/* =========================================================
   FONTS
   ========================================================= */
/* Example with Orbitron */
/* Example with Orbitron */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

/* or with Audiowide */
@import url('https://fonts.googleapis.com/css2?family=Audiowide&display=swap');


/* =========================================================
   DESIGN TOKENS — Pac-Man palette
   ========================================================= */
:root{
  /* Core palette */
  --bg:#050507;                 /* cabinet black */
  --maze:#0037ff;               /* maze wall blue */
  --maze-dark:#001a9e;          /* inner rim blue */
  --pacman:#ffed00;             /* Pac-Man yellow */
  --pellet:#ffe9a5;             /* small pellet */
  --white:#F5F7FA;

  /* Ghost accents */
  --ghost-red:#ff0000;          /* blinky */
  --ghost-pink:#ff74c6;         /* pinky */
  --ghost-cyan:#00ffff;         /* inky */
  --ghost-orange:#ff9900;       /* clyde */

  /* UI neutrals */
  --panel:#0b0f1d;
  --panel-2:#0e1224;
  --muted:#b9c0cc;
  --shadow: 0 12px 30px rgba(0,0,0,.55);
  --radius:16px;
}

/* =========================================================
   GLOBAL
   ========================================================= */
*{ box-sizing:border-box; }
html, body { height:100%; }
body{
  margin:0;
  background:
    radial-gradient(1200px 800px at 50% -10%, #0b1530 0%, #070812 35%, var(--bg) 100%);
  color:var(--white);
  font-family: 'Orbitron', 'Audiowide', system-ui, sans-serif;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}

.prompt, .question-text, .choices button {
  font-family: 'Orbitron', sans-serif; 
  font-weight: 700;
}
button{ cursor:pointer; }

/* App layout */
.cp_app{ display:flex; width:100%; min-height:100vh; justify-content:center; align-items:center; padding:40px 24px; }

/* Screens */
.screen{ width:100%; max-width:1200px; display:flex; flex-direction:column; align-items:center; gap:20px; }

/* =========================================================
   TITLES
   ========================================================= */
.app-title{ margin:.2rem 0 1rem; text-align:center; line-height:.9; letter-spacing:.4px; }
.title-top{
  display:block;
  font-size: clamp(28px, 5vw, 54px);
  font-weight:800;
  color:var(--white);
  opacity:.92;
  font-family:"Press Start 2P", system-ui;
  letter-spacing:1px;
}
.title-bottom{
  display:block;
  font-size: clamp(42px, 8vw, 84px);
  color:var(--pacman);
  text-shadow:
    0 0 0 #000,
    0 0 22px rgba(255,237,0,.35),
    0 0 6px rgba(0,0,0,.8);
  font-family:"Press Start 2P", system-ui;
  letter-spacing:2px;
}

/* Section titles */
.screen-title{
  font-size: clamp(18px, 3.4vw, 32px);
  font-family:"Press Start 2P", system-ui;
  color: var(--pacman);
  text-shadow: 0 0 14px rgba(255,237,0,.45);
  margin: 6px 0 12px;
}

/* Cover */
.cover{
  width: min(720px, 90vw);
  border-radius: 18px;
  box-shadow: var(--shadow), 0 0 28px rgba(255,237,0,.18);
  border:3px solid var(--maze);
  outline: 8px solid var(--maze-dark);
  object-fit: cover;
}

/* =========================================================
   PRIMARY BUTTON
   ========================================================= */
.btn{
  appearance:none; border:none; user-select:none;
  background: linear-gradient(180deg, var(--pacman), #e5cc00);
  color:#18120a; font-weight:900; letter-spacing:.6px;
  border-radius: 14px; padding:16px 24px; font-size:18px;
  font-family:"Press Start 2P", system-ui;
  box-shadow: 0 6px 0 #000, 0 0 22px rgba(255,237,0,.38);
  transition: transform .08s ease, box-shadow .2s ease, filter .15s ease;
}
.btn:hover{ transform: translateY(-1px); box-shadow: 0 8px 0 #000, 0 0 26px rgba(255,237,0,.48); }
.btn:active{ transform: translateY(0); filter:saturate(1.06) contrast(1.03); }
.start-btn{ width:min(520px, 90vw); font-size: clamp(18px, 3.4vw, 28px); }

/* =========================================================
   SKILL SELECTION (Pac-maze card language)
   ========================================================= */
#select-screen{ position:relative; isolation:isolate; padding: 28px 0 36px; }
#select-screen::before{
  content:""; position:absolute; inset:-12vh -8vw;
  background:
    radial-gradient(1000px 600px at 50% 20%, rgba(0,55,255,.10), transparent 62%),
    radial-gradient(1200px 700px at 85% 60%, rgba(255,237,0,.10), transparent 66%),
    radial-gradient(900px 600px at 15% 70%, rgba(255,0,0,.08), transparent 68%);
  filter: blur(2px); z-index:-2;
}
#select-screen::after{
  content:""; position:absolute; inset:auto 0 0 0; height: 320px;
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(0,0,0,.00));
  z-index:-1;
}

