/* ── Paramount brand fonts ── */
@font-face {
  font-family: 'Vista Sans';
  src: url('../hub/fonts/ParamountVistaSans-CondensedBold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Peak Sans';
  src: url('../hub/fonts/Peak-Sans_Light.otf') format('opentype');
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: 'Peak Sans';
  src: url('../hub/fonts/PeakSans_Regular.otf') format('opentype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Peak Sans';
  src: url('../hub/fonts/PeakSans_Bold.otf') format('opentype');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Peak Sans';
  src: url('../hub/fonts/PeakSans_Black.otf') format('opentype');
  font-weight: 900;
  font-display: swap;
}

/* ── Brand tokens ── */
:root {
  --bg:       #000a3c;
  --surface:  #0d1525;
  --surface2: #1a2a45;
  --text:     #d9dae2;
  --muted:    #8e8e91;
  --border:   #1a2a45;
  --blue:     #0064ff;
  --gold:     #ffd400;
  --topbar-h: 48px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Peak Sans', 'Segoe UI', Arial, sans-serif;
  font-weight: 400;
  height: 100vh;
  height: 100dvh; /* avoids mobile browser chrome overlap */
  overflow: hidden;
}

.back-to-hub {
  position: fixed;
  top: 10px; left: 12px;
  z-index: 200;
  color: #fff;
  text-decoration: none;
  font-size: 1.4rem;
  padding: 6px 10px;
  background: rgba(0,0,0,0.55);
  border-radius: 6px;
  touch-action: manipulation;
  line-height: 1;
}
.back-to-hub:hover { background: rgba(0,0,0,0.8); }

.screen { display: none; }
.screen.active { display: flex; flex-direction: column; }

button { touch-action: manipulation; cursor: pointer; font-family: 'Peak Sans', sans-serif; }

/* ── MENU ── */
#screen-menu {
  height: 100vh;
  height: 100dvh;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 4vh, 32px);
  padding: clamp(48px, 8vh, 72px) 16px clamp(24px, 4vh, 40px);
}

.menu-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.paramount-logo { height: 40px; width: auto; opacity: 0.95; }

.menu-header h1 {
  font-family: 'Vista Sans', 'Arial Narrow', Arial, sans-serif;
  font-weight: 700;
  font-size: clamp(2rem, 8vw, 3.4rem);
  letter-spacing: clamp(2px, 1vw, 4px);
  color: #fff;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 2px 16px rgba(0,100,255,0.45);
}

.menu-header p {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}



/* ── GAME ── */
#screen-game {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.game-topbar {
  width: 100%;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 2px solid var(--blue);
  flex-shrink: 0;
}

.btn-back-menu {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: 4px;
  white-space: nowrap;
  min-height: 30px;
}
.btn-back-menu:hover { color: var(--text); border-color: var(--blue); }

.topbar-title {
  font-family: 'Vista Sans', 'Arial Narrow', Arial, sans-serif;
  font-size: clamp(0.65rem, 2.5vw, 1rem);
  letter-spacing: clamp(1px, 0.5vw, 2px);
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.topbar-stats {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.stat-primary {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--blue);
  font-family: 'Peak Sans', sans-serif;
  letter-spacing: 0.5px;
  min-width: 48px;
  text-align: center;
}

.stat-sep { color: var(--border); font-size: 1rem; }

.btn-hint {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
  min-height: 30px;
  transition: background 0.12s, border-color 0.12s;
}
.btn-hint:hover { background: var(--border); border-color: var(--gold); }



#play-surface {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: var(--bg);
}

#board-canvas {
  position: absolute;
  top: 0; left: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

/* ── WIN ── */


.win-emoji { font-size: 4rem; line-height: 1; }

.win-title {
  font-family: 'Vista Sans', 'Arial Narrow', Arial, sans-serif;
  font-weight: 700;
  font-size: 3.4rem;
  letter-spacing: 5px;
  color: #fff;
  text-transform: uppercase;
  text-shadow: 0 0 24px rgba(255,212,0,0.55);
}

.win-puzzle { font-size: 1rem; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; font-weight: 300; }
.win-time-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; margin-top: 8px; }
.win-time {
  font-size: 2.6rem; font-weight: 700; color: var(--gold); line-height: 1;
  font-family: 'Vista Sans', 'Arial Narrow', Arial, sans-serif; letter-spacing: 2px;
}

