* { box-sizing: border-box; }
:root{
  --primary: #7b5cff;
  --accent: #00e5ff;
  --bg1: #0f1226;
  --bg2: #090b17;
  --text: #e7e8ee;
  --muted: #9aa0b8;
  /* layout tunables */
  --side-width: 300px;   /* equal width for left/right carousels to ensure perfect centering */
  --center-width: 260px; /* stable width for main arrow area */
  /* direction colors (arrows) */
  --up: #4CAF50;      /* green */
  --right: #2196F3;   /* blue */
  --down: #FF9800;    /* amber */
  --left: #E91E63;    /* pink */
  /* color shift palette */
  --red: #F44336;
  --green: #4CAF50;
  --blue: #2196F3;
  --yellow: #FDD835;
  --purple: #9C27B0;
  /* header + components */
  --header-h: 56px;
  --target-size: clamp(64px, 9vmin, 140px);
  /* symmetric vertical gap between header/content and content/footer */
  --page-gap-y: clamp(18px, 3.5vh, 28px);
  --page-gap-game: clamp(12px, 2.5vh, 22px);
}
html, body { height: 100%; }
body{
  margin: 0;
  font-family: 'Outfit', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  /* Solid base to avoid any responsive banding. Decorative layers are on .bg */
  background: var(--bg2);
  overflow-x: hidden;
  overflow-y: auto; /* keep vertical flow stable */
  scrollbar-gutter: stable; /* keep right gutter only to avoid left/right asymmetry */
  min-height: 100vh;
  /* Body no centra; el centrado se hace dentro de main para evitar conflictos con el header fijo */
  display: block;
  padding: 0; /* sin offsets globales */
}
.bg{ position: fixed; inset: 0; z-index: 0; pointer-events: none; }
/* Oversized, low‑alpha radials that always extend far beyond the viewport
   to avoid any visible seams or bands at responsive breakpoints (dark mode). */
.bg::before{
  content: "";
  position: absolute;
  inset: -200vmax; /* push way out so gradients never end inside the viewport */
  background:
    radial-gradient(160vmax 120vmax at 15% 12%, rgba(123,92,255,.10), transparent 68%),
    radial-gradient(160vmax 125vmax at 85% 82%, rgba(0,229,255,.09), transparent 65%);
  filter: blur(200px);
}
.bg::after{
  content: "";
  position: absolute;
  inset: -200vmax;
  /* soft vignette to add depth, no hard bands */
  background:
    radial-gradient(180vmax 140vmax at 50% 50%, rgba(4,6,18,.20), transparent 72%);
  filter: blur(180px);
}
.app{ position: relative; z-index: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding: 16px 24px; border-bottom: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(6px);
}
@media (max-width: 640px){
  .topbar{ padding: 12px 16px; }
}
.brand{ font-weight:800; letter-spacing:.5px; font-size: 20px; }
.hud{ display:flex; flex-wrap: wrap; gap:16px; }
.hud-item{ display:flex; flex-direction:column; align-items:flex-start; gap:2px; }
.hud-item span{ font-size:12px; color: var(--muted); }
.hud-item strong{ font-size:18px; }

.content{
  display:grid; grid-template-columns: 1fr 260px; gap: 24px; padding: 24px; max-width: 1100px; margin: 0 auto;
}
@media (max-width: 920px){ .content{ grid-template-columns: 1fr; } }

/* Home page layout: start near top, not vertically centered */
.content.home{
  display: block;
  max-width: 1280px;
  padding: var(--page-gap-y) 16px;
  margin: 0 auto;
}

/* Force the main content to be absolutely centered in the viewport, like the modal */