/* grid */
.select-wrap{
  width:100%;
  display:grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap:22px;
}

/* Pac-maze glass cards */
.skill-card{
  background: linear-gradient(180deg, #0b0f1d, #070c18);
  border: 4px solid var(--maze);
  border-radius: 18px;
  padding: 18px;
  box-shadow:
    0 0 0 8px var(--maze-dark) inset,
    0 14px 0 #000,
    0 16px 36px rgba(0,55,255,.18);
  transition: transform .08s ease, box-shadow .25s ease, border-color .25s ease, filter .25s ease;
}
.skill-card:hover{
  transform: translateY(-2px);
  border-color: var(--pacman);
  box-shadow:
    0 0 0 8px var(--maze-dark) inset,
    0 16px 0 #000,
    0 0 30px rgba(255,237,0,.4);
  filter: saturate(1.06);
}

/* header */
.skill-header{ display:flex; align-items:center; gap:14px; margin-bottom:12px; }
.skill-icon{
  width:56px; height:56px; display:grid; place-items:center; font-size:22px;
  background: radial-gradient(closest-side, rgba(0,55,255,.22), rgba(0,55,255,.06));
  border:2px solid var(--maze);
  border-radius:14px;
  box-shadow: inset 0 0 14px rgba(0,55,255,.18);
  position:relative; overflow:hidden;
}
.skill-title{
  margin:0; font-size: clamp(18px, 2.6vw, 26px); font-weight:900; letter-spacing:.3px; color:#eaf2ff;
  font-family:"Press Start 2P", system-ui;
}
.skill-sub{ margin:.15rem 0 0; color:#cfe6ff; opacity:.9; font-size:13px; }

/* grade grid */
.grade-grid{
  display:grid; gap:12px; margin-top:10px;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

/* Grade buttons → pellet pills */
.grade-btn{
  display:flex; flex-direction:column; align-items:flex-start; justify-content:center;
  text-align:left; padding:14px 14px; min-height:56px; width:100%;
  color:#111; font-weight:900;
  background: var(--pacman);
  border:2px solid #e5cc00;
  border-radius:999px;
  box-shadow: 0 6px 0 #000, 0 0 16px rgba(255,237,0,.35);
  transition: transform .1s ease, box-shadow .18s ease, filter .18s ease;
  position:relative; overflow:hidden;
  font-family:"Press Start 2P", system-ui;
}
.grade-btn strong{ font-size:14px; line-height:1.1; }
.grade-btn span{ font-size:10px; opacity:.9; font-weight:900; margin-top:4px; }
.grade-btn:hover{ transform: scale(1.06); box-shadow: 0 8px 0 #000, 0 0 20px rgba(255,237,0,.5); filter:saturate(1.05); }
.grade-btn:active{ transform: scale(1.03); }

/* =========================================================
   DIFFICULTY — ghost color accents
   ========================================================= */
#difficulty-screen{ position:relative; isolation:isolate; padding: 28px 0 36px; }
#difficulty-screen::before{
  content:""; position:absolute; inset:-12vh -8vw;
  background:
    radial-gradient(1000px 600px at 50% 20%, rgba(0,55,255,.10), transparent 62%),
    radial-gradient(1200px 700px at 85% 60%, rgba(255,237,0,.10), transparent 66%),
    radial-gradient(900px 600px at 15% 70%, rgba(255,0,0,.08), transparent 68%);
  filter: blur(2px); z-index:-2;
}
#difficulty-screen::after{
  content:""; position:absolute; inset:auto 0 0 0; height: 320px;
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(0,0,0,.00));
  z-index:-1;
}
.pill-row{
  display:flex;
  justify-content: center;
  width: 100%;
}
.pill{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  padding:18px 16px; min-height:92px; text-align:center; width:100%;
  color:#e9f2ff; font-weight:800;
  background: var(--panel);
  margin-left:20px;
  border:4px solid var(--maze);
  border-radius:16px;
  box-shadow: 0 0 0 8px var(--maze-dark) inset, 0 10px 0 #000, 0 14px 30px rgba(0,55,255,.22);
  transition: transform .08s ease, box-shadow .22s ease, border-color .18s ease, filter .2s ease;
}
.pill .pill-title{ font-size:18px; font-family:"Press Start 2P", system-ui; }
.pill .pill-sub{ font-size:12px; opacity:.95; margin-top:6px; }

.pill:hover{ transform: translateY(-1px); filter:saturate(1.05); }

/* Ghost color rings */
#difficulty-easy   { border-color: var(--ghost-pink);   box-shadow: 0 0 0 8px var(--maze-dark) inset, 0 0 20px rgba(255,116,198,.35), 0 10px 0 #000; }
#difficulty-medium { border-color: var(--ghost-cyan);   box-shadow: 0 0 0 8px var(--maze-dark) inset, 0 0 20px rgba(0,255,255,.35), 0 10px 0 #000; }
#difficulty-hard   { border-color: var(--ghost-red);    box-shadow: 0 0 0 8px var(--maze-dark) inset, 0 0 20px rgba(255,0,0,.35),   0 10px 0 #000; }

/* Grade/Difficulty responsive */
@media (max-width: 980px){
  .select-wrap{ grid-template-columns: 1fr; }
  .grade-grid{ grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .pill-row{ grid-template-columns: 1fr; }
}
@media (max-width: 520px){
  .grade-grid{ grid-template-columns: 1fr; }
}

/* =========================================================
   QUESTION SCREEN — Pac-look
   ========================================================= */
#question-screen {
  width: 100%;
  max-width: 1200px;
  padding: 12px 0 18px;
  position: relative;
  isolation: isolate;
}
#question-screen::before {
  content: "";
  position: absolute; inset: -6vh -4vw;
  background:
    radial-gradient(1200px 800px at 50% -20%, rgba(0,55,255,.10), transparent 60%),
    radial-gradient(900px 600px  at 80% 20%, rgba(255,237,0,.10), transparent 62%),
    radial-gradient(700px 500px  at 20% 60%, rgba(255,0,0,.08), transparent 65%);
  filter: blur(2px);
  z-index: -1;
}

