/* Family Games Hub — panel de administración.
 *
 * Self-contained: no external fonts, no remote assets, no CDN. Mobile-first.
 * Sober dark surface, white/near-black chrome, color reserved for state and
 * functional actions. Yellow is NEVER used as body text — only as a high-
 * contrast accent for warnings, and always paired with an icon or text.
 */

:root {
  --bg: #fff7ea;
  --bg-elevated: #ffffff;
  --bg-input: #fff1d9;
  --fg: #2b241f;
  --fg-muted: #675c52;
  --fg-subtle: #8b7d70;
  --border: #ead9c0;
  --border-strong: #d8b98e;
  --accent: #4f7cff;
  --accent-strong: #315ed8;
  --danger: #c43d4b;
  --warn-bg: #fff0bd;
  --warn-fg: #6f5200;
  --success: #2f9f6b;
  --focus: #6f52ff;
  --surface-card: #ffffff;
  --surface-card-hover: #fffaf1;
  --shadow-card: 0 1px 0 rgba(80, 53, 21, 0.06), 0 8px 24px rgba(80, 53, 21, 0.10);
  --radius: 20px;
  --radius-lg: 28px;
  --radius-pill: 999px;
  --gap: 16px;
  --max-width: 1200px;
  --touch-min: 44px;
  --font-stack: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  background:
    radial-gradient(circle at 8% 10%, rgba(255, 216, 119, 0.35), transparent 26rem),
    radial-gradient(circle at 90% 0%, rgba(118, 184, 255, 0.22), transparent 24rem),
    var(--bg);
  color: var(--fg);
  font-family: var(--font-stack);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent-strong);
}

/* Skip-link for keyboard users: visible on focus only. */
.skip-link {
  position: absolute;
  left: 8px;
  top: -40px;
  background: var(--fg);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: var(--radius);
  z-index: 100;
  text-decoration: none;
}
.skip-link:focus {
  top: 8px;
}

/* Topbar -------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 14px rgba(80, 53, 21, 0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar__title {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.topbar__subtitle {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.topbar__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.topbar__session {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

/* Cross-navigation link styled as a topbar button (admin <-> play).
   It is a real anchor so it works without JS and keeps middle-click. */
a.topbar__link {
  color: inherit;
  text-decoration: none;
}

/* Layout -------------------------------------------------------------- */

.layout {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.footnote {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--fg-subtle);
  text-align: center;
}

/* Cards --------------------------------------------------------------- */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
}

.card__title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.card__hint {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.card--password {
  border-color: var(--border-strong);
  margin-top: 16px;
}

.password-line__value code {
  font-family: ui-monospace, SFMono-Regular, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 1rem;
  color: var(--fg);
  background: var(--bg-input);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
}

/* Centred cards (login, create): their labels and action rows sit on the
 * card's visual axis instead of hugging the left edge. Inputs keep their
 * full width; only the label text and the action row are centred. The
 * dashboard / detail panels use ``.panel`` and are untouched. */
.card--login .field label,
.card--create .field label {
  text-align: center;
}

.card--login .form-actions,
.card--create .form-actions {
  justify-content: center;
}

/* Forms --------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.9rem;
  color: var(--fg);
  font-weight: 500;
}

.field input,
.field textarea {
  background: var(--bg-input);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font: inherit;
  min-height: var(--touch-min);
  width: 100%;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #6c7382;
  opacity: 1;
}

.field textarea {
  resize: vertical;
  min-height: calc(var(--touch-min) * 3);
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.btn:focus,
.room-card:focus {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.form-status {
  margin: 0;
  font-size: 0.9rem;
  min-height: 1.2em;
}

.form-status[data-state="error"] {
  color: var(--danger);
}

.form-status[data-state="success"] {
  color: var(--success);
}

.form-status[data-state="warn"] {
  color: var(--warn-fg);
}

/* Buttons ------------------------------------------------------------- */

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--fg);
  font: inherit;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1;
}

.btn:hover {
  border-color: var(--fg-muted);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.btn--ghost {
  background: transparent;
  color: var(--fg);
}

.btn--danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn--danger:hover {
  background: var(--danger);
  color: var(--bg);
}

/* Dashboard ------------------------------------------------------------ */

.dashboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  align-items: start;
}

@media (min-width: 760px) {
  .dashboard {
    grid-template-columns: minmax(260px, 360px) 1fr;
  }
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.panel__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.panel__head-actions {
  display: flex;
  gap: 8px;
}

.panel__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  color: var(--fg-muted);
  font-size: 0.95rem;
  margin: 0;
}

/* Rooms list ----------------------------------------------------------- */

.rooms-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Each room card sits inside its own <li> so the <ul> markup stays valid.
 * The <li> is a transparent container; the parent already supplies the
 * gap, and the button keeps its full-width card visuals. */
.rooms-list > li {
  list-style: none;
}

.room-card {
  width: 100%;
  text-align: left;
  background: var(--bg-input);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(80, 53, 21, 0.04);
  padding: 12px 14px;
  font: inherit;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  min-height: var(--touch-min);
}

.room-card:hover {
  border-color: var(--fg-muted);
  background: var(--surface-card-hover);
  transform: translateY(-1px);
}

