@font-face { font-family: 'Baloo'; src: url(../game/fonts/baloo-latin.woff2) format('woff2'); font-weight: 400 800; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Baloo'; src: url(../game/fonts/baloo-latin-ext.woff2) format('woff2'); font-weight: 400 800; font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Baloo'; src: url(../game/fonts/baloo-arabic.woff2) format('woff2'); font-weight: 400 800; font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
:root {
  --bg: #0b0a1f; --bg2: #1a1650; --ink: #f4f3ff; --muted: #b8b4e6; --card: #ffffff; --card-ink: #1c1940;
  --math: #f07a35; --arabic: #1fb3b0; --quran: #e9c46a; --stardust: #b37bff; --good: #46d36a; --bad: #ff6b6b;
  --r: 18px; --gap: clamp(8px, 1.6vmin, 16px);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --fs: clamp(14px, 2.2vmin + 6px, 22px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; overscroll-behavior: none; }
body { font: 500 var(--fs)/1.35 'Baloo', system-ui, sans-serif; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
img { -webkit-user-drag: none; user-select: none; }
.ar { font-family: 'Baloo', system-ui, sans-serif; direction: rtl; }
.quran { font-family: 'WarshQuran', 'AmiriQuran', serif; direction: rtl; line-height: 2.1; }
bdi { unicode-bidi: isolate; }

#sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; background: #0b0a1f center/cover no-repeat; transition: background-image .4s; }
#sky::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, #0b0a1f99 0%, #0b0a1f22 30%, #0b0a1f33 70%, #0b0a1fcc 100%); }
#sky[data-bg="starmap"] { background-image: url(https://cdn.digitalarabians.xyz/games/cuby-code/v1/game/bg/starmap.webp); }
#app { position: fixed; inset: 0; z-index: 1; display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 6px) calc(var(--safe-r) + 8px) calc(var(--safe-b) + 6px) calc(var(--safe-l) + 8px); }

/* ---------- generic ---------- */
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--gap); animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.grow { flex: 1; min-height: 0; }
.row { display: flex; align-items: center; gap: var(--gap); }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: .8em; }
h1, h2, h3 { margin: 0; line-height: 1.1; font-weight: 800; }
h1 { font-size: clamp(30px, 7vmin, 64px); letter-spacing: .5px; }
h2 { font-size: clamp(20px, 4vmin, 34px); }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; min-height: 52px; min-width: 52px; padding: .45em 1.1em;
  border-radius: 999px; font-weight: 800; color: #1c1940; background: linear-gradient(#fff, #d9dcff); box-shadow: 0 5px 0 #8f8ad6, 0 8px 18px #0006;
  transition: transform .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #8f8ad6, 0 4px 10px #0006; }
.btn.big { font-size: 1.25em; min-height: 64px; padding: .5em 1.6em; }
.btn.go { background: linear-gradient(#7cf29a, #2fbf5a); box-shadow: 0 5px 0 #1b7d3a, 0 8px 18px #0006; }
.btn.gold { background: linear-gradient(#ffe7a3, #e9c46a); box-shadow: 0 5px 0 #9b7a2b, 0 8px 18px #0006; }
.btn.ghost { background: #ffffff1a; color: var(--ink); box-shadow: none; border: 2px solid #ffffff33; }
.btn[disabled] { opacity: .45; filter: grayscale(.6); pointer-events: none; }
.icon-btn { width: 52px; height: 52px; padding: 0; border-radius: 50%; font-size: 24px; background: #ffffff1a; border: 2px solid #ffffff2a; color: var(--ink); box-shadow: none; }

/* ---------- HUD ---------- */
.hud { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; min-height: 52px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px 3px 4px; border-radius: 999px; background: #0008; border: 1px solid #ffffff22;
  font-weight: 800; font-size: .9em; white-space: nowrap; }
.chip img { width: 28px; height: 28px; border-radius: 7px; }
.chip .dot { width: 22px; height: 22px; border-radius: 50%; display: inline-block; margin-left: 3px; }
.hud .spacer { flex: 1; }
@media (max-width: 560px) { .hud .label-hide { display: none; } .chip img { width: 24px; height: 24px; } }
@keyframes pop { 30% { transform: scale(1.12); } 100% { transform: scale(0); opacity: 0; } }
.spark { position: fixed; z-index: 49; width: 8px; height: 8px; border-radius: 2px; pointer-events: none; }
.modal-bg { position: fixed; inset: 0; z-index: 60; background: #05041599; display: grid; place-items: center; padding: 16px; animation: fadein .2s; }
.modal { width: min(560px, 100%); max-height: 100%; overflow: auto; background: linear-gradient(#2b2470, #1a1650); border: 2px solid #ffffff2a; border-radius: 24px; padding: 18px; text-align: center;
  display: flex; flex-direction: column; gap: 12px; align-items: center; box-shadow: 0 20px 60px #000a; }
.bigstars { font-size: clamp(40px, 10vmin, 72px); letter-spacing: 6px; }
.bigstars .off { filter: grayscale(1) brightness(.4); }
.bigstars span { display: inline-block; animation: starin .45s backwards; }
@keyframes starin { from { transform: scale(0) rotate(-90deg); } }
.teach { width: 100%; display: flex; flex-direction: column; gap: 10px; align-items: center; }
#toasts { position: fixed; z-index: 80; left: 50%; top: calc(var(--safe-t) + 64px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #fff; color: var(--card-ink); font-weight: 800; padding: 8px 18px; border-radius: 999px; box-shadow: 0 6px 20px #0008; animation: toast 2.6s forwards; white-space: nowrap; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-10px) scale(.9); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.brand { position: fixed; right: calc(var(--safe-r) + 8px); bottom: calc(var(--safe-b) + 6px); z-index: 3; display: flex; align-items: center; padding: 4px 8px; border-radius: 999px;
  background: #0b0a1fcc; border: 1px solid #ffffff2a; opacity: .9; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); transition: opacity .2s, transform .2s; }
.brand:hover { opacity: 1; transform: scale(1.04); }
.brand img { height: 20px; display: block; }
.hud-title { font-size: clamp(15px, 2.6vmin, 22px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; display: flex; flex-direction: column; line-height: 1.1; }
.hud-title small { font-size: .7em; color: var(--muted); font-weight: 600; }
@media (max-width: 560px) { .hud-title { display: none; } }
.cuby-mini { height: clamp(64px, 12vmin, 110px); flex: none; filter: drop-shadow(0 6px 10px #0008); transition: transform .2s; }
.cuby-modal { height: clamp(110px, 20vmin, 170px); filter: drop-shadow(0 8px 14px #0009); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-10px) scale(.9); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.confetti { position: fixed; top: 0; z-index: 90; pointer-events: none; border-radius: 2px; }
.btn.danger { background: linear-gradient(#ff9a8a, #e94f4f); color: #fff; box-shadow: 0 5px 0 #9b2a2a, 0 8px 18px #0006; }
[hidden] { display: none !important; }