/* shared width */
#prompt, #question-text, #choices, .bottom-ui { width: min(980px, 92vw); }

/* Prompt/Stem */
.prompt{
  margin-top: 8px;
  font-size: clamp(22px, 4.2vw, 36px);
  color: #fff;
  text-align:center;
  letter-spacing:.2px;
  font-weight: 700;
  font-family:"Press Start 2P", system-ui;
}
.question-text{
  margin-top: 8px;
  font-weight: 600;
  text-align: center;
  color: #eaf2ff;
  font-size: clamp(18px, 3.6vw, 28px);
  line-height: 1.35;
  text-shadow: 0 0 18px rgba(0,55,255,.18), 0 0 2px rgba(255,255,255,.6);
}

/* Answer choices — dark tile with Pac-glow hover */
.choices{
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  place-items: center;
}
.choices button{
  width: 100%;
  max-width: min(900px, 92vw);
  padding: 16px 18px;
  border: 3px solid var(--maze);
  border-radius: 14px;
  background: var(--panel);
  color: #fff;
  font-weight: 800;
  font-size: clamp(16px, 3vw, 22px);
  letter-spacing: .2px;
  font-family:"Press Start 2P", system-ui;
  box-shadow: 0 0 0 8px var(--maze-dark) inset, 0 6px 0 #000, 0 10px 24px rgba(0,55,255,.18);
  transition: transform .08s ease, box-shadow .18s ease, border-color .18s ease, background .2s ease, color .2s ease;
  position: relative; overflow: hidden;
}
.choices button:hover,
.choices button:focus-visible{
  border-color: var(--pacman);
  background: #bcbbaa;
  color:#111;
  box-shadow:
    0 0 0 8px var(--maze-dark) inset,
    0 8px 0 #000,
    0 0 26px rgba(255,237,0,.35);
}
.choices button:active{ transform: translateY(1px) scale(.999); }

/* Right/Wrong colors when JS applies inline bg can remain;
   this keeps outline glow consistent */
