* { box-sizing: border-box; }

/* The `hidden` attribute must win over the `display` rules below, otherwise
   sections set to display:flex stay visible when hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #0f1115;
  color: #e6e8ec;
  min-height: 100vh;
}

h1 { font-size: 1.3rem; margin: 0; }
h2 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; color: #9aa1ad; margin: 1.2rem 0 0.4rem; }

button {
  background: #2a2f3a;
  color: inherit;
  border: 1px solid #3a4150;
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  font-size: 0.9rem;
}
button:hover { background: #353c4a; }
button.primary { background: #c2362b; border-color: #c2362b; }
button.primary:hover { background: #d8453a; }

input {
  background: #1a1e26;
  color: inherit;
  border: 1px solid #3a4150;
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  font-size: 0.9rem;
}
input:focus { outline: 2px solid #c2362b; border-color: transparent; }

.error { color: #ff7a6e; }
.muted { color: #9aa1ad; font-size: 0.85rem; }

button.link {
  background: none;
  border: none;
  color: #9aa1ad;
  text-decoration: underline;
  padding: 0;
  font-size: 0.85rem;
}
button.link:hover { background: none; color: #e6e8ec; }

/* Account widget */
#account {
  position: fixed;
  top: 0.7rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: #9aa1ad;
  z-index: 10;
}
#me { font-weight: 600; color: #e6e8ec; }
/* When moved into the room header it joins the normal flow. */
#account.in-header { position: static; }

/* Auth page */
#auth {
  max-width: 22rem;
  margin: 16vh auto 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 0 1rem;
}
#auth h1 { font-size: 2.2rem; }
#auth h2 { color: #e6e8ec; text-transform: none; letter-spacing: 0; font-size: 1.1rem; }
#auth-form { display: flex; flex-direction: column; gap: 0.6rem; }

/* Lobby */
#lobby {
  max-width: 26rem;
  margin: 18vh auto 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0 1rem;
}
#lobby h1 { font-size: 2.2rem; }
#join-form { display: flex; gap: 0.5rem; justify-content: center; }
#join-code { flex: 1; max-width: 14rem; }

/* Room */
#room { display: flex; flex-direction: column; height: 100vh; }
#room-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid #2a2f3a;
  background: #12151b;
}
.bar-group {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.85rem;
  color: #9aa1ad;
}
.brand {
  font-weight: 700;
  color: #e6e8ec;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* Pixelated play-button logo. */
.logo {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
}
.logo-lg {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
  align-self: center;
}
.room-meta strong { color: #e6e8ec; }

button.ghost {
  background: transparent;
  border: 1px solid #3a4150;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}
button.ghost:hover { background: #2a2f3a; }
#exit-room { color: #e6e8ec; }

.layout {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 1rem;
  padding: 1rem;
}
.layout main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-width: 0;
}
#player-wrap {
  flex: 1;
  min-height: 0;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}
#player-wrap iframe, #player { width: 100%; height: 100%; }

#video-form { display: flex; gap: 0.5rem; }
#video-url { flex: 1; }

.layout aside {
  width: 18rem;
  flex-shrink: 0;
  background: #161a21;
  border-radius: 8px;
  padding: 0.4rem 1rem 1rem;
  overflow-y: auto;
}
aside ul { list-style: none; margin: 0; padding: 0; }
aside li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid #21262f;
}
aside li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptime {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: #9aa1ad;
  font-size: 0.8rem;
}
.queue-remove {
  padding: 0.1rem 0.4rem;
  font-size: 0.75rem;
  border: none;
  background: transparent;
  color: #9aa1ad;
}
.queue-remove:hover { color: #ff7a6e; background: transparent; }

#toast {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #2a2f3a;
  border: 1px solid #3a4150;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-size: 0.9rem;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.4);
}

@media (max-width: 800px) {
  .layout { flex-direction: column; overflow-y: auto; }
  .layout main { flex: none; }
  #player-wrap { aspect-ratio: 16 / 9; flex: none; }
  .layout aside { width: auto; }
  #video-form { flex-wrap: wrap; }
}
