:root {
  color-scheme: dark;
  --gold: #efd08b;
  --ink: #f3f0e5;
  --muted: #aec5b9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #082d25;
  color: var(--ink);
  font:
    16px/1.5 system-ui,
    sans-serif;
}

header {
  padding: 17px clamp(16px, 4vw, 60px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid #ffffff20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid #a9bc94;
  border-radius: 50%;
  font: 27px Georgia;
  color: var(--gold);
}

.brand strong {
  display: block;
  font: 23px/1.2 Georgia;
  letter-spacing: 4px;
}

.brand small {
  display: block;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--muted);
}

nav,
.roomline,
.tabs,
.tags {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

a {
  color: var(--gold);
}

nav a,
nav button {
  font-size: 12px;
}

button,
input,
select {
  font: inherit;
  min-height: 46px;
  border-radius: 9px;
  border: 1px solid #ffffff38;
  padding: 11px 14px;
  background: #173e35;
  color: var(--ink);
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:hover {
  background: #285647;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.primary {
  background: var(--gold);
  color: #163a2d;
  font-weight: 800;
}

.primary:hover {
  background: #ffe3a3;
}

main {
  max-width: 1080px;
  margin: 28px auto;
  padding: 0 24px;
}

.panel {
  background: #123c31;
  border: 1px solid #ffffff20;
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 18px;
}

.setup {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 50px;
  padding: 40px;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--gold);
  font-weight: 700;
}

h1 {
  font: normal clamp(40px, 5vw, 62px) / 1.12 Georgia;
  margin: 20px 0;
}

h1 em {
  color: var(--gold);
}

h2 {
  font: normal 29px Georgia;
  margin: 0 0 18px;
}

p {
  color: var(--muted);
}

label {
  display: block;
  margin: 14px 0 6px;
}

input,
select {
  width: 100%;
  background: #f8f1dc;
  color: #163a2d;
  border: 2px solid #d4c69e;
}

input::placeholder {
  color: #667465;
}

.wide {
  width: 100%;
  margin-top: 20px;
}

.tabs {
  margin-bottom: 24px;
}

.tabs button {
  flex: 1;
}

.tags span {
  border: 1px solid #ffffff25;
  border-radius: 30px;
  padding: 5px 10px;
  font-size: 12px;
}

.paper {
  margin-top: 30px;
  background: #f8f1dc;
  color: #244539;
  padding: 24px;
  border-radius: 4px;
  transform: rotate(-2deg);
  font: 16px Georgia;
  box-shadow: 8px 8px 0 #0002;
}

.paper b {
  font-size: 12px;
  letter-spacing: 2px;
}

.paper p {
  color: #244539;
  border-bottom: 1px solid #24453940;
  padding-bottom: 10px;
}

.roomline {
  justify-content: space-between;
  margin-bottom: 16px;
}

.players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.player {
  border: 1px solid #ffffff25;
  background: #173e35;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
}

.player b {
  color: var(--gold);
}

.player button {
  font-size: 12px;
  padding: 5px;
  min-height: 44px;
}

.small {
  font-size: 12px;
}

.muted,
small {
  color: var(--muted);
}

.secret {
  background: #f8f1dc;
  color: #244539;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  margin: 20px 0;
}

.secret strong {
  font: 36px Georgia;
  display: block;
}

.secret p {
  color: #244539;
}

.clues {
  list-style: none;
  padding: 0;
}

.clues li {
  padding: 14px 0;
  border-bottom: 1px solid #ffffff20;
  overflow-wrap: anywhere;
}

.clues b {
  color: var(--gold);
  display: block;
}

.votes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.selected {
  outline: 2px solid var(--gold);
}

.ranking {
  padding: 0;
  list-style: none;
}

.ranking li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #ffffff20;
}

.ranking b {
  color: var(--gold);
}

#hud {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #082d25;
  box-shadow: 0 4px 12px #0005;
  border-bottom: 2px solid var(--gold);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

#clock {
  color: var(--gold);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

footer {
  text-align: center;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 25px;
}

dialog {
  width: min(640px, 94vw);
  max-height: 85dvh;
  overflow: auto;
  background: #123c31;
  color: var(--ink);
  border: 1px solid var(--gold);
  border-radius: 18px;
  padding: 24px;
}

dialog::backdrop {
  background: #001b17d9;
}

dialog li {
  margin: 14px 0;
}

#closeRules {
  float: right;
}

summary {
  cursor: pointer;
}

details h3 {
  color: var(--gold);
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  header {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .brand strong {
    font-size: 20px;
    letter-spacing: 3px;
  }

  main {
    padding: 0 12px;
    margin: 18px auto;
  }

  .setup {
    grid-template-columns: 1fr;
    gap: 30px;
    padding: 24px;
  }

  .panel {
    padding: 18px;
  }

  .roomline>div {
    display: flex;
    gap: 6px;
  }

  .roomline button {
    font-size: 12px;
  }

  .votes {
    grid-template-columns: 1fr;
  }

  .paper {
    margin: 24px 0 8px;
  }

  .secret strong {
    font-size: 30px;
  }

  #hud {
    font-size: 13px;
    align-items: center;
  }
}

.room-stats {
  grid-column: 1/-1;
  justify-self: end;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 0;
}

.guess {
  margin: 24px 0;
  padding: 20px;
  border: 1px solid var(--gold);
  border-radius: 12px;
}

.spectator {
  padding: 14px;
  background: #082d25;
  border-radius: 9px;
}

