/* ── FONTS ── */

/* Inria Serif — 4 variantes estáticas */
@font-face {
  font-family: 'Inria Serif';
  src: url('fonts/Inria_Serif/InriaSerif-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inria Serif';
  src: url('fonts/Inria_Serif/InriaSerif-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Inria Serif';
  src: url('fonts/Inria_Serif/InriaSerif-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inria Serif';
  src: url('fonts/Inria_Serif/InriaSerif-BoldItalic.woff2') format('woff2');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* Red Hat Display — fuente variable (cubre pesos 100–900) */
@font-face {
  font-family: 'Red Hat Display';
  src: url('fonts/Red_Hat_Display/RedHatDisplay-VariableFont_wght.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Red Hat Display';
  src: url('fonts/Red_Hat_Display/RedHatDisplay-Italic-VariableFont_wght.woff2') format('woff2');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
img { display: block; }

/* ── TOKENS ── */
:root {
  --navy:              #101E5A;
  --text-primary:      #ffffff;
  --modal-text:        #101E5A;
  --bar-position-fill: #101E5A;

  --font-serif: 'Inria Serif', Georgia, serif;
  --font-sans:  'Red Hat Display', -apple-system, BlinkMacSystemFont, sans-serif;

  --r-pill:    999px;
  --grid-size: min(88vw, 340px);

  --dur-modal:   300ms;
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── BODY / BACKGROUND ── */
html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--navy);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

/* Gradient overlays + dot pattern */
.bg-top,
.bg-bottom {
  position: fixed;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 0;
}

.bg-pattern {
  position: fixed;
  inset: 0;
  background-image: url('assets/Background dot pattern.svg');
  background-repeat: repeat;
  background-size: 14px 14px;
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

.bg-top {
  top: 0;
  width: 100%;
  height: 375px;
  object-fit: fill;
}

.bg-bottom {
  bottom: 0;
  width: 100%;
  height: 375px;
  object-fit: fill;
}

/* ── APP LAYOUT ── */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
}

/* ── HEADER ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: max(26px, env(safe-area-inset-top, 26px)) 20px 10px;
  flex-shrink: 0;
}

.header-title {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 32px;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--text-primary);
  text-align: center;
}

.title-sub {
  display: block;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 24px;
  color: var(--text-primary);
}

.icon-btn {
  width: 53px;
  height: 53px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  flex-shrink: 0;
  transition: transform 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}

.icon-btn:active {
  transform: scale(0.90);
  opacity: 0.80;
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.30);
  }
}

/* ── ROUND LABEL ── */
.round-label-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-top: 20px;
  flex-shrink: 0;
}

.round-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.round-dash {
  color: var(--text-primary);
  font-size: 0.75rem;
  letter-spacing: -0.08em;
}

.round-number {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-primary);
}

.round-mode {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--text-primary);
  font-weight: 400;
}

/* ── GRID ── */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: var(--grid-size);
  height: var(--grid-size);
  margin: 24px auto 0;
  flex-shrink: 0;
  position: relative;
  background-image: url('assets/grid.svg');
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('assets/glassy_square.svg');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 78% 78%;
  opacity: 0;
  transition: opacity 100ms ease;
}

.cell--active::after {
  opacity: 1;
}

/* ── PLAY BUTTON (centered over grid) ── */
.play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  padding: 0;
  transition: transform 150ms ease, opacity 150ms ease;
  -webkit-tap-highlight-color: transparent;
}

.play-btn:active {
  transform: translate(-50%, -50%) scale(0.90);
  opacity: 0.80;
}

@media (hover: hover) and (pointer: fine) {
  .play-btn:hover {
    transform: translate(-50%, -50%) translateY(-3px);
    opacity: 0.90;
  }
}

/* ── COUNTDOWN ── */
.countdown {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 50px;
  color: var(--text-primary);
  z-index: 2;
  pointer-events: none;
}

.countdown.active {
  display: flex;
}

/* ── RESPONSE AREA ── */
.response-area {
  display: flex;
  align-items: stretch;
  width: var(--grid-size);
  height: 97px;
  flex-shrink: 0;
  margin-top: 24px;
  border-radius: 10px;
  position: relative;
}

/* Gradient border: white at the outer edges fading to 30% opacity at the center seam */
.response-area::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  padding: 1px;
  background: linear-gradient(
    to right,
    rgba(255,255,255,1)    0%,
    rgba(255,255,255,0.3) 48%,
    rgba(255,255,255,0.2) 50%,
    rgba(255,255,255,0.3) 52%,
    rgba(255,255,255,1)  100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 1;
}

.response-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 17px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.08em;
  font-weight: 700;
  background: rgba(255,255,255,0.3);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  touch-action: manipulation;
  transition: background 100ms ease;
  -webkit-tap-highlight-color: transparent;
}

