/* =================================================================
   INTEGRATED DESIGN SYSTEM — Brain Blast!
   ================================================================= */

:root {
  --or: #FF5722; --or2: #FF8A65; --bl: #1565C0; --gr: #2E7D32; --lgr: #43A047;
  --re: #C62828; --ye: #F9A825; --pu: #6A1B9A; --pi: #AD1457; --te: #00838F;
  --dk: #1A237E; --bg: #FFF8F1; --soft: #FFF0E4;
  --txt: #1A2634;
  --shd: 0 10px 40px rgba(0, 0, 0, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  background-image: 
    radial-gradient(at 0% 0%, rgba(255, 87, 34, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(21, 101, 192, 0.05) 0px, transparent 50%);
  color: var(--txt);
  line-height: 1.6;
  overflow-x: hidden;
  height: 100%;
  user-select: none;
}

/* ─────────────────────────────────────────────────────────────
   SCREENS & OVERLAYS
   ───────────────────────────────────────────────────────────── */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.3s, transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.screen.hide { opacity: 0; pointer-events: none; transform: scale(.94) translateY(18px); z-index: -1; }

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  background: rgba(16, 24, 40, 0.58);
  backdrop-filter: blur(8px);
  transition: opacity .28s;
}

.overlay.hide { opacity: 0; pointer-events: none; }

/* Welcome Screen */
#sw { background: linear-gradient(155deg, #FFF8F1 0%, #FFE8CC 100%); gap: 16px; padding: 20px; position: relative; height: auto; min-height: 100vh; overflow: visible; }
.w-orb { width: 96px; height: 96px; background: linear-gradient(135deg, var(--or), var(--or2)); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 50px; box-shadow: 0 10px 38px rgba(255,87,34,0.38); animation: flt 3s ease-in-out infinite; }
@keyframes flt { 0%, 100% { transform: translateY(0) rotate(-7deg) scale(1); } 50% { transform: translateY(-14px) rotate(7deg) scale(1.06); } }

.w-title { font-family: 'Fredoka One', cursive; font-size: clamp(36px, 9vw, 64px); color: var(--or); line-height: .93; text-align: center; text-shadow: 3px 4px 0 rgba(255,87,34,.15); }
.w-tag { font-size: 12px; letter-spacing: 2px; color: rgba(26,38,52,0.38); text-align: center; text-transform: uppercase; margin-bottom: 20px; }

.diff-row { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; margin-bottom: 10px; }
.dc { padding: 9px 20px; border-radius: 100px; font-size: 13px; font-weight: 900; color: #fff; cursor: pointer; border: 3px solid transparent; transition: all .15s; letter-spacing: .5px; }
.dc:active { transform: scale(.91); }
.dc.on { border-color: #fff; box-shadow: 0 3px 16px rgba(0,0,0,.25); }

.type-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 360px; margin-bottom: 30px; }
.tp { padding: 5px 12px; border-radius: 100px; font-size: 11px; font-weight: 800; color: #fff; letter-spacing: .3px; }

.bbtn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 16px 48px; border-radius: 100px; border: none; font-family: inherit; font-size: 18px; font-weight: 900; cursor: pointer; transition: all .15s; letter-spacing: .5px; margin-bottom: 20px; }
.bbtn:active { transform: scale(.95); }
.or-btn { background: linear-gradient(135deg, var(--or), var(--or2)); color: #fff; box-shadow: 0 6px 26px rgba(255,87,34,0.45); }

/* Game Screen */
#sg { background: var(--bg); justify-content: flex-start; padding: 0; }
.hdr { width: 100%; max-width: 520px; display: flex; align-items: center; padding: 9px 13px; gap: 9px; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,0.09); flex-shrink: 0; }
.hdr-lv { flex: 1; min-width: 0; }
.hdr-ic { font-size: 21px; flex-shrink: 0; }
.hdr-nm { font-size: 14px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-sb { font-size: 10px; font-weight: 700; color: rgba(26,38,52,0.35); letter-spacing: .6px; margin-top: 1px; }
.hdr-tw { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.hdr-t { font-family: 'Fredoka One', cursive; font-size: 30px; line-height: 1; color: var(--or); min-width: 48px; text-align: center; transition: color 0.3s; }
.hdr-tl { font-size: 9px; font-weight: 800; color: rgba(26,38,52,0.28); letter-spacing: 1px; }
.hdr-sw { text-align: right; flex-shrink: 0; }
.hdr-sc { font-family: 'Fredoka One', cursive; font-size: 23px; color: var(--bl); }
.hdr-sl { font-size: 9px; font-weight: 800; color: rgba(26,38,52,0.28); letter-spacing: 1px; }

.seg-bar { width: 100%; max-width: 520px; display: flex; gap: 3px; padding: 5px 13px; background: #fff; border-bottom: 1px solid #F0E4D8; flex-shrink: 0; align-items: center; }
.sbl { font-size: 10px; font-weight: 800; color: rgba(26,38,52,0.28); letter-spacing: 1px; flex-shrink: 0; margin-right: 5px; }
.sbw { display: flex; flex: 1; gap: 3px; }
.sbs { flex: 1; height: 6px; border-radius: 100px; background: #EDE0D4; transition: all 0.4s; }
.sbs.done { background: var(--lgr); }
.sbs.cur { background: var(--or); animation: pseg 1.4s ease-in-out infinite; }
@keyframes pseg { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

.inst-bar { width: 100%; max-width: 520px; background: rgba(255,87,34,0.06); border-bottom: 2px dashed rgba(255,87,34,0.12); padding: 7px 13px; font-size: 12px; font-weight: 800; text-align: center; line-height: 1.4; flex-shrink: 0; }
.prog-w { width: 100%; max-width: 520px; height: 5px; background: #EDE0D4; flex-shrink: 0; overflow: hidden; }
.prog-f { height: 100%; background: linear-gradient(90deg, var(--or), var(--ye)); transition: width .7s cubic-bezier(.23, 1, .32, 1); }

.cw { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; width: 100%; max-width: 520px; align-self: center; position: relative; }
#gc { display: block; cursor: pointer; touch-action: none; background: #fff; }

.abar { width: 100%; max-width: 520px; align-self: center; display: flex; gap: 8px; justify-content: center; padding: 8px 13px; background: #fff; border-top: 1px solid #F0E4D8; flex-shrink: 0; }
.sbtn { position: relative; padding: 10px 20px; border-radius: 100px; border: 2px solid #EDE0D4; background: #FBF5EF; color: rgba(26,38,52,0.58); font-family: inherit; font-size: 13px; font-weight: 800; cursor: pointer; transition: all 0.18s; letter-spacing: .3px; }
.sbtn:active { transform: scale(.92); }
.sbtn:hover { border-color: var(--or); color: var(--or); }
.sbtn-dis { opacity: .4; pointer-events: none; }
.badge { position: absolute; top: -7px; right: -7px; background: var(--re); color: #fff; font-size: 10px; font-weight: 900; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* Pop-cards (Solved / Round Transition) */
.pop-card { background: #fff; border-radius: 26px; padding: 26px 22px; text-align: center; min-width: 276px; max-width: 326px; box-shadow: 0 22px 60px rgba(0,0,0,0.22); animation: popIn 0.36s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes popIn { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.pe { font-size: 55px; display: block; margin-bottom: 5px; animation: bnc 1.1s ease-in-out infinite; }
@keyframes bnc { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.pt { font-family: 'Fredoka One', cursive; font-size: 27px; color: #1a2634; }
.pstar { font-size: 26px; letter-spacing: 4px; margin: 5px 0 14px; color: #FFD600; }
.stat-row { display: flex; gap: 12px; justify-content: center; margin: 8px 0 16px; }
.sb2 { text-align: center; }
.sv { font-family: 'Fredoka One', cursive; font-size: 22px; color: var(--or); }
.sl { font-size: 10px; font-weight: 700; color: rgba(26,38,52,0.36); letter-spacing: .5px; margin-top: 1px; }

.fbtn { width: 100%; padding: 14px; border-radius: 100px; border: none; font-family: inherit; font-size: 16px; font-weight: 900; cursor: pointer; transition: all 0.17s; letter-spacing: .4px; }
.fbtn:active { transform: scale(.96); }

.tc { background: #fff; border-radius: 26px; padding: 30px 24px; text-align: center; min-width: 280px; max-width: 340px; box-shadow: 0 22px 60px rgba(0,0,0,0.22); animation: popIn 0.36s cubic-bezier(0.34, 1.56, 0.64, 1); }
.tc-rnd { font-size: 11px; font-weight: 800; letter-spacing: 2px; color: rgba(26,38,52,0.32); text-transform: uppercase; margin-bottom: 7px; }
.tc-em { font-size: 62px; display: block; margin-bottom: 8px; animation: flt 2s ease-in-out infinite; }
.tc-ti { font-family: 'Fredoka One', cursive; font-size: 29px; color: #1a2634; }
.tc-sb { font-size: 13px; color: rgba(26,38,52,0.44); margin: 7px 0 18px; line-height: 1.5; }
.tc-tp { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 18px; }

/* Results */
#sr { background: linear-gradient(155deg,#FFF8F1,#FFE8CC); padding: 20px; overflow-y: auto; z-index: 1000; }
.rc2 { background: #fff; border-radius: 26px; padding: 24px 20px; width: 100%; max-width: 380px; box-shadow: 0 10px 42px rgba(0,0,0,0.12); margin: 0 auto; }
.iqorb { width: 150px; height: 150px; border-radius: 50%; margin: 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--or), var(--or2)); box-shadow: 0 8px 32px rgba(255,87,34,0.4); animation: flt 3s ease-in-out infinite; }
.iqn { font-family: 'Fredoka One', cursive; font-size: 52px; color: #fff; line-height: 1; }
.iql { font-size: 11px; font-weight: 800; color: rgba(255,255,255,0.68); letter-spacing: 2px; }
.iqcl { font-family: 'Fredoka One', cursive; font-size: clamp(17px, 5vw, 27px); text-align: center; margin-top: 9px; }

.s3g { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 12px 0; }
.s3c { background: var(--soft); border-radius: 12px; padding: 10px 4px; text-align: center; }
.s3v { font-family: 'Fredoka One', cursive; font-size: 19px; }
.s3l { font-size: 10px; font-weight: 700; color: rgba(26,38,52,0.36); letter-spacing: .5px; margin-top: 2px; }

.bl2 { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; padding: 0 10px; }
.br { display: flex; align-items: center; gap: 7px; }
.brn { font-size: 11px; font-weight: 800; width: 60px; flex-shrink: 0; }
.brt { flex: 1; height: 10px; background: var(--soft); border-radius: 100px; overflow: hidden; }
.brf { height: 100%; border-radius: 100px; transition: width 1.5s cubic-bezier(.23,1,.32,1); }
.brv { font-size: 11px; font-weight: 800; width: 32px; text-align: right; flex-shrink: 0; }

.btnrow { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; margin-top: 13px; }
.gbtn { padding: 11px 26px; border-radius: 100px; border: 2px solid var(--soft); background: var(--soft); font-family: inherit; font-size: 13px; font-weight: 800; cursor: pointer; color: rgba(26,38,52,0.55); transition: all 0.17s; letter-spacing: .3px; }
.gbtn:hover { border-color: var(--or); color: var(--or); }

@keyframes fup { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-65px); opacity: 0; } }
.fsc { position: fixed; font-family: 'Fredoka One', cursive; font-size: 20px; color: var(--or); pointer-events: none; z-index: 3000; animation: fup 0.88s ease-out forwards; }

/* ─────────────────────────────────────────────────────────────
   SEO & FOOTER (Maintained from previous state)
   ───────────────────────────────────────────────────────────── */

.seo-content { 
  max-width: 900px; margin: 60px auto; padding: 60px 40px;
  background: #FFF; border-radius: 24px;
  box-shadow: var(--shd); margin-bottom: 100px;
  position: relative; z-index: 10;
}
.seo-content h1 { font-family: 'Fredoka One', cursive; color: var(--bl); margin-bottom: 25px; font-size: 32px; }
.seo-content h2 { margin-top: 40px; margin-bottom: 15px; color: var(--bl); }
.seo-content h3 { margin-top: 25px; margin-bottom: 10px; color: var(--or); }
.seo-content p { margin-bottom: 20px; color: #555; }
.seo-content ul { margin-bottom: 20px; padding-left: 20px; }
.seo-content li { margin-bottom: 10px; color: #555; }

footer { 
  background: #1A2634; color: #fff; padding: 60px 20px; text-align: center; 
  position: relative; z-index: 500;
}
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; margin-bottom: 30px; }
.footer-links a { color: #fff; text-decoration: none; font-weight: 800; font-size: 14px; opacity: 0.7; transition: 0.2s; }
.footer-links a:hover { opacity: 1; color: var(--or); }
footer p { font-size: 12px; opacity: 0.4; letter-spacing: 1px; text-transform: uppercase; }

/* Ad Containers */
.content-ad-wrapper { width: 100%; display: flex; justify-content: center; margin: 40px 0; }
.ad-300x250 { width: 300px; height: 250px; background: #fff; border: 1px solid #ddd; border-radius: 8px; overflow: hidden; position: relative; z-index: 10; }

#popup-ad-container {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.85); z-index: 4000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  display: none;
}
#close-ad { margin-top: 20px; background: #fff; border: none; padding: 10px 30px; border-radius: 30px; font-weight: 900; cursor: pointer; }

/* Utils */
.hide { display: none !important; }
