* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0a1420;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #eaf6ff;
}

.hidden {
  display: none !important;
}

#back-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 30;
  background: rgba(6, 14, 22, 0.65);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  color: #eaf6ff;
  text-decoration: none;
}

#back-link:hover {
  background: rgba(6, 14, 22, 0.85);
}

#lobby, #players-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(20, 40, 60, 0.6), rgba(4, 10, 16, 0.9));
}

.panel {
  background: rgba(8, 18, 28, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2rem 2.5rem;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  text-align: center;
  max-width: 420px;
  width: min(90vw, 420px);
  max-height: 90vh;
  overflow-y: auto;
}

.panel h1 {
  margin: 0 0 0.5rem;
  background: linear-gradient(90deg, #34e89e, #3b9dff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.panel h3 {
  margin: 1rem 0 0.25rem;
  font-size: 0.85rem;
  color: #a7bdd1;
  text-align: left;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.panel-header h2 {
  margin: 0;
}

.tagline {
  color: #a7bdd1;
  font-size: 0.9rem;
  margin: 0 0 0.75rem;
}

.mode-hint {
  color: #6b8199;
  font-size: 0.85rem;
}

.player-list {
  list-style: none;
  margin: 0.5rem 0 1rem;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.player-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.9rem;
}

.player-list li.is-drawer {
  border: 1px solid #3b9dff;
}

.player-list .score {
  color: #a7bdd1;
  font-variant-numeric: tabular-nums;
}

button {
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #34e89e, #3b9dff);
  color: #04121c;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

#spectate-toggle-btn {
  display: block;
  width: 100%;
  margin: 0.5rem 0 0;
}

#category-select {
  display: block;
  width: 100%;
  margin: 0.3rem 0 0.75rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #eaf6ff;
  font-size: 0.9rem;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.small-btn {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: inherit;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

#game {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

#top-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  /* Left-padded so content clears the fixed "← Back to chat" pill sitting on top of it. */
  padding-left: 9rem;
  background: rgba(6, 14, 22, 0.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

@media (max-width: 480px) {
  #top-bar {
    padding-left: 1rem;
    padding-top: 3rem;
    flex-wrap: wrap;
  }
}

#round-status {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#round-timer {
  font-variant-numeric: tabular-nums;
  color: #a7bdd1;
  font-size: 0.85rem;
}

#board-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0.5rem;
}

#board {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
}

#toolbar {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(6, 14, 22, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
}

#color-swatches {
  display: flex;
  gap: 0.25rem;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  padding: 0;
}

.color-swatch.active {
  border-color: #fff;
}

#feed {
  max-height: 25vh;
  overflow-y: auto;
  padding: 0.4rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.85rem;
  background: rgba(6, 14, 22, 0.5);
}

#feed .feed-correct {
  color: #34e89e;
  font-weight: 600;
}

#feed .feed-system {
  color: #6b8199;
  font-style: italic;
}

#guess-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(6, 14, 22, 0.75);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

#guess-input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #eaf6ff;
  font-size: 1rem;
}

#guess-input::placeholder {
  color: #7891a7;
}