.game{
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px; padding: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  position: relative;
  /* allow inner elements (icons/shadows) to breathe without cropping */
  overflow: visible;
}
/* Absolutely center the game card itself to guarantee symmetric left/right borders on all screens */
.arrow{
  font-size: 160px; text-align:center; margin: 22px 0 8px; user-select:none;
  text-shadow: 0 8px 40px rgba(0,229,255,.35), 0 2px 10px rgba(123,92,255,.35);
}
.hint{ text-align:center; color: var(--muted); margin-top: 0; }
.controls{ display:flex; flex-wrap:wrap; align-items:center; gap: 14px; justify-content:center; margin-top: 22px; }
.controls.tight .btn{ width: 200px; min-height: 50px; padding: 12px 20px; font-size: 18px; line-height: 1; }
.btn{
  background: transparent; color: var(--text); border: 1px solid rgba(255,255,255,.2);
  padding: 10px 16px; border-radius: 10px; cursor:pointer; transition: .2s transform, .2s background, .2s border, .2s box-shadow;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover{ transform: translateY(-1px); border-color: rgba(255,255,255,.4); box-shadow: 0 6px 18px rgba(123,92,255,.25); }
.btn:active{ transform: translateY(0); }
.btn:disabled{ opacity:.5; cursor: not-allowed; }
.btn.primary{
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border: none; font-weight: 700; color: #0b1021;
}

/* Preview panel */
.preview{
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px; padding: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.preview h2{ margin: 0 0 8px; font-size: 16px; color: var(--muted); }
.preview-list{ display:flex; flex-direction:column; gap: 8px; min-height: 220px; }
.preview-arrow{
  font-size: 28px; opacity: .45; filter: blur(.6px) drop-shadow(0 4px 10px rgba(0,0,0,.25));
  transform: translateZ(0);
  display: inline-flex; width: 48px; height: 48px; align-items: center; justify-content: center;
}
.preview-arrow:nth-child(1){ opacity:.75; filter: blur(.2px); }
.preview-arrow:nth-child(2){ opacity:.55; }
.preview-arrow:nth-child(3){ opacity:.50; }
.preview-arrow:nth-child(4){ opacity:.45; }
.preview-arrow:nth-child(5){ opacity:.40; }

@media (max-width: 920px){
  .preview{ order: 2; }
  .preview-list{ flex-direction: row; justify-content:center; min-height: auto; }
  .preview-arrow{ font-size: 36px; }
}

/* Centered layout for game focus */
.content.centered{ grid-template-columns: 1fr; max-width: 820px; }

/* HUD near the game card */
.hud-inline{ display:flex; justify-content:center; align-items:center; gap:20px; margin-bottom: 18px; }
.hud-inline .hud-item{ display:flex; flex-direction:column; align-items:center; gap:4px; }
.hud-inline .hud-item span{ font-size: 14px; color: var(--muted); }
/* Prevent HUD numbers from shifting when values change and make them larger */
.hud-inline .hud-item strong{
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  display: inline-block;
  min-width: 4ch; /* reserve width for at least 4 digits */
  text-align: center;
  font-size: 26px;
  font-weight: 800;
}
/* Reserve a bit more width for time values across games */
#time, #aimTime, #csRoundTime{ min-width: 7ch; }
#score, #best, #aimScore, #aimBest, #csScore, #csLives{ min-width: 4ch; }

/* Stage: main arrow + carousels side-by-side */
.stage{ display:flex; align-items:center; justify-content:center; gap: 24px; min-height: 240px; }
.arrow-wrap{ position: relative; display:flex; flex-direction:column; align-items:center; justify-content:center; width: var(--center-width); min-width: var(--center-width); height: 200px; }
/* Ensure the main arrow has a stable box so the layout never jumps */
.arrow{ line-height: 1; height: 180px; display:flex; align-items:center; justify-content:center; }
.side{ display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; height: 200px; width: var(--side-width); }
.carousel-title{ font-size: 13px; color: var(--muted); }

/* Horizontal carousels */
/* Reserve fixed width for 5 items to avoid layout shift as history fills */
.preview-list.horizontal{ display:flex; flex-direction: row; gap: 12px; width: var(--side-width); overflow:hidden; padding: 6px 2px; align-items: center; }
.preview-list.horizontal.reverse{ flex-direction: row-reverse; }
.preview-list.horizontal .preview-arrow{ font-size: 42px; opacity:.55; filter: blur(.6px) drop-shadow(0 4px 10px rgba(0,0,0,.25)); will-change: transform; }
.preview-list.horizontal .preview-arrow:nth-child(1){ opacity:.95; filter: blur(.2px); transform: scale(1.06); }
.preview-list.horizontal .preview-arrow:nth-child(2){ opacity:.78; }
.preview-list.horizontal .preview-arrow:nth-child(3){ opacity:.65; }
.preview-list.horizontal .preview-arrow:nth-child(4){ opacity:.52; }
.preview-list.horizontal .preview-arrow:nth-child(5){ opacity:.45; }
/* Invisible placeholder items to pre-reserve space */
.preview-arrow.placeholder{ visibility: hidden; opacity: 0; }

/* Advance feedback without moving layout */
.preview-list.bump-left{ animation: flashList .14s ease-out; }
.preview-list.bump-right{ animation: flashList .14s ease-out; }
@keyframes flashList { from{ filter: brightness(1.15); } to{ filter: brightness(1); } }

@media (max-width: 700px){
  .stage{ flex-direction: column; gap: 12px; }
  .side{ order: 2; }
  .preview-list.horizontal{ max-width: 100%; }
}

/* Start overlay and started glow (modern, subtle) */
.start-overlay{ position:absolute; inset:0; display:grid; place-items:center; font-size:48px; font-weight:800; color:#e7e8ee;
  background: transparent; border-radius: 12px; text-shadow:none; box-shadow: none; pointer-events: none; user-select: none; letter-spacing:.5px; opacity: 0; transition: opacity 220ms ease-out; }
.start-overlay:not(.hidden){ opacity: 1; }
.start-overlay.hidden{ display:none; }
.game.started{ box-shadow: 0 0 0 2px rgba(255,255,255,.12) inset, 0 10px 30px rgba(0,0,0,.25); animation: glow 500ms ease-out; }
@keyframes glow{ 0%{ filter: brightness(1); } 50%{ filter: brightness(1.15); } 100%{ filter: brightness(1); } }

/* Ring glow around the game card on key press (uses --arrow-color) */
.game.ring-glow{
  animation: ringPulse 180ms ease-out;
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--arrow-color, #fff) 45%, transparent) inset,
    0 0 24px color-mix(in srgb, var(--arrow-color, #fff) 35%, transparent),
    0 10px 30px rgba(0,0,0,.25);
}
@keyframes ringPulse{
  0%{ filter: saturate(1) brightness(1); }
  50%{ filter: saturate(1.15) brightness(1.08); }
  100%{ filter: saturate(1) brightness(1); }
}

/* Make carousel more evident */
.preview-list.horizontal .preview-arrow{ opacity:.75; }
.preview-list.horizontal .preview-arrow:nth-child(1){ opacity:1; transform: scale(1.06); }

.modal{ position: fixed; inset: 0; display: grid; place-items: center; background: rgba(6,8,18,.72); z-index: 2000; }
.modal.hidden{ display:none; }
.modal-card{
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
  border: 1px solid rgba(255,255,255,.18);
  padding: 24px; border-radius: 16px; width: 92%; max-width: 460px; text-align:center;
  box-shadow: 0 14px 60px rgba(0,0,0,.5);
}
.modal-card h3{ margin: 4px 0 8px; font-size: 22px; }
.modal-actions{ display:flex; justify-content:center; margin-top: 14px; }
.small{ font-size: 12px; color: var(--muted); }

/* Lock background and blur app slightly when modal is open */
body.modal-open{ overflow: hidden; }
body.modal-open .app{ filter: none; }

/* Direction colors and arrow styling */

/* Main arrow uses --arrow-color for its color and glow */
.arrow{ color: var(--arrow-color, #e7e8ee); position: relative; }
.arrow.hit{
  /* brief colored glow on correct press */
  animation: arrowHit 220ms ease-out;
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--arrow-color, #fff) 60%, transparent));
}
@keyframes arrowHit{
  0%{ text-shadow: 0 0 0 var(--arrow-color, transparent), 0 0 0 rgba(0,0,0,0); }
  50%{ text-shadow: 0 0 14px color-mix(in srgb, var(--arrow-color, #fff) 70%, transparent); }
  100%{ text-shadow: 0 0 6px color-mix(in srgb, var(--arrow-color, #fff) 40%, transparent); }
}

/* Direction classes inject the color token */
.arrow-dir-up{ --arrow-color: var(--up); }
.arrow-dir-right{ --arrow-color: var(--right); }
.arrow-dir-down{ --arrow-color: var(--down); }
.arrow-dir-left{ --arrow-color: var(--left); }

/* Tint preview/history arrows by direction */
.preview-arrow.arrow-dir-up{ color: color-mix(in srgb, var(--up) 85%, #ffffff 15%); }
.preview-arrow.arrow-dir-right{ color: color-mix(in srgb, var(--right) 85%, #ffffff 15%); }
.preview-arrow.arrow-dir-down{ color: color-mix(in srgb, var(--down) 90%, #ffffff 10%); }
.preview-arrow.arrow-dir-left{ color: color-mix(in srgb, var(--left) 85%, #ffffff 15%); }

.grid-menu{ display:grid; grid-template-columns: repeat(3, minmax(340px, 1fr)); gap:28px; }
@media (max-width: 900px){ .grid-menu{ grid-template-columns: repeat(2, minmax(240px, 1fr)); } }
@media (max-width: 600px){ .grid-menu{ grid-template-columns: 1fr; } }
.menu-card{ display:flex; flex-direction:column; align-items:center; justify-content:flex-start; text-align:center; padding:18px; border-radius:14px; background: rgba(255,255,255,.05); border:1px solid rgba(255,255,255,.1); text-decoration:none; color:inherit; transition: .2s transform, .2s box-shadow, .2s border; }
.menu-card:hover{ transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.25); border-color: rgba(255,255,255,.2); }
.menu-icon{ font-size:48px; line-height:1; }
.menu-title{ font-weight:800; margin-top:8px; font-size: 22px; }
.menu-desc{ color: var(--muted); font-size: 15px; margin-top: 8px; }
/* Coming soon placeholder cards */
.menu-card.soon{ opacity: .66; cursor: default; pointer-events: none; }
.menu-card.soon:hover{ transform: none; box-shadow: none; border-color: rgba(255,255,255,.1); }
body[data-theme="light"] .menu-card.soon:hover{ border-color: rgba(0,0,0,.08); }

/* Aim Trainer */
.stage-aim{ position: relative; width: min(96vw, 1100px); height: min(62vh, 720px); margin: 10px auto; border-radius: 14px; background: rgba(255,255,255,.04); border:1px solid rgba(255,255,255,.08); overflow: hidden; }
/* Simplified, modern target (responsive) */
.target{ position: absolute; width: var(--target-size); height: var(--target-size); border-radius: 50%; cursor: pointer; display:grid; place-items:center; 
  background: #ffffff; /* inner dot background for contrast */
  border: 6px solid rgba(123,92,255,.9); /* outer ring */
  box-shadow: 0 8px 24px rgba(0,0,0,.35), 0 0 0 2px rgba(255,255,255,.2) inset;
  transition: transform .12s ease-out, filter .12s ease-out;
}
.target::before{ content:""; width: calc(var(--target-size) * 0.32); height: calc(var(--target-size) * 0.32); border-radius:50%; background: rgba(123,92,255,1); }
.target:hover{ transform: scale(1.05); filter: brightness(1.06); }

/* Color Shift */
.stimulus{ font-size: 64px; font-weight: 800; text-align: center; letter-spacing:.8px; margin: 8px 0 10px; min-height: calc(clamp(80px, 6.5vw, 140px) * 1.1); }
.color-options{ display:flex; flex-wrap: wrap; gap:10px; justify-content:center; }
.color-btn{ padding: 10px 14px; border-radius: 12px; border:1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.06); color: var(--text); cursor: pointer; transition: .2s transform, .2s filter; font-weight:700; }
.color-btn:hover{ transform: translateY(-1px); filter: brightness(1.1); }
.color-red{ --opt: var(--red); }
.color-green{ --opt: var(--green); }
.color-blue{ --opt: var(--blue); }
.color-yellow{ --opt: var(--yellow); }
.color-purple{ --opt: var(--purple); }
.color-btn{ box-shadow: 0 0 0 2px color-mix(in srgb, var(--opt) 40%, transparent) inset; }

/* Light mode overrides */
body[data-theme="light"]{
  --bg1: #f4f7fb; --bg2: #eaeef6; --text: #121421; --muted: #5b6073;
}
body[data-theme="light"] body, body[data-theme="light"]{
  background: radial-gradient(1200px 800px at 20% 20%, #ffffff 0%, transparent 60%),
              radial-gradient(1000px 600px at 80% 30%, #e2f1ff 0%, transparent 55%),
              linear-gradient(180deg, var(--bg1), var(--bg2));
}
body[data-theme="light"] .game,
body[data-theme="light"] .preview,
body[data-theme="light"] .modal-card,
body[data-theme="light"] .menu-card,
body[data-theme="light"] .stage-aim{
  background: rgba(255,255,255,.75);
  border-color: rgba(0,0,0,.06);
  color: var(--text);
}
body[data-theme="light"] .topbar{ background: rgba(255,255,255,.55); border-bottom-color: rgba(0,0,0,.06); }
body[data-theme="light"] .btn{ border-color: rgba(0,0,0,.18); color: var(--text); }
body[data-theme="light"] .btn.primary{ color: #0b1021; }

/* Light theme: remove dark decorative background layers to avoid odd bands */
body[data-theme="light"] .bg::before,
body[data-theme="light"] .bg::after{ display: none; content: none; }


/* === Layout polish (non-fixed header, centered content) === */
.topbar{ position: static; z-index: 10; background: rgba(10,12,24,.15); }
.app{ position: relative; z-index:1; }
/* Game pages layout: top-aligned content with modest, symmetric gaps */
/* Tighter page padding for game screens so header/footer aren't too far */
.content.centered.viewport-center{
  position: static !important;
  top:auto !important; left:auto !important; transform:none !important;
  width: 100%; max-width: 100%;
  /* Remove forced full-viewport height and vertical centering to avoid huge gaps on small cards */
  min-height: auto;
  display: block;
  padding: var(--page-gap-game) 16px;
  margin: 0 auto;
}
.game.center-fixed{ position: static !important; top:auto !important; left:auto !important; transform:none !important; width: 100%; max-width: min(96vw, 1280px); margin: 0 auto; z-index: 1; }
/* Ensure modals sit on top of header */
.modal{ z-index: 2000; }
/* Menu card links: ensure proper color and spacing */
/* keep original generous gap for visual balance */
.grid-menu{ gap: 28px; }
.menu-card{ color: inherit; text-decoration: none; }
.menu-card .menu-title{ color: inherit; }
.menu-card .menu-desc{ color: var(--muted); }
/* ColorShift: more breathing room */
.stimulus{ margin: 16px 0 22px; 
  /* Use a shared size token so min-height matches the eventual text size */
  font-size: var(--cs-stimulus-size, clamp(80px, 6.5vw, 140px));
  min-height: calc(var(--cs-stimulus-size, clamp(80px, 6.5vw, 140px)) * 1.2);
  display: flex; align-items: center; justify-content: center; line-height: 1.1;
}
/* Lives feedback animation */
.hud-inline .hud-item strong.hit{ color:#ff6b6b; animation: lifeHit 420ms ease-out; }
@keyframes lifeHit{ 0%{ transform: scale(1); } 30%{ transform: scale(1.2); color:#ff6b6b; } 100%{ transform: scale(1); } }
.color-options{ gap: 16px; }
.color-btn{ padding: 16px 22px; font-size: 18px; }
/* Aim stage small polish */
.stage-aim{ margin-top: 14px; }


/* Light theme visibility improvements for grid and start overlay */
body[data-theme="light"] .menu-card{
  background: linear-gradient(180deg, #ffffff 0%, #f3f6fb 100%);
  border-color: rgba(0,0,0,.08);
  box-shadow: 0 8px 22px rgba(19, 24, 40, .06);
}
body[data-theme="light"] .menu-card:hover{
  box-shadow: 0 12px 26px rgba(19, 24, 40, .10);
  border-color: rgba(0,0,0,.12);
}
/* Ensure countdown text is readable depending on theme */
body[data-theme="light"] .start-overlay{ color:#121421; }

/* Smooth page transitions (reduce perceived blink) */
@keyframes appFadeIn { from { opacity: 0 } to { opacity: 1 } }
body.ready .app { animation: appFadeIn 180ms ease-out both; }
body.leaving .app { opacity: 0; transition: opacity 120ms ease-in; }
@media (prefers-reduced-motion: reduce){
  body.ready .app { animation: none; opacity: 1; }
  body.leaving .app { transition: none; opacity: 1; }
}

/* Footer (menu) */
.site-footer{ max-width: 1100px; margin: 28px auto 22px; padding: 14px 18px; text-align:center; color: var(--muted); }
.site-footer .footer-inner{ display:flex; gap:14px; justify-content:center; align-items:center; flex-wrap:wrap; font-size: 13px; }
.site-footer .sep{ opacity:.6; }
.site-footer a{ color: inherit; text-decoration: none; border-bottom: 1px dashed rgba(255,255,255,.3); }
body[data-theme="light"] .site-footer a{ border-bottom-color: rgba(0,0,0,.25); }


/* === Footer follows scroll; sticky at bottom when content is short === */
.bottombar{
  position: static;
  display:flex; align-items:center; justify-content:center;
  padding: 14px 20px;
  background: rgba(255,255,255,.04);
  border-top: 1px solid rgba(255,255,255,.08);
  color: var(--muted);
  gap: 24px;
  margin-top: auto; /* push to bottom in flex container */
}
.bottombar a{ color: inherit; text-decoration: none; border-bottom: 1px dashed rgba(255,255,255,.25); }
body[data-theme="light"] .bottombar{ background: rgba(255,255,255,.65); border-top-color: rgba(0,0,0,.06); }
body[data-theme="light"] .bottombar a{ border-bottom-color: rgba(0,0,0,.25); }

/* === Hero (landing) — spacing tweaked === */
.hero{ text-align:center; margin: 8px 0 12px; }
.hero-logo{ font-size: clamp(60px, 10vw, 120px); line-height: 1; filter: drop-shadow(0 12px 40px rgba(0,229,255,.25)); }
.hero-title{ margin: 10px 0 6px; font-size: clamp(30px, 7vw, 72px); letter-spacing: .5px; }
.hero-tagline{ margin: 6px 0 18px; font-size: clamp(15px, 3.2vw, 20px); }
.hero-cta{ margin-top: 10px; padding: 12px 20px; font-size: 16px; }

/* Extra spacing before footer on landing grid (closer so footer isn't too far) */
/* Rely on page bottom padding for symmetrical footer distance */
.grid-menu{ margin-bottom: 0; }
/* Increase gap between hero and grid */
.hero + .grid-menu{ margin-top: clamp(28px, 5vw, 44px); }

/* Revert grid to previous full-width behavior inside the card (no extra padding) */
.game .grid-menu{ width: 100%; padding-inline: 0; }

/* Reaction Time */
.reaction-stage {
    width: 100%;
    min-height: 320px;
    margin: 20px 0;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s, transform 0.1s;
}

.reaction-idle {
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 255, 255, 0.1);
}

.reaction-waiting {
    background: #2b2d35; /* Grayish */
    border: 2px solid rgba(255, 255, 255, 0.05);
}

.reaction-ready {
    background: #4CAF50; /* Green */
    box-shadow: 0 0 40px rgba(76, 175, 80, 0.4);
}

.reaction-ready .reaction-message, 
.reaction-ready .reaction-icon,
.reaction-ready .hint {
    color: #0b1021;
}

.reaction-result {
    background: rgba(123, 92, 255, 0.15);
    border: 2px solid var(--primary);
}

.reaction-error {
    background: rgba(244, 67, 54, 0.15);
    border: 2px solid var(--red);
}

.reaction-icon {
    font-size: 64px;
    margin-bottom: 12px;
}

.reaction-message {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 8px;
}

body[data-theme="light"] .reaction-idle {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] .reaction-waiting {
    background: #d1d5db;
}

body[data-theme="light"] .reaction-ready {
    background: #4CAF50;
}

body[data-theme="light"] .reaction-ready .reaction-message,
body[data-theme="light"] .reaction-ready .reaction-icon,
body[data-theme="light"] .reaction-ready .hint {
    color: #ffffff;
}

/* Time Perception */
.tp-stage {
    width: 100%;
    min-height: 320px;
    margin: 20px 0;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s, border 0.2s;
}

.tp-idle {
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 255, 255, 0.1);
}

.tp-running {
    background: rgba(123, 92, 255, 0.05);
    border: 2px solid var(--primary);
}

.tp-result {
    background: rgba(0, 229, 255, 0.1);
    border: 2px solid var(--accent);
}

.tp-timer {
    font-size: 84px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    margin-bottom: 12px;
    transition: opacity 1s ease-in-out;
}

.tp-faded {
    opacity: 0;
}

.tp-message {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 8px;
}

.tp-history {
    margin: 48px auto 0;
    width: 100%;
    max-width: 360px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.tp-history:hover {
    opacity: 1;
}

.tp-history h4 {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-align: center;
}

.tp-history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tp-history-item {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    font-size: 13px;
    color: var(--muted);
}

.tp-history-item span:nth-child(1) {
    font-family: monospace;
    opacity: 0.8;
    text-align: left;
}

.tp-history-item span:nth-child(2) {
    text-align: center;
}

.tp-history-item span:nth-child(3) {
    text-align: right;
}

.tp-diff {
    font-weight: 400;
}

.tp-diff.early {
    color: rgba(255, 107, 107, 0.8);
}

.tp-diff.late {
    color: rgba(0, 229, 255, 0.8);
}

.tp-label {
    font-weight: 500;
    text-transform: lowercase;
    font-variant: small-caps;
}

.tp-label.perfect { color: rgba(0, 229, 255, 0.7); }
.tp-label.very-close { color: rgba(123, 92, 255, 0.7); }
.tp-label.close { color: var(--muted); }
.tp-label.miss { color: rgba(255, 107, 107, 0.7); }

body[data-theme="light"] .tp-idle {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] .tp-history-item {
    background: rgba(0, 0, 0, 0.015);
    border-color: rgba(0, 0, 0, 0.03);
}

/* Pattern Grid */
.pg-stage {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 20px auto;
    aspect-ratio: 1 / 1;
}

.pg-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    height: 100%;
}

.pg-square {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.pg-square:active {
    transform: scale(0.96);
}

.pg-square.active {
    background: var(--primary);
    box-shadow: 0 0 20px var(--primary);
    border-color: var(--primary);
    transform: scale(1.02);
}

.pg-square.correct {
    background: var(--accent);
    box-shadow: 0 0 15px var(--accent);
    border-color: var(--accent);
}

.pg-square.wrong {
    background: var(--red);
    box-shadow: 0 0 15px var(--red);
    border-color: var(--red);
}

.pg-overlay {
    position: absolute;
    inset: 0;
    background: rgba(9, 11, 23, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    z-index: 10;
    padding: 20px;
    text-align: center;
}

.pg-overlay.hidden {
    display: none;
}

.pg-message {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 8px;
}

body[data-theme="light"] .pg-square {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
}

body[data-theme="light"] .pg-overlay {
    background: rgba(255, 255, 255, 0.9);
}

/* Cross-document View Transitions (smooth navigation without white flash) */
@supports (view-transition-name: root) {
  html { view-transition-name: root; }
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 140ms;
    animation-timing-function: ease-out;
  }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: 0.001ms; }
}
