/* ============================================================
   Simón — tablero y portada (templates/play_simon.html, simon_hub.html).

   El tablero es un disco oscuro con cuatro cuadrantes (rojo, azul, verde,
   amarillo, como en el banner) y un centro con el nivel. Cada color tiene
   su tono en reposo y encendido; el encendido se funde en ~110 ms y se
   apaga más lento (no destella). Todo lo demás usa los tokens de app.css.
   ============================================================ */
.sm-shell {
  --sm-r: #A8322B; --sm-r-on: #FF5B4D;
  --sm-b: #22539F; --sm-b-on: #4C9DFF;
  --sm-g: #21804A; --sm-g-on: #3BE07C;
  --sm-y: #B99117; --sm-y-on: #FFD94A;
  --sm-body: #17181B; --sm-body-2: #26282D; --sm-rim: #33363C;
}

/* ---------- mesa ---------- */
.sm-stage {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  min-height: clamp(440px, calc(100dvh - 212px), 860px); padding: 20px 16px 18px;
  border-radius: var(--r-lg); border: 1px solid var(--line);
  background: radial-gradient(110% 80% at 50% 44%, color-mix(in srgb, var(--surface) 64%, var(--surface-2)) 0%, var(--surface-2) 64%, color-mix(in srgb, var(--surface-3) 55%, var(--surface-2)) 100%);
  --tt-table: var(--surface-2);
}

/* ---------- quién juega ---------- */
.sm-turn {
  display: inline-flex; align-items: center; gap: 10px; margin: 0; min-height: 40px; padding: 0 18px;
  border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface);
  font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); box-shadow: var(--shadow-sm);
  transition: background .3s ease, color .3s ease, border-color .3s ease;
}
.sm-turn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; transition: background .3s ease; }
.sm-turn[data-who="simon"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.sm-turn[data-who="simon"] .sm-turn-dot { background: var(--on-ink); animation: sm-breath 1.1s ease-in-out infinite; }
.sm-turn[data-who="player"] { background: var(--success-weak); border-color: color-mix(in srgb, var(--success) 45%, transparent); color: var(--ink); }
.sm-turn[data-who="player"] .sm-turn-dot { background: var(--success); }
.sm-turn[data-who="ok"] { background: var(--success-weak); border-color: var(--success); color: var(--ink); }
.sm-turn[data-who="ok"] .sm-turn-dot { background: var(--success); }
.sm-turn[data-who="over"] { background: var(--accent-weak); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent-ink); }
.sm-turn[data-who="over"] .sm-turn-dot { background: var(--accent); }
@keyframes sm-breath { 50% { opacity: .35; transform: scale(.8); } }