.win-buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

.btn {
  padding: 12px 28px; border-radius: 4px; font-size: 0.88rem;
  font-weight: 700; border: none; min-height: 48px; letter-spacing: 1px; text-transform: uppercase;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #0050cc; }
.btn-secondary { background: var(--surface); border: 2px solid var(--surface2); color: var(--text); }
.btn-secondary:hover { border-color: var(--blue); }



/* ── Privacy modal ── */
#privacy-modal {
  display: none; position: fixed; inset: 0; z-index: 9998;
  background: rgba(0,0,0,0.8); align-items: center; justify-content: center; padding: 24px;
}
#privacy-modal.active { display: flex; }
.privacy-modal-inner {
  position: relative; width: 100%; max-width: 860px; height: 80vh;
  background: #fff; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column;
}
.privacy-modal-bar {
  display: flex; align-items: center; justify-content: flex-end;
  background: #0d1525; padding: 8px 12px; flex-shrink: 0;
}
.privacy-modal-close {
  background: none; border: none; color: #DADAE3; font-size: 1.4rem;
  cursor: pointer; line-height: 1; padding: 4px 8px; border-radius: 6px; transition: background 0.15s;
}
.privacy-modal-close:hover { background: rgba(255,255,255,0.1); }
.privacy-modal-inner iframe { flex: 1; width: 100%; border: none; }

#cmp-overlay {
  display: none; position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,0.85); will-change: transform;
}
#cmp-overlay.active { display: block; }