/* Menús nativos legibles sobre fondo crema, también al desplegarlos. */
select {
  color-scheme: light;
  background-color: #f8f1dc;
  color: #163a2d;
}

select option {
  background-color: #f8f1dc;
  color: #163a2d;
}

select option:checked {
  background-color: #efd08b;
  color: #163a2d;
}

/* Separación de los controles de la sala de espera. */
#lobbyMode {
  margin-bottom: 16px;
}

#lobbyRoundOptions:not([hidden]) {
  margin-bottom: 16px;
}

#changeMode {
  margin-right: 12px;
  margin-bottom: 8px;
}

#start {
  margin-bottom: 8px;
}

/* Chat: el campo se conserva al recibir nuevos mensajes. */
.chat-panel {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #ffffff30;
}

.chat-log {
  max-height: 260px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #082d25;
  border-radius: 10px;
  padding: 12px;
}

.chat-log p {
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}

.chat-log p:last-child {
  margin-bottom: 0;
}

.chat-log b {
  display: block;
  color: var(--gold);
  font-size: 13px;
}

.chat-log span {
  color: var(--ink);
  white-space: pre-wrap;
}

.chat-compose {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.chat-compose input {
  min-width: 0;
  flex: 1;
}

@media (max-width: 480px) {
  .chat-compose {
    flex-direction: column;
  }

  .chat-log {
    max-height: 220px;
  }
}

/* Menú superior compartido con Tutti Frutti y Conga Online. */
.topbar .header-actions {
  gap: 7px;
  justify-content: flex-end;
}

.topbar .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid #ffffff1f;
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12px;
  line-height: 1.5;
  min-height: 0;
}

.topbar .ghost:hover {
  background: #ffffff16;
}

.topbar .online-status {
  font-size: 12px;
  color: var(--muted);
}

.topbar nav a {
  color: var(--gold) !important;
}

@media (max-width: 760px) {
  .topbar {
    padding: 14px 16px;
    gap: 12px;
  }

  .topbar .header-actions {
    justify-content: flex-start;
  }

  .topbar .ghost {
    min-height: 44px;
  }

  .topbar .online-status {
    flex-basis: 100%;
  }
}

/* Ranking de medallas en columnas, con desplazamiento en celulares. */
.medal-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.medal-table {
  width: 100%;
  min-width: 540px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.medal-table caption {
  text-align: left;
  color: var(--muted);
  font-size: 13px;
  padding-bottom: 12px;
}

.medal-table th,
.medal-table td {
  padding: 12px;
  border-bottom: 1px solid #ffffff25;
  text-align: center;
}

.medal-table thead th {
  color: var(--gold);
  white-space: nowrap;
}

.medal-table th:nth-child(2) {
  text-align: left;
  overflow-wrap: anywhere;
}

.medal-table tbody th {
  min-width: 140px;
}

.medal-table small {
  display: block;
  font-weight: normal;
  color: var(--muted);
  font-size: 12px;
}

.medal-table .medal-empty {
  text-align: left;
  color: var(--muted);
}

/* Avatares compartidos con los otros juegos. */
.avatar {
  width: 32px;
  height: 32px;
  object-fit: contain;
  vertical-align: middle;
  border-radius: 50%;
  flex-shrink: 0;
}

.avatar-picker {
  margin: 0 0 22px;
  padding: 14px;
  border: 1px solid #ffffff25;
  border-radius: 12px;
  min-width: 0;
}

.avatar-picker legend {
  color: var(--gold);
  padding: 0 6px;
}

.avatar-current {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.avatar-current .avatar {
  width: 44px;
  height: 44px;
}

.avatar-choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.avatar-choices button {
  padding: 6px;
  min-height: 48px;
}

.avatar-choices button[aria-pressed="true"] {
  outline: 2px solid var(--gold);
  background: #285647;
}

.player .avatar {
  width: 26px;
  height: 26px;
}

.chat-log b .avatar {
  margin-right: 6px;
}

/* Selector con desplazamiento vertical, igual que Tutti Frutti. */
.avatar-choices {
  max-height: min(280px, 40dvh);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 4px;
}

/* Ventanas de selección y avisos: no ocupan espacio en el tablero. */
.avatar-dialog {
  width: min(620px, 94vw);
}

.dialog-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.dialog-heading h2 {
  margin: 0;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 24px;
  flex-wrap: wrap;
}

.message-dialog {
  width: min(480px, 94vw);
}

#messageText {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.avatar-open {
  margin-top: 4px;
}

.avatar-dialog .avatar-choices {
  max-height: min(400px, 50dvh);
  margin: 20px 0;
}

html {
  scrollbar-gutter: stable;
}

/* Presentación inicial compacta, con el texto de bienvenida. */
#entry h1 {
  font-size: clamp(28px, 3vw, 32px);
  line-height: 1.25;
  margin: 20px 0;
}

#entry h2 {
  font-size: 26px;
  line-height: 1.25;
}

.game-intro {
  margin-top: 28px;
}

.game-intro h3 {
  margin: 0 0 10px;
  color: var(--gold);
  font:
    normal 23px/1.3 Georgia,
    serif;
}

.game-intro p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.game-intro p:last-child {
  margin-bottom: 0;
}

#entry.setup {
  row-gap: 20px;
  padding-bottom: 24px;
  align-items: start;
}

#entry .room-stats {
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

@media (max-width: 760px) {
  .game-intro {
    margin-top: 24px;
  }

  #entry.setup {
    row-gap: 24px;
    padding-bottom: 20px;
  }
}