/* Footy Grid — dark cyan board, inspired by classic football grid games. */

:root {
  --bg:        #050d19;
  --cell:      #0a1726;
  --cell-hi:   #102336;
  --line:      #2f6d95;
  --line-soft: #1d4258;
  --cyan:      #5bc8f5;
  --cyan-deep: #0b1a2b;
  --gold:      #f5b417;
  --text:      #e8f2fa;
  --muted:     #7f9cb5;
  --ok:        #35d07f;
  --ko:        #ff5470;
  --x:         #ff8b3d;
  --o:         #5bc8f5;
  --radius:    4px;
  --col: min(760px, calc(100vw - 2 * clamp(8px, 2vw, 20px)));
  --brand-white: #fff;
  --hint:      #ffffff26;
  --scrim:     #030812d9;
  --body:      #c4d6e6;
  --font:      system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* Tema claro: la misma paleta que lightTheme en lib/grid/theme.dart. */
:root[data-theme="light"] {
  --bg:        #eff4f9;
  --cell:      #ffffff;
  --cell-hi:   #e3edf5;
  --line:      #7fafc9;
  --line-soft: #c7dae6;
  --cyan:      #1494d0;
  --cyan-deep: #05263a;
  --gold:      #be7c05;
  --text:      #0b2233;
  --muted:     #5a748a;
  --ok:        #12894f;
  --ko:        #d22b45;
  --x:         #d1620a;
  --o:         #1180b4;
  --brand-white: #0b2233;
  --hint:      #0b223333;
  --scrim:     #33445599;
  --body:      #2a4357;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(8px, 2vw, 20px);
  gap: 14px;
}

#app {
  width: var(--col);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* ── top bar ─────────────────────────────────────────────── */

.topbar {
  width: var(--col);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Logotipo apilado: las dos lineas miden lo mismo (ver brandSvg en kits.js),
   asi que el tamano lo manda el ancho del hueco, no el cuerpo de letra. */
.brand { width: 132px; margin-right: auto; }
.brand svg { display: block; width: 100%; height: auto; letter-spacing: -.02em; }
.brand__gold  { fill: var(--gold); }
.brand__white { fill: var(--brand-white); }
.brand__cyan  { fill: var(--cyan); }

.modes { display: flex; gap: 4px; background: var(--cell); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 3px; }
.mode {
  border: 0; background: transparent; color: var(--muted);
  font: 600 13px/1 var(--font); padding: 8px 12px; border-radius: 3px; cursor: pointer;
}
.mode.is-on { background: var(--cyan); color: var(--cyan-deep); }
.mode:not(.is-on):hover { color: var(--text); background: var(--cell-hi); }

.topbar__right { display: flex; gap: 6px; }

.btn, .sel {
  font: 600 13px/1 var(--font);
  padding: 9px 14px; border-radius: var(--radius); cursor: pointer;
  background: var(--cyan); color: var(--cyan-deep); border: 1px solid var(--cyan);
}
.btn--ghost, .sel { background: var(--cell); color: var(--text); border-color: var(--line-soft); }
.btn:hover { filter: brightness(1.08); }
.btn--ghost:hover, .sel:hover { border-color: var(--line); }
.sel { padding-right: 8px; }

/* ── status ──────────────────────────────────────────────── */

.status { width: var(--col); display: flex; align-items: baseline; gap: 10px; min-height: 22px; flex-wrap: wrap; }
.status__main { font-weight: 700; font-size: 15px; }
.status__sub { color: var(--muted); font-size: 13px; }
.status__main .turn-x { color: var(--x); }
.status__main .turn-o { color: var(--o); }

/* ── board ───────────────────────────────────────────────── */

.boardwrap {
  max-width: var(--board, 100%);
  /* Keep the whole board on screen: never wider than the column, never taller
     than what is left of the viewport once the chrome is laid out. */
  width: 100%;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.tile {
  position: relative;
  container-type: inline-size;   /* lets type scale with the tile, not the viewport */
  color: var(--text);
  font-family: var(--font);
  aspect-ratio: 1;
  background: var(--cell);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* logo tile */
.tile--logo { align-items: center; justify-content: center; border-color: var(--line); }
.tile--logo .brand { width: 84%; margin: 0; }

/* header tiles: artwork + cyan caption bar */
.tile--head { padding: 0; }
.tile--head .art {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 12% 14%;
}
.tile--head .art svg, .tile--head .art img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile--head .art .flag { border: 1px solid #00000055; }
.tile--head .art .flag--fallback {
  width: 100%; aspect-ratio: 3/2; display: grid; place-items: center;
  background: var(--cell-hi); color: var(--muted); font-weight: 800; font-size: 12px;
}
.tile--head .cap {
  background: var(--cyan); color: var(--cyan-deep);
  font-weight: 800; font-size: clamp(8px, 9.5cqw, 14px); letter-spacing: .02em;
  text-transform: uppercase; text-align: center;
  padding: 7px 4px; line-height: 1.1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* playable cells */
.tile--cell { cursor: pointer; align-items: center; justify-content: center; padding: 6px; text-align: center; }
.tile--cell:hover:not(.is-done) { background: var(--cell-hi); border-color: var(--cyan); }
.tile--cell:disabled { cursor: default; color: var(--text); opacity: 1; }
.tile--cell .plus { color: var(--line); font-size: 26px; font-weight: 300; line-height: 1; }
.tile--cell .hintN { position: absolute; bottom: 5px; right: 7px; font-size: 10px; color: var(--hint); font-weight: 700; }

.cellface { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; padding: 4px; }
.cellface img.face {
  width: clamp(34px, 9vw, 54px); height: clamp(34px, 9vw, 54px);
  border-radius: 50%; object-fit: cover; background: var(--cell-hi);
  border: 1.5px solid var(--line-soft);
}
.cellface .nm { font-size: clamp(9px, 9cqw, 12px); font-weight: 700; line-height: 1.15;
                 color: var(--text); overflow-wrap: anywhere; }
.cellface .rr { font-size: clamp(8px, 7cqw, 10px); color: var(--muted); font-weight: 700; }
.tile--cell.is-x { border-color: var(--x); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--x) 20%, transparent); }
.tile--cell.is-o { border-color: var(--o); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--o) 20%, transparent); }
.tile--cell.is-ok { border-color: var(--ok); }
.tile--cell.is-win { background: color-mix(in srgb, var(--ok) 10%, transparent); }
.tile--cell.is-empty-final .plus { color: var(--ko); font-size: 20px; }

.mark { position: absolute; top: 4px; left: 6px; font-weight: 900; font-size: 13px; }
.mark--x { color: var(--x); }
.mark--o { color: var(--o); }

/* ── answers panel ───────────────────────────────────────── */

.panel {
  width: var(--col);
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--cell); padding: 12px 14px;
}
.panel h3 { margin: 0 0 8px; font-size: 14px; }
.panel ol { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.panel b { color: var(--text); }

/* ── footer ──────────────────────────────────────────────── */

.foot { width: var(--col); display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
        color: var(--muted); font-size: 12px; padding-bottom: 8px; }
.link { background: none; border: 0; color: var(--cyan); font: 600 12px var(--font); cursor: pointer; padding: 0; }
.link:hover { text-decoration: underline; }
.dot { opacity: .4; }
.credit a { color: var(--muted); }

.getapp { width: var(--col); display: flex; align-items: center; gap: 12px; text-decoration: none;
          background: var(--cell); border: 1px solid var(--line-soft); border-radius: var(--radius);
          padding: 8px 12px; color: var(--text); margin-bottom: 8px; }
.getapp:hover { border-color: var(--cyan); }
.getapp img { border-radius: 8px; flex: none; }
.getapp__txt { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.getapp__txt b { font-size: 14px; }
.getapp__txt small { color: var(--muted); font-size: 12px; }
.getapp__cta { flex: none; background: var(--cyan); color: var(--cyan-deep); font-weight: 800;
               font-size: 13px; padding: 8px 12px; border-radius: var(--radius); }

/* Con sitio a la derecha del tablero, el banner pasa a ser una tarjeta lateral. */
@media (min-width: 1260px) {
  .getapp { position: fixed; top: 50%; right: max(24px, calc((100vw - 760px) / 2 - 300px));
            transform: translateY(-50%); width: 240px; flex-direction: column; align-items: flex-start;
            gap: 14px; padding: 22px; margin: 0; border-color: var(--line); }
  .getapp img { width: 64px; height: 64px; border-radius: 14px; }
  .getapp__txt b { font-size: 20px; line-height: 1.15; }
  .getapp__txt small { font-size: 14px; margin-top: 6px; }
  .getapp__cta { width: 100%; text-align: center; font-size: 15px; padding: 12px; }
}

/* ── overlays ────────────────────────────────────────────── */

.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: var(--scrim); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: clamp(10px, 6vh, 70px) 12px;
}
.overlay[hidden] { display: none; }

.sheet {
  width: min(520px, 100%);
  background: var(--cell); border: 1.5px solid var(--line);
  border-radius: 6px; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: 86dvh;
}
.sheet__head { display: flex; align-items: center; gap: 10px; }
.sheet__crumbs { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.sheet__crumbs .chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--cell-hi); border: 1px solid var(--line-soft); border-radius: 3px;
  padding: 4px 8px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.sheet__crumbs .chip svg, .sheet__crumbs .chip img { width: 18px; height: 18px; object-fit: contain; }
.sheet__crumbs .x { color: var(--muted); font-weight: 700; }
.sheet__close { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; }
.sheet__close:hover { color: var(--text); }
.sheet__title { margin: 0; font-size: 15px; font-weight: 700; }
.sheet__input {
  width: 100%; padding: 12px; font: 500 15px var(--font);
  background: var(--bg); border: 1.5px solid var(--line-soft); border-radius: var(--radius); color: var(--text);
}
.sheet__input:focus { outline: none; border-color: var(--cyan); }
.sheet__hint { margin: 0; color: var(--muted); font-size: 12px; }

.results { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.results li { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius); cursor: pointer; }
.results li:hover, .results li.is-sel { background: var(--cell-hi); }
.results img.face { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--bg); }
.results .noface { width: 34px; height: 34px; border-radius: 50%; background: var(--bg); display: grid; place-items: center;
                   color: var(--muted); font-size: 13px; font-weight: 800; }
.results .who { flex: 1; min-width: 0; }
.results .who b { display: block; font-size: 14px; font-weight: 700; }
.results .who span { display: block; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sheet--text { gap: 8px; font-size: 14px; line-height: 1.6; }
.sheet--text h2 { margin: 0; font-size: 18px; }
.sheet--text p, .sheet--text ul { margin: 0; color: var(--body); }
.sheet--text ul { padding-left: 20px; }
.sheet--text .sheet__close { position: absolute; }
.rules__modes { border-top: 1px solid var(--line-soft); padding-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--cell); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 10px 16px; font-weight: 700; font-size: 14px; z-index: 40;
  animation: pop .18s ease-out;
}
.toast--ok { border-color: var(--ok); color: var(--ok); }
.toast--ko { border-color: var(--ko); color: var(--ko); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 520px) {
  .topbar { gap: 8px; }
  .topbar > .brand { width: 112px; }
  .modes { order: 3; width: 100%; }
  .mode { flex: 1; padding: 8px 6px; }
}

.cellface .noface {
  display: grid; place-items: center;
  color: var(--muted); font-weight: 800; font-size: 16px;
}

/* ── ajustes, reloj ──────────────────────────────────────── */

.iconbtn {
  order: 4; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer;
  background: var(--cell); color: var(--cyan); border: 1px solid var(--line-soft); border-radius: var(--radius);
}
.iconbtn:hover { background: var(--cell-hi); }
.topbar > .modes { order: 2; }
.topbar > .topbar__right { order: 3; }
@media (max-width: 520px) {
  .topbar > .iconbtn { order: 1; }
  .topbar > .topbar__right { width: 100%; }
  .topbar__right .sel { margin-right: auto; }
}

.credit { flex-basis: 100%; }

.status .clock {
  flex-basis: 100%; position: relative; height: 30px; margin-top: 10px; overflow: hidden;
  background: var(--cell); border: 1px solid var(--line-soft); border-radius: var(--radius);
}
.clock__fill { position: absolute; inset: 0 auto 0 0; background: var(--cyan); transition: width .9s linear; }
.clock.is-urgent .clock__fill { background: color-mix(in srgb, var(--ko) 65%, transparent); }
.clock.is-idle .clock__fill { width: 0 !important; }
.clock__txt {
  position: relative; display: flex; align-items: center; height: 100%; padding: 0 10px;
  font-weight: 800; font-size: 13px; letter-spacing: .5px; font-variant-numeric: tabular-nums; color: var(--cyan-deep);
}
.clock.is-urgent .clock__txt { color: var(--text); }
.clock.is-idle .clock__txt { color: var(--muted); }
.clock__txt::before { content: '⏱'; margin-right: 6px; font-size: 13px; }

.setlabel { margin: 14px 0 6px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; }
.seg {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; padding: 3px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--radius);
}
.seg--5 { grid-template-columns: repeat(5, 1fr); }
.seg button {
  padding: 10px 4px; border: 0; border-radius: 3px; background: transparent; cursor: pointer;
  color: var(--muted); font: 600 13px var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seg button.is-on { background: var(--cyan); color: var(--cyan-deep); }
@media (max-width: 460px) { .seg--5 { grid-template-columns: repeat(3, 1fr); } }
#settings .sheet__close { margin-left: auto; }