.cg-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  padding: 10px 16px 12px; text-align: center;
  background: linear-gradient(to top, rgba(3,8,28,0.92), rgba(3,8,28,0));
  pointer-events: none;            /* let board clicks pass through the bar… */
}
.cg-footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; pointer-events: auto; }  /* …except the links */
.cg-footer-links a { color: #6b6b6e; text-decoration: none; font-size: 12px; transition: color 0.2s; }
.cg-footer-links a:hover { color: #d9dae2; }

body.under18 [data-adult-only] { display: none; }

/* ── Mode selection buttons (Normal / Hard) ── */
.mode-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-mode {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 16px 36px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
  touch-action: manipulation;
  min-height: 72px;
  min-width: 140px;
}

.mode-name {
  font-family: 'Vista Sans', 'Arial Narrow', Arial, sans-serif;
  font-size: clamp(1rem, 4vw, 1.3rem);
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  line-height: 1;
}

.mode-detail {
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.5px;
  opacity: 0.85;
}

.btn-mode-normal {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-mode-normal:hover {
  background: #0050cc;
  border-color: #0050cc;
  transform: translateY(-2px);
}

.btn-mode-hard {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-mode-hard:hover {
  background: var(--surface2);
  border-color: var(--gold);
  color: var(--gold);
  transform: translateY(-2px);
}
.btn-mode-hard .mode-name { color: inherit; }

.btn-mode:active { transform: translateY(0); }



/* ── Win overlay (shown on top of the completed puzzle) ── */
/* Panel is 30% smaller than the original win screen.
   Text scales proportionally using the same 0.7× ratio.   */

#win-overlay {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 100;
  pointer-events: none;
}
#win-overlay.active {
  display: flex;
  justify-content: center;
  padding-top: 14px;       /* 20px × 0.7 */
  pointer-events: all;
}

.win-panel {
  background: rgba(0, 10, 60, 0.93);
  border: 1px solid var(--blue);
  border-radius: 8px;
  padding: 17px 28px 20px; /* 24/40/28 × 0.7 */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;               /* 8px × 0.7 */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 28px rgba(0,0,0,0.7);
  max-width: min(308px, 88vw); /* 440px × 0.7, capped to viewport */
  width: 88%;
}

/* All win text scaled to 70% of original sizes */
.win-panel .win-emoji       { font-size: 2.8rem;  line-height: 1; }           /* 4rem × 0.7 */
.win-panel .win-title       { font-size: 2.4rem;  letter-spacing: 3px;        /* 3.4rem × 0.7 */
                              font-family: 'Vista Sans', 'Arial Narrow', Arial, sans-serif;
                              font-weight: 700; color: #fff; text-transform: uppercase;
                              text-shadow: 0 0 16px rgba(255,212,0,0.55); }
.win-panel .win-puzzle      { font-size: 0.7rem;  color: var(--muted);         /* 1rem × 0.7 */
                              letter-spacing: 1px; text-transform: uppercase; font-weight: 300; }
.win-panel .win-time-label  { font-size: 0.5rem;  color: var(--muted);         /* 0.72rem × 0.7 */
                              text-transform: uppercase; letter-spacing: 1.5px; margin-top: 6px; }
.win-panel .win-time        { font-size: 1.8rem;  font-weight: 700; color: var(--gold); /* 2.6rem × 0.7 */
                              line-height: 1;
                              font-family: 'Vista Sans', 'Arial Narrow', Arial, sans-serif;
                              letter-spacing: 2px; }
.win-panel .win-buttons     { display: flex; gap: 8px; flex-wrap: wrap;         /* 12px × 0.7 */
                              justify-content: center; margin-top: 6px; }
.win-panel .btn             { padding: 8px 20px; border-radius: 4px;           /* 12/28 × 0.7 */
                              font-size: 0.72rem; font-weight: 700; border: none;
                              min-height: 34px; letter-spacing: 1px; text-transform: uppercase; }

/* play-surface must be position:relative for the overlay to sit over it */
#play-surface {
  position: relative;
}

/* ── Mobile breakpoints ── */

/* Narrow phones: ≤ 480px */
@media (max-width: 480px) {
  :root { --topbar-h: 42px; }

  /* Menu */
  .paramount-logo         { height: 28px; }
  .menu-header            { gap: 8px; }
  #screen-menu            { gap: 16px; }

  /* Puzzle selector cards shrink */
  .mode-buttons           { gap: 10px; }
  .btn-mode               { min-width: 120px; padding: 14px 20px; }

  /* Topbar — compress spacing so all elements fit */
  .game-topbar            { gap: 6px; padding: 0 8px; }
  .btn-back-menu          { font-size: 0.65rem; padding: 4px 7px; }
  .btn-hint               { font-size: 0.65rem; padding: 4px 8px; letter-spacing: 0; }
  .stat-primary           { font-size: 0.78rem; min-width: 36px; }
  .stat-sep               { display: none; } /* hide · separator to save space */

  /* Win panel — let it go almost full-width on tiny screens */
  .win-panel              { max-width: 96vw; width: 96%; padding: 14px 16px 18px; }
  .win-panel .win-title   { font-size: 2rem; }
  .win-panel .win-time    { font-size: 1.5rem; }
  .win-panel .win-buttons { flex-direction: column; align-items: stretch; }
  .win-panel .btn         { text-align: center; }
}

/* Very short screens (landscape phone): reduce vertical padding */
@media (max-height: 500px) {
  :root { --topbar-h: 38px; }

  #screen-menu  { gap: 12px; padding: 36px 16px 16px; }
  #win-overlay.active { padding-top: 6px; }
  .win-panel    { padding: 10px 22px 14px; gap: 3px; }
  .win-panel .win-emoji { font-size: 1.6rem; }
  .win-panel .win-title { font-size: 1.6rem; }
  .win-panel .win-time  { font-size: 1.3rem; }
  .win-panel .win-time-label { margin-top: 2px; }
}

/* Touch targets — ensure all buttons are at least 44px tall on touch devices */
@media (pointer: coarse) {
  .btn-back-menu,
  .btn-hint               { min-height: 44px; }
  .win-panel .btn         { min-height: 44px; }
}

/* ── Loading screen ── */
#screen-loading {
  height: 100vh;
  height: 100dvh;
  align-items: center;
  justify-content: center;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding: 40px 24px;
}

.loading-box h1 {
  font-family: 'Vista Sans', 'Arial Narrow', Arial, sans-serif;
  font-size: clamp(1.8rem, 7vw, 3rem);
  letter-spacing: 4px;
  color: #fff;
  text-transform: uppercase;
  text-shadow: 0 2px 16px rgba(0,100,255,0.45);
}

.loading-box p {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--surface2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Menu body (rules list + start button) ── */
.menu-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.menu-rules {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
  width: 100%;
}

.rule-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--text);
}

.rule-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

@media (max-width: 480px) {
  .menu-rules { max-width: 100%; }
  .rule-item  { font-size: 0.75rem; padding: 8px 12px; }
}