.response-btn:first-child {
  border-radius: 10px 0 0 10px;
}

.response-btn:last-child {
  border-radius: 0 10px 10px 0;
}

.response-btn.full-width {
  flex: 1 1 100%;
  border-radius: 10px;
}

.response-btn.btn--pressed {
  background: rgba(255,255,255,0.45);
}

.response-divider {
  width: 1px;
  background: rgba(255,255,255,0.20);
  flex-shrink: 0;
  align-self: stretch;
}


.btn-icon {
  flex-shrink: 0;
}

.btn-label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── KEYBOARD HINT (desktop only) ── */
.keyboard-hint {
  display: none;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 15px;
  color: var(--text-primary);
  text-align: center;
  margin-top: 16px;
  flex-shrink: 0;
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-style: normal;
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 3px;
  padding: 3px 5px 1px 5px;
  vertical-align: middle;
}

@media (hover: hover) and (pointer: fine) {
  .keyboard-hint { display: block; }
}

/* ── STOP AREA ── */
.stop-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 40px;
  flex-shrink: 0;
}

.stop-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 100ms ease, opacity 100ms ease;
  touch-action: manipulation;
}

.stop-btn:active {
  transform: scale(0.88);
  opacity: 0.70;
}

.stop-label {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 20px;
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── HISTORY LIST ── */
.history-list {
  width: 100%;
  margin-top: 20px;
  padding-bottom: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0px;
  border-top: 1px solid rgba(16, 30, 90, 0.30);
  gap: 8px;
}

.history-item:last-child {
  border-bottom: 1px solid rgba(16, 30, 90, 0.30);
}

.history-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-round {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--modal-text);
}

.history-mode {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 15px;
  font-weight: 400;
  color: var(--modal-text);
}

.history-scores {
  display: flex;
  align-items: center;
  gap: 16px;
}

.history-score {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 20px;
  font-weight: 400;
  color: var(--modal-text);
}

/* ── BACKDROP ── */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 30, 90, 0.60);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-modal) ease;
}

.backdrop:not(.hidden) {
  opacity: 1;
  pointer-events: all;
}

/* Keep backdrop in the DOM when hidden so fade-out plays */
.backdrop.hidden {
  display: block !important;
  opacity: 0;
  pointer-events: none;
}

/* ── MODALS (shared) ── */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-modal) ease;
}

/* Keep modals in the DOM when hidden so fade-out plays */
.modal.hidden {
  display: flex !important;
  opacity: 0;
  pointer-events: none;
}

.modal:not(.hidden) {
  opacity: 1;
  pointer-events: all;
}

.modal-panel {
  width: calc(100% - 40px);
  max-width: 420px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #ffffff;
  border-radius: 10px;
  padding: 28px 20px 32px;
  position: relative;
  color: var(--modal-text);
}

.modal-panel--scroll {
  max-height: 85dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-panel--scroll::-webkit-scrollbar { display: none; }

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
}

.modal-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 24px;
  color: var(--modal-text);
  text-align: center;
  margin-bottom: 24px;
}

/* ── SETTINGS MODAL ── */
.toggle-group {
  display: flex;
  gap: 0;
  margin-bottom: 30px;
  position: relative;
}

/* Dividing line at the center seam */
.toggle-group::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--navy);
  z-index: 1;
  pointer-events: none;
}

.toggle-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 76px;
  padding: 10px 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--navy);
  border: 1px solid var(--navy);
  transition: background 120ms ease, color 120ms ease;
  touch-action: manipulation;
  line-height: 1;
  white-space: nowrap;
}