.room-card[aria-current="true"] {
  border-color: var(--fg);
}

.room-card__name {
  font-weight: 600;
  grid-column: 1 / -1;
}

.room-card__meta {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.room-card__status {
  font-size: 0.85rem;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  white-space: nowrap;
}

.room-card__status[data-status="WAITING"] {
  border-color: var(--fg-muted);
}

.room-card__status[data-status="PLAYING"] {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.room-card__status[data-status="FINISHED"] {
  border-color: var(--success);
  color: var(--success);
}

.room-card__status[data-status="CLOSED"] {
  border-color: var(--border-strong);
  color: var(--fg-subtle);
}

.room-card__item {
  display: grid;
  gap: 8px;
}

.btn--small {
  padding: 6px 10px;
  font-size: 0.85rem;
}

/* Detail --------------------------------------------------------------- */

.detail__head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail__title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.detail__meta {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.players-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: var(--touch-min);
}

.player-row__name {
  font-weight: 500;
}

.player-row__chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.player-row .btn {
  grid-column: 1 / -1;
  justify-self: end;
}

/* Add-participant panel on the room detail ---------------------------- */

.add-player-panel {
  margin: 16px 0 0;
  padding: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.add-player-panel__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
}

.add-player-panel__hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--fg-muted);
}

.add-player-panel__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.add-player-panel__row input {
  flex: 1 1 160px;
  min-width: 0;
}

.chip {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--fg-muted);
  white-space: nowrap;
}

.chip--claimed {
  border-color: var(--success);
  color: var(--success);
}

.chip--unclaimed {
  border-color: var(--fg-muted);
}

.chip--active {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.chip--score {
  border-color: var(--fg-muted);
  color: var(--fg);
}

/* Password reveal panel on the room detail --------------------------- */

.password-panel {
  margin: 16px 0 0;
  padding: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.password-panel__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
}

.password-panel__hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--fg-muted);
}

.password-panel__value {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.4rem;
  letter-spacing: 0.08em;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  min-height: 1.4em;
  word-break: break-all;
}

.password-panel__value[data-revealed='false'] {
  color: var(--fg-subtle);
}

.password-panel__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.password-panel__status {
  margin: 0;
  font-size: 0.85rem;
  min-height: 1.1em;
}

.password-panel__status[data-state='success'] {
  color: var(--success);
}

.password-panel__status[data-state='error'] {
  color: var(--danger);
}

/* Password line -------------------------------------------------------- */

.password-line {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.password-line__label {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.password-line__value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.05rem;
  word-break: break-all;
  letter-spacing: 0.02em;
  color: var(--fg);
}

/* Action bar inside the detail panel ------------------------------------ */

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* Share bar inside the detail panel ------------------------------------
 *
 * Holds the open-room / copy-link controls plus their inline status.
 * Sits between the title+meta and the players list so it reads as
 * "how do I share this room" before "who is in it".
 */

.detail__share {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.detail__share-status {
  margin: 0;
  font-size: 0.85rem;
  min-height: 1.1em;
  color: var(--fg-muted);
}

.detail__share-status[data-state='success'] {
  color: var(--success);
}

.detail__share-status[data-state='error'] {
  color: var(--danger);
}

/* Utilities ------------------------------------------------------------ */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: no-preference) {
  .btn,
  .room-card {
    transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
  }
}

/* Theme picker --------------------------------------------------------- */

.theme-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: 10px;
}

.theme-picker__option {
  min-height: 112px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-card);
  color: var(--fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.theme-picker__option[aria-pressed='true'] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.16);
}

.theme-picker__name {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

.theme-picker__preview {
  display: flex;
  gap: 5px;
  min-height: 42px;
}

.theme-picker__preview img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 10px;
  background: var(--bg-input);
}

.setup-intro__eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.setup-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
}

.setup-block__title {
  margin: 0;
  font-size: 1rem;
}

.game-choice,
.mode-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-card);
}

label.game-choice {
  cursor: pointer;
}

.game-choice--selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.game-choice__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #e7edff;
  font-size: 1.4rem;
}

.game-choice small,
.mode-option small {
  display: block;
  margin-top: 3px;
  color: var(--fg-muted);
  font-size: .82rem;
}

.game-choice .chip {
  margin-left: auto;
}

.mode-picker {
  display: grid;
  gap: 8px;
}

.mode-option {
  align-items: flex-start;
  cursor: pointer;
}

.mode-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, .12);
}

.mode-option input {
  margin-top: 3px;
  accent-color: var(--accent);
}

/* Change-password view ----------------------------------------------------
 * Reuses the existing .card / .field / .form-actions / .form-status / .btn
 * primitives. Only the per-view overrides live here so the card stays in
 * sync with the rest of the panel without touching the shared styles. */
.view--password .card--password-change .field label {
  text-align: center;
}

.view--password .card--password-change .form-actions {
  justify-content: center;
}

.password-hint-list {
  margin: 0;
  padding-left: 1.2em;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

/* Hall ---------------------------------------------------------------- */

.view--hall {
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.hall-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hall-item {
  list-style: none;
}