/* ============================================================
   OnlineMathBasics — Game CSS
   All styles for the game screens (level select, play, results)
   Used by: addition.html, subtraction.html, multiplication.html, division.html
============================================================ */

/* ── Game Page Shell ─────────────────────────────────────── */
.game-page {
  min-height: calc(100vh - var(--hdr-h) - env(safe-area-inset-top,0px));
  display: flex; flex-direction: column;
  background: linear-gradient(160deg, #1A1A2E 0%, #16213E 55%, #0F3460 100%);
  position: relative; overflow: hidden;
}
.game-page::before {
  content:''; position:absolute; inset:0; pointer-events:none;
  background:
    radial-gradient(circle at 18% 22%, rgba(var(--op-rgb,255,107,53),.17) 0%, transparent 48%),
    radial-gradient(circle at 82% 78%, rgba(0,187,249,.12) 0%, transparent 48%);
}

/* Stars */
.stars-bg { position:absolute; inset:0; pointer-events:none; overflow:hidden; z-index:0; }
.star-dot  { position:absolute; background:white; border-radius:50%; animation:twinkle var(--d) ease-in-out infinite var(--dl); }

/* Game content wrapper */
.game-body {
  position:relative; z-index:1;
  flex:1; display:flex; flex-direction:column;
  max-width:640px; width:100%;
  margin:0 auto;
  padding:20px 16px 16px;
}

/* ── Game page header ────────────────────────────────────── */
.game-hdr { text-align:center; color:white; margin-bottom:28px; }
.game-hdr .sec-tag { background:rgba(255,255,255,.11); color:rgba(255,255,255,.9); margin-bottom:8px; }
.game-hdr h1 { font-size:clamp(22px,5vw,36px); font-weight:900; color:white; margin-bottom:5px; }
.game-hdr p  { font-size:13px; color:rgba(255,255,255,.55); font-weight:600; }

/* ── Level Select ────────────────────────────────────────── */
#level-select { animation:slideUp .45s ease both; flex:1; display:flex; flex-direction:column; justify-content:center; }
.level-grid {
  display:grid; grid-template-columns:1fr 1fr; gap:14px;
}
.lv-card {
  background:rgba(255,255,255,.07); backdrop-filter:blur(12px);
  border:2px solid rgba(255,255,255,.12); border-radius:var(--r);
  padding:24px 16px; text-align:center; cursor:pointer; color:white;
  transition:all .28s var(--spring); -webkit-tap-highlight-color:transparent;
  position:relative; overflow:hidden;
}
.lv-card:hover  { background:rgba(255,255,255,.14); border-color:var(--op,rgba(255,255,255,.4)); transform:translateY(-6px) scale(1.02); box-shadow:0 14px 40px rgba(0,0,0,.3); }
.lv-card:active { transform:scale(.96); transition-duration:70ms; }
.lv-emoji { font-size:40px; display:block; margin-bottom:9px; line-height:1.1; }
.lv-grade { font-size:10px; font-weight:800; text-transform:uppercase; letter-spacing:1.2px; color:var(--op,rgba(255,255,255,.7)); margin-bottom:3px; }
.lv-name  { font-size:14px; font-weight:900; margin-bottom:3px; }
.lv-range { font-size:12px; color:rgba(255,255,255,.48); font-weight:600; }

/* ── Game Screen ─────────────────────────────────────────── */
#game-screen { animation:slideUp .4s ease both; display:flex; flex-direction:column; flex:1; }

.game-topbar {
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:14px; gap:8px;
}
.back-btn {
  background:rgba(255,255,255,.1); border:1.5px solid rgba(255,255,255,.2);
  border-radius:var(--pill); color:white;
  font-family:'Nunito',sans-serif; font-size:13px; font-weight:800;
  padding:7px 15px; cursor:pointer; transition:all .2s; flex-shrink:0;
  -webkit-tap-highlight-color:transparent;
}
.back-btn:hover, .back-btn:active { background:rgba(255,255,255,.2); }
.score-disp  { font-size:19px; font-weight:900; color:var(--yellow); display:flex; align-items:center; gap:4px; }
.streak-disp { font-size:13px; font-weight:800; color:rgba(255,255,255,.55); transition:all .3s; text-align:center; }
.streak-disp.hot { color:var(--orange); animation:pulseRing .9s infinite; }

/* Progress */
.prog-track { background:rgba(255,255,255,.1); border-radius:var(--pill); height:8px; margin-bottom:20px; overflow:hidden; }
.prog-fill  {
  height:100%;
  background:linear-gradient(90deg, var(--op,#FF6B35), #4ECDC4);
  background-size:200% 100%;
  animation:gradPan 3s ease infinite;
  border-radius:var(--pill);
  transition:width .5s var(--spring);
}

/* Question card */
.q-card {
  background:rgba(255,255,255,.08); backdrop-filter:blur(18px);
  border:2px solid rgba(255,255,255,.12); border-radius:var(--r);
  padding:26px 22px; text-align:center; transition:border-color .25s, background .25s;
  margin-bottom:14px;
}
.q-card.flash-ok   { border-color:var(--green); background:rgba(6,214,160,.18); animation:popScale .4s; }
.q-card.flash-fail { border-color:var(--red);   background:rgba(239,71,111,.15); animation:shakeX .45s; }
.char-disp { font-size:44px; display:block; min-height:55px; margin-bottom:6px; transition:all .3s; line-height:1.2; }
.q-lbl     { font-size:10px; font-weight:800; text-transform:uppercase; letter-spacing:1.5px; color:rgba(255,255,255,.38); margin-bottom:14px; }

/* Visual aids (Grade 1 emoji counting) */
.vis-aids { display:flex; align-items:center; justify-content:center; gap:10px; flex-wrap:wrap; margin-bottom:14px; min-height:48px; }
.vis-grp  { display:flex; flex-wrap:wrap; gap:2px; justify-content:center; max-width:150px; }
.vis-em   { font-size:22px; animation:bounceIn .35s backwards; }
.vis-op-sym { font-size:24px; font-weight:900; color:var(--op,#FF6B35); flex-shrink:0; }

/* Problem display */
.prob-row { display:flex; align-items:center; justify-content:center; gap:10px; margin-bottom:8px; flex-wrap:wrap; }
.pn  { font-size:clamp(44px,10vw,72px); font-weight:900; color:white; line-height:1; }
.pop { font-size:clamp(32px,7vw,54px); font-weight:900; color:var(--op,#FF6B35); line-height:1; }
.peq { font-size:clamp(32px,7vw,54px); color:rgba(255,255,255,.3); line-height:1; }
.pbl { font-size:clamp(44px,10vw,72px); font-weight:900; color:var(--yellow); line-height:1; border-bottom:3px solid var(--yellow); min-width:50px; display:inline-block; }
.q-hint { font-size:12px; color:rgba(255,255,255,.38); font-weight:600; }

/* Choices */
.choices-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:12px; }
.choice-btn {
  background:rgba(255,255,255,.08); border:2.5px solid rgba(255,255,255,.14);
  border-radius:var(--rs); color:white;
  font-family:'Nunito',sans-serif; font-size:clamp(22px,5vw,34px); font-weight:900;
  padding:16px; cursor:pointer; line-height:1;
  transition:all .25s var(--spring); -webkit-tap-highlight-color:transparent;
}
.choice-btn:hover:not(:disabled) { background:rgba(255,255,255,.16); border-color:var(--op,#4ECDC4); transform:translateY(-4px) scale(1.04); box-shadow:0 8px 22px rgba(0,0,0,.25); }
.choice-btn:active:not(:disabled){ transform:scale(.94); transition-duration:70ms; }
.choice-btn.correct { background:rgba(6,214,160,.22);  border-color:var(--green); color:var(--green); animation:popScale .4s; }
.choice-btn.wrong   { background:rgba(239,71,111,.18); border-color:var(--red);   color:var(--red);   animation:shakeX .45s; }
.choice-btn:disabled{ cursor:not-allowed; opacity:.65; transform:none !important; }

/* Feedback */
.feedback-msg { text-align:center; font-size:16px; font-weight:900; min-height:26px; transition:all .3s; color:transparent; }
.feedback-msg.ok  { color:var(--green); animation:slideUp .3s; }
.feedback-msg.err { color:var(--red);   animation:shakeX .3s; }

/* ── Results Screen ──────────────────────────────────────── */
#results-screen { animation:bounceIn .5s ease both; display:flex; flex-direction:column; flex:1; justify-content:center; }
.res-card {
  background:rgba(255,255,255,.09); backdrop-filter:blur(18px);
  border:2px solid rgba(255,255,255,.13); border-radius:var(--r);
  padding:40px 28px; text-align:center; color:white;
}
.res-mascot { font-size:68px; display:block; margin-bottom:14px; }
.res-title  { font-size:28px; font-weight:900; margin-bottom:5px; }
.res-sub    { font-size:14px; color:rgba(255,255,255,.55); font-weight:600; margin-bottom:24px; }
.stars-row  { display:flex; justify-content:center; gap:7px; font-size:40px; margin-bottom:22px; }
.res-star   { animation:starSpin .6s backwards; }
.res-star:nth-child(2){ animation-delay:.15s; }
.res-star:nth-child(3){ animation-delay:.3s; }
.res-score  { font-size:54px; font-weight:900; color:var(--yellow); display:block; animation:countPop .5s ease; margin-bottom:4px; }
.res-detail { font-size:13px; color:rgba(255,255,255,.45); font-weight:700; margin-bottom:28px; }
.res-actions{ display:flex; gap:10px; justify-content:center; flex-wrap:wrap; }
.btn-res {
  font-family:'Nunito',sans-serif; font-size:15px; font-weight:800;
  padding:13px 26px; border-radius:var(--pill); border:none; cursor:pointer;
  transition:all .25s var(--spring); -webkit-tap-highlight-color:transparent;
}
.btn-res-a { background:var(--op-g,linear-gradient(135deg,#FF6B35,#9B5DE5)); color:white; box-shadow:0 5px 18px var(--op-sh,rgba(255,107,53,.38)); }
.btn-res-a:hover { transform:translateY(-2px); box-shadow:0 9px 26px var(--op-sh,rgba(255,107,53,.5)); }
.btn-res-b { background:rgba(255,255,255,.1); color:white; border:2px solid rgba(255,255,255,.2) !important; }
.btn-res-b:hover { background:rgba(255,255,255,.18); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width:360px) {
  .choice-btn { padding:12px; }
  .q-card     { padding:20px 16px; }
  .res-card   { padding:28px 18px; }
  .level-grid { gap:10px; }
}
@media (min-width:480px) {
  .game-body  { padding:24px 24px 20px; }
  .choices-grid{ gap:12px; }
}
@media (min-width:768px) {
  .q-card   { padding:32px 30px; }
  .res-card { padding:48px 40px; }
  .level-grid{ gap:18px; }
}
/* Landscape on small phones — shrink everything */
@media (orientation:landscape) and (max-height:500px) {
  .game-hdr  { margin-bottom:14px; }
  .game-hdr h1 { font-size:20px; }
  .char-disp { font-size:32px; min-height:40px; }
  .pn  { font-size:clamp(32px,7vw,52px); }
  .pop, .peq { font-size:clamp(24px,5vw,40px); }
  .pbl { font-size:clamp(32px,7vw,52px); }
  .choice-btn { padding:12px; font-size:clamp(18px,4vw,28px); }
  .q-card { padding:16px; }
}