/* ---------- tablero ---------- */
.sm-board {
  --size: min(100%, 460px, calc(100dvh - 330px));
  position: relative; width: var(--size); min-width: 240px; aspect-ratio: 1;
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 3.2%;
  padding: 4.2%; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, var(--sm-body-2), var(--sm-body) 70%);
  box-shadow: 0 0 0 1px var(--sm-rim), 0 18px 40px -18px rgba(0, 0, 0, .55), 0 3px 8px rgba(0, 0, 0, .18), inset 0 2px 0 rgba(255, 255, 255, .06);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.sm-pad {
  --c: var(--sm-r); --on: var(--sm-r-on);
  position: relative; margin: 0; padding: 0; border: 0; cursor: pointer; font: inherit;
  background: radial-gradient(circle at var(--gx) var(--gy), color-mix(in srgb, var(--c) 82%, #fff) 0%, var(--c) 55%, color-mix(in srgb, var(--c) 70%, #000) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06), inset 0 -6px 14px rgba(0, 0, 0, .28);
  filter: saturate(.82) brightness(.82);
  transition: filter .32s ease, box-shadow .32s ease, background .32s ease, transform .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.sm-pad.c0 { --c: var(--sm-r); --on: var(--sm-r-on); border-radius: 100% 6% 6% 6%; --gx: 75%; --gy: 75%; }
.sm-pad.c1 { --c: var(--sm-b); --on: var(--sm-b-on); border-radius: 6% 100% 6% 6%; --gx: 25%; --gy: 75%; }
.sm-pad.c2 { --c: var(--sm-g); --on: var(--sm-g-on); border-radius: 6% 6% 6% 100%; --gx: 75%; --gy: 25%; }
.sm-pad.c3 { --c: var(--sm-y); --on: var(--sm-y-on); border-radius: 6% 6% 100% 6%; --gx: 25%; --gy: 25%; }
.sm-pad:disabled { cursor: default; }
/* encendido: entra rápido y suave, sale más lento */
.sm-pad.is-lit {
  --c: var(--on);
  filter: saturate(1.08) brightness(1.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35), inset 0 0 26px rgba(255, 255, 255, .35), 0 0 34px 2px color-mix(in srgb, var(--on) 70%, transparent);
  transition-duration: .11s, .11s, .11s, .2s;
}
.sm-pad.is-wrong { animation: sm-wrong .5s ease; filter: saturate(.4) brightness(.6); }
.sm-pad.is-hint { animation: sm-hint 1.1s ease-in-out; }
@keyframes sm-wrong { 20% { transform: translateX(-3px); } 45% { transform: translateX(3px); } 70% { transform: translateX(-2px); } }
@keyframes sm-hint {
  0%, 100% { filter: saturate(.82) brightness(.82); }
  25%, 75% { filter: saturate(1.05) brightness(1.1); box-shadow: 0 0 26px color-mix(in srgb, var(--on) 60%, transparent); }
  50% { filter: saturate(.82) brightness(.82); }
}
@media (hover: hover) {
  [data-phase="player"] .sm-pad:hover:not(.is-lit) { filter: saturate(.92) brightness(.92); }
}
.sm-pad:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; z-index: 2; }
[data-phase="simon"] .sm-pad:not(.is-lit), [data-phase="idle"] .sm-pad, [data-phase="wait"] .sm-pad:not(.is-lit) { filter: saturate(.7) brightness(.7); }

/* centro: nivel */
.sm-hub {
  position: absolute; left: 50%; top: 50%; width: 34%; aspect-ratio: 1; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 50% 35%, #2C2F35, #141518 75%);
  box-shadow: 0 0 0 6px var(--sm-body), 0 0 0 7px var(--sm-rim), inset 0 2px 0 rgba(255, 255, 255, .07);
  color: #EDEAE4;
}
.sm-hub-k { font-size: clamp(.6rem, .5rem + .5vw, .78rem); letter-spacing: .16em; text-transform: uppercase; color: #B9B3AA; }
.sm-hub-n { font-family: var(--font-num); font-size: clamp(1.6rem, 1.1rem + 2.4vw, 2.6rem); font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
[data-phase="idle"] .sm-hub-n { color: #8A857D; }

.sm-keys { margin: 0; font-size: var(--t-xs); }
@media (hover: none) { .sm-keys { display: none; } }

/* ---------- selector de modo (mesa y portada) ---------- */
.sm-modes { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 14px 0 4px; text-align: left; }
.sm-mode-opt {
  position: relative; display: flex; flex-direction: column; gap: 3px; padding: 14px 16px;
  border: 1px solid var(--line-2); border-radius: var(--r-md); background: var(--surface); cursor: pointer;
  transition: border-color var(--dur), box-shadow var(--dur), background var(--dur);
}
.sm-mode-opt strong { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--t-sm); font-weight: 600; color: var(--ink); }
.sm-mode-opt > span { font-size: var(--t-xs); line-height: 1.4; color: var(--muted); }
.sm-mode-opt:hover { border-color: color-mix(in srgb, var(--line-2) 40%, var(--ink-2)); }
.sm-mode-opt input { position: absolute; opacity: 0; pointer-events: none; }
.sm-mode-opt:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.sm-mode-opt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.sm-best { font-size: .7rem; font-weight: 500; color: var(--ink-2); background: var(--surface-2); border-radius: var(--r-pill); padding: 2px 8px; font-variant-numeric: tabular-nums; }
.sm-best[hidden] { display: none; }
.sm-panel .tt-result-card { width: min(100%, 420px); }

/* ---------- resultado ---------- */
.sm-r-score { display: flex; flex-direction: column; align-items: center; margin: 4px 0 10px; }
.sm-r-score b { font-family: var(--font-num); font-size: 3rem; font-weight: 500; line-height: 1; color: var(--ink); }
.sm-r-score span { font-size: var(--t-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* sonido: botón conmutador sin el relleno de «activo»; apagado = ícono tachado */
.sm-sound[aria-pressed] { background: transparent; color: var(--ink-2); }
.sm-sound[aria-pressed]:hover { background: var(--surface-2); color: var(--ink); }
.sm-sound.is-muted { color: var(--muted); }
.sm-sound.is-muted .ico { opacity: .6; }
.sm-sound.is-muted::before {
  content: ""; position: absolute; left: 10.5px; top: calc(50% - 1px); width: 20px; height: 2px; border-radius: 2px;
  background: currentColor; transform: rotate(-45deg); pointer-events: none;
}
.sm-sound { position: relative; }

/* ---------- portada: banner del juego ---------- */
.sm-banner {
  display: block; margin: 0 0 22px; overflow: hidden; border-radius: var(--r-lg);
  aspect-ratio: 1920 / 583; background: #0d0e12; box-shadow: var(--shadow-md);
  transition: transform var(--dur) ease, box-shadow var(--dur) ease;
}
.sm-banner img { display: block; width: 100%; height: 100%; object-fit: cover; }
.sm-banner:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.sm-banner:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .sm-banner, .sm-banner:hover { transition: none; transform: none; } }

/* ---------- portada: tablero en miniatura ---------- */
.sm-hub-art { display: grid; place-items: center; padding: 6px 0 2px; }
.sm-mini {
  position: relative; width: 132px; aspect-ratio: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 6px;
  border-radius: 50%; background: radial-gradient(circle at 50% 38%, #26282D, #17181B 70%); box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .5), 0 0 0 1px #33363C;
}
.sm-mini i { display: block; filter: saturate(.85) brightness(.85); }
.sm-mini .c0 { background: #A8322B; border-radius: 100% 8% 8% 8%; animation: sm-mini 4.8s ease-in-out infinite; }
.sm-mini .c1 { background: #22539F; border-radius: 8% 100% 8% 8%; animation: sm-mini 4.8s ease-in-out 1.2s infinite; }
.sm-mini .c3 { background: #B99117; border-radius: 8% 8% 100% 8%; animation: sm-mini 4.8s ease-in-out 2.4s infinite; }
.sm-mini .c2 { background: #21804A; border-radius: 8% 8% 8% 100%; animation: sm-mini 4.8s ease-in-out 3.6s infinite; }
.sm-mini b { position: absolute; left: 50%; top: 50%; width: 36%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: #17181B; box-shadow: 0 0 0 1px #33363C; }
@keyframes sm-mini { 0%, 18%, 100% { filter: saturate(.85) brightness(.85); } 7% { filter: saturate(1.15) brightness(1.35); } }

@media (max-width: 640px) {
  .sm-stage { gap: 12px; padding: 14px 10px; min-height: clamp(400px, calc(100dvh - 190px), 760px); }
  .sm-board { --size: min(100%, 420px, calc(100dvh - 300px)); }
  .sm-turn { min-height: 36px; padding: 0 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .sm-turn-dot, .sm-mini i, .sm-pad.is-wrong, .sm-pad.is-hint { animation: none !important; }
  .sm-pad.is-hint { filter: saturate(1.05) brightness(1.1); }
}