/* Left button: 10px radius on left corners only */
.toggle-group .toggle-btn:first-child {
  border-radius: 10px 0 0 10px;
  border-right: none;
}

/* Right button: 10px radius on right corners only */
.toggle-group .toggle-btn:last-child {
  border-radius: 0 10px 10px 0;
  border-left: none;
}

.toggle-btn.active {
  background: var(--navy);
  color: #ffffff;
}

/* Icons in inactive toggles: white SVGs → convert to #101E5A */
.toggle-btn:not(.active) .toggle-icon {
  filter: brightness(0);
  opacity: 0.80;
}

/* Icons in active toggles: stay white */
.toggle-btn.active .toggle-icon {
  filter: none;
  opacity: 1;
}

.toggle-icon {
  flex-shrink: 0;
}

.toggle-dual-icons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 75px;
  padding: 0 16px;
  margin-top: 32px;
  border-radius: 10px;
  background: #ffffff;
  color: var(--modal-text);
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.2rem;
  text-align: center;
  transition: transform 100ms ease, opacity 100ms ease;
  touch-action: manipulation;
  box-shadow: 0 1px 1px rgba(16, 30, 90, 0.30);
}

.primary-btn:active {
  transform: scale(0.97);
  opacity: 0.88;
}

/* ── SCORE MODAL ── */
.score-row {
  margin-bottom: 32px;
}

.score-row.hidden { display: none; }

.score-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--modal-text);
  margin-bottom: 16px;
  text-align: center;
}

.progress-track {
  height: 30px;
  border-radius: var(--r-pill);
  background: transparent;
  border: 1px solid var(--navy);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--bar-position-fill);
  width: 0%;
  min-width: 52px;
  transition: width 650ms var(--ease-bounce);
  display: flex;
  align-items: center;
  padding-left: 12px;
}


.progress-pct {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 20px;
  font-weight: 400;
  color: var(--text-primary);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.score-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 32px;
  margin-bottom: 32px;
}

.score-links .link-btn {
  display: inline;
  width: auto;
  margin: 0;
}

.score-link-sep {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--modal-text);
  opacity: 0.5;
  user-select: none;
}

.link-btn {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 32px;
  margin-bottom: 32px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 20px;
  font-weight: 400;
  color: var(--modal-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  touch-action: manipulation;
}

/* ── STATISTICS MODAL ── */
.stats-empty {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.55;
  color: var(--modal-text);
  text-align: center;
  padding: 16px 8px;
}

/* ── INFO MODAL ── */
.info-content {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--modal-text);
}

.info-content p { margin-bottom: 12px; }
.info-content strong { color: var(--modal-text); font-weight: 700; }

.info-ref {
  font-size: 0.78rem !important;
  color: var(--modal-text) !important;
}

.info-ref a {
  color: var(--navy);
  text-decoration: underline;
}

.info-divider {
  border: none;
  border-top: 1px solid rgba(16, 30, 90, 1);
  margin: 16px auto;
  width:50px;
}

.info-subtitle {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.35rem;
  color: var(--modal-text);
  margin-bottom: 10px;
  Text-align:center;
}


.info-list {
  Padding-left: 20px;
}

.info-list li {
  margin-bottom: 8px;
}


/* ── UTILITY ── */
.hidden { display: none !important; }

/* ── RESPONSIVE: shorter phones ── */
@media (max-height: 720px) {
  :root { --grid-size: min(84vw, 300px); }
  .header-title { font-size: 26px; }
  .title-sub    { font-size: 16px; }
  .icon-btn    { width: 44px; height: 44px; }
  .header      { padding-top: max(10px, env(safe-area-inset-top, 10px)); }
  .round-label-wrap { margin-top: 12px; }
  .response-area { height: 80px; }
  .response-btn { gap: 12px; }
  .stop-area   { margin-top: 40px; }
}

@media (max-height: 620px) {
  :root { --grid-size: min(72vw, 260px); }
  .header-title { font-size: 22px; }
  .title-sub    { font-size: 14px; }
  .round-label-wrap { margin-top: 6px; }
  .response-area { height: 68px; margin-top: 6px; }
  .response-btn { gap: 10px; font-size: 11px; }
}