.choices button.correct { border-color: var(--pacman); }
.choices button.wrong   { border-color: var(--ghost-red); }

/* Retry */
.retry{
  color:#ff9b9b;
  font-weight:900;
  letter-spacing:.3px;
  text-shadow: 0 0 14px rgba(255,98,98,.35);
  margin: 6px 0 2px;
  font-family:"Press Start 2P", system-ui;
}
.pulse{ animation: pulse .9s ease; }
@keyframes pulse {
  0%{ transform:scale(1); opacity:.95; }
  30%{ transform:scale(1.03); opacity:1; }
  100%{ transform:scale(1); opacity:.95; }
}

/* Progress bar — Pac-dots filling */
.progress-bar{
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, #0e1224, #0b0f1d);
  border: 3px solid var(--maze);
  box-shadow: inset 0 0 0 6px var(--maze-dark), 0 0 18px rgba(0,55,255,.16);
  display: grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 3px 6px;
  margin: 12px auto 8px;
  width: min(800px, 90vw);
}
.progress-bar .segment{
  border-radius: 999px;
  background: radial-gradient(circle at 50% 50%, #1b223a 0%, #12192e 60%);
  transition: background .25s ease, box-shadow .25s ease, transform .15s ease;
}
.progress-bar .segment.filled{
  background: radial-gradient(circle at 50% 50%, var(--pellet) 0%, var(--pacman) 70%);
  box-shadow: 0 0 10px rgba(255,237,0,.55), 0 0 20px rgba(255,237,0,.28);
  transform: scale(1.02);
}

/* Bottom row / HUD */
.bottom-ui{
  width: min(980px, 92vw);
  display:flex; align-items:center; justify-content:space-between;
  gap: 14px;
}
.hud{ display:flex; gap:10px; align-items:center; }
.hud-chip{
  background: linear-gradient(180deg, #0e1224, #0b0f1d);
  color:#eaf2ff; padding:8px 12px; border-radius:999px; font-size:13px;
  border:3px solid var(--maze);
  box-shadow: 0 0 0 6px var(--maze-dark) inset;
  font-family:"Press Start 2P", system-ui;
}
.hint{
  color:#e7ecf7; opacity:.92; font-size:13px; text-align:center; margin:6px 0 8px;
}

/* Canvas frame (maze bezel) */
#game{
  border:10px solid var(--maze);
  background:#000;
  max-width:95vw; max-height:85vh; touch-action:none;
  box-shadow: 0 0 0 8px var(--maze-dark) inset, 0 16px 40px rgba(0,0,0,.6);
  border-radius:10px;
}

/* Overlays */
.overlay{
  position:fixed; inset:0; background:rgba(0,0,0,.72);
  display:none; align-items:center; justify-content:center; z-index:1000;
}
.modal{
  background: linear-gradient(#060810,#070a14);
  padding:28px 36px; border:3px solid var(--maze); border-radius:14px; text-align:center;
  box-shadow: 0 0 0 8px var(--maze-dark) inset, 0 0 18px rgba(255,237,0,.25);
}
.modal h2{
  color:var(--pacman);
  margin:6px 0 10px;
  font-family:"Press Start 2P", system-ui;
}
.modal .btn{ margin-top:8px; }

/* Focus */
:focus-visible{ outline:3px solid var(--pacman); outline-offset:2px; border-radius:8px; }

/* Responsive tweaks */
@media (max-width: 600px){
  .question-text{ font-size: clamp(18px, 5vw, 22px); }
  .choices button{ padding: 14px 14px; }
  .bottom-ui{ flex-direction: column; align-items: stretch; gap:10px; }
}

/* ----------------------------------------------
   GLOBAL RESPONSIVE TUNING
---------------------------------------------- */


/* Tablets landscape / small laptops (≤ 1024px) */
@media (max-width: 1024px){
  .cp_app{ padding: 36px 22px; }
  #select-screen .select-wrap{ grid-template-columns: 1fr; gap: 18px; }
  .grade-grid{ grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .pill-row{ display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .pill{ margin-left: 0; }
  #game{ width: 96vw; height: auto; max-height: 70vh; }
  .bottom-ui{ gap: 10px; }
  .choices button{ max-width: 92vw; }
}

/* Tablets portrait / large phones (≤ 820px) */
@media (max-width: 820px){
  .cp_app{ padding: 28px 18px; }
  .skill-card{ padding: 14px; border-width: 3px; }
  .grade-grid{ grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .pill-row{ grid-template-columns: 1fr 1fr; }
  .pill{ min-height: 78px; }
  .choices{ gap: 10px; }
  .choices button{ padding: 14px 14px; font-size: clamp(15px, 2.6vw, 20px); }
  .progress-bar{ height: 14px; width: min(700px, 92vw); }
  .hud-chip{ font-size: 12px; padding: 7px 10px; }
  .hint{ font-size: 12px; }
}

/* Phones (≤ 600px) */
@media (max-width: 600px){
  .cp_app{ padding: 22px 14px; }
  .cover{ width: 92vw; border-width: 2px; outline-width: 6px; }
  .skill-card{ border-width: 3px; border-radius: 14px; }
  .skill-header{ gap: 12px; }
  .skill-icon{ width: 48px; height: 48px; border-radius: 12px; }
  .grade-grid{ grid-template-columns: 1fr; }
  .grade-btn{ min-height: 52px; padding: 12px 14px; }
  .grade-btn strong{ font-size: 13px; }
  .grade-btn span{ font-size: 10px; }
  #control-screen .pill-row{ grid-template-columns: 1fr; }
  .pill{ min-height: 72px; }
  #prompt{ font-size: clamp(18px, 5.8vw, 26px); }
  .question-text{ font-size: clamp(16px, 4.4vw, 20px); }
  .progress-bar{ height: 12px; padding: 2px 5px; }
  .progress-bar .segment.filled{ box-shadow: 0 0 8px rgba(255,237,0,.5), 0 0 16px rgba(255,237,0,.25); }
  .bottom-ui{ flex-direction: column; align-items: stretch; gap: 8px; }
  #game{ width: 96vw; height: auto; max-height: 64vh; border-width: 8px; box-shadow: 0 0 0 6px var(--maze-dark) inset, 0 12px 30px rgba(0,0,0,.55); }
  .modal{ width: min(92vw, 520px); padding: 22px 18px; }
}

/* Small phones (≤ 420px) */
@media (max-width: 420px){
  .cp_app{ padding: 18px 10px; }
  .title-top{ font-size: clamp(22px, 7vw, 32px); }
  .title-bottom{ font-size: clamp(34px, 10vw, 56px); }
  .btn{ padding: 14px 16px; font-size: 16px; border-radius: 12px; }
  .start-btn{ width: 92vw; }
  .skill-card{ padding: 12px; }
  .pill{ min-height: 66px; padding: 14px 12px; }
  .choices button{ font-size: clamp(14px, 4vw, 18px); border-width: 2px; }
  #game{ border-width: 6px; border-radius: 8px; }
  .hud-chip{ font-size: 11px; padding: 6px 9px; border-width: 2px; }
  .retry{ font-size: 12px; }
}

/* Ultra-compact (≤ 360px) */
@media (max-width: 360px){
  .cp_app{ padding: 14px 8px; }
  .skill-card{ border-width: 2px; border-radius: 12px; }
  .grade-btn{ padding: 10px 12px; min-height: 48px; }
  .pill{ min-height: 62px; border-width: 3px; }
  .progress-bar{ height: 10px; gap: 3px; }
  .modal{ width: 94vw; padding: 18px 14px; border-width: 2px; }
}

/* Very short viewports (e.g., landscape phones) */
@media (orientation: landscape) and (max-height: 480px){
  .cover{ display: none; }
  .cp_app{ padding: 10px; }
  #select-screen, #difficulty-screen, #control-screen{ padding: 10px 0 14px; }
  #game{ max-height: 68vh; width: 96vw; }
  .hint{ display: none; }
  .modal{ width: 86vw; padding: 16px; }
}

/* Touch-first tweaks (bigger hit targets, no hover reliance) */
@media (hover: none), (pointer: coarse){
  .grade-btn,
  .choices button,
  .pill,
  .btn{ padding-block: calc(1em + 4px); }
  .choices button:hover{ transform: none; }
  .grade-btn:hover{ transform: none; }
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce){
  *{ animation: none !important; transition: none !important; }
  .pulse{ animation: none !important; }
}

/* Respect iOS safe areas (notches) */
@supports (padding: max(0px)){
  body{
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
}

/* Make sure the canvas never causes pull-to-refresh or highlight issues */
canvas{
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
html, body{ overscroll-behavior: none; }
