/* AA Accounting – shared design tokens + components (mobile-first) */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Sinhala:wght@400;600;800&family=Poppins:wght@400;600;800&display=swap');

:root {
  --bg: #071428;
  --bg-2: #0c1f3d;
  --surface: #12284c;
  --surface-2: #1a3561;
  --line: rgba(255, 255, 255, .10);
  --text: #eef3fb;
  --muted: #9fb2cf;
  --brand: #ffb703;      /* AA gold */
  --brand-ink: #1b1300;
  --accent: #22c1c3;     /* teal */
  --good: #2ecc71;
  --bad: #ff5d5d;
  --warn: #ffb020;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: 'Poppins', 'Noto Sans Sinhala', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
html[data-lang="si"] { --font: 'Noto Sans Sinhala', 'Poppins', system-ui, sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 80% -10%, #1b3d73 0%, transparent 60%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
img, canvas { max-width: 100%; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: rgba(7, 20, 40, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .logo {
  display: flex; align-items: center; gap: 8px;
  color: var(--text); text-decoration: none; font-weight: 800; white-space: nowrap;
}
.topbar .logo .mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #fb8500); color: var(--brand-ink); font-weight: 800;
}
.topbar .title { font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.topbar .spacer { flex: 1; }
.who { font-size: .85rem; color: var(--muted); cursor: pointer; white-space: nowrap; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; }

/* Language toggle */
.lang-toggle { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; flex-shrink: 0; }
.lang-toggle button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-family: 'Noto Sans Sinhala', 'Poppins', 'Iskoola Pota', 'Nirmala UI', sans-serif; font-size: .85rem; font-weight: 600;
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
}
.lang-toggle button.active { background: var(--brand); color: var(--brand-ink); }

/* Sound toggle (sits before the language toggle) */
.sound-toggle {
  flex-shrink: 0; width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-size: 1rem; line-height: 1; cursor: pointer;
}
.sound-toggle:hover { border-color: var(--brand); }
.sound-toggle[aria-pressed="false"] { opacity: .65; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 12px 22px; font: inherit; font-weight: 700;
  cursor: pointer; text-decoration: none; transition: transform .1s ease, filter .2s;
  background: var(--brand); color: var(--brand-ink);
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.good { background: var(--good); color: #052b14; }
.btn.bad { background: var(--bad); color: #2b0505; }
.btn.wa { background: #25d366; color: #04210f; }
.btn.fb { background: #1877f2; color: #fff; }
.btn.sm { padding: 7px 14px; font-size: .85rem; }
.btn.block { width: 100%; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
@media (min-width: 720px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.pill.brand { background: rgba(255, 183, 3, .15); color: var(--brand); }
.pill.good { background: rgba(46, 204, 113, .15); color: var(--good); }
.pill.bad { background: rgba(255, 93, 93, .15); color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }

/* Forms */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { min-height: 90px; resize: vertical; }

/* Tables / leaderboard */
.lb { width: 100%; border-collapse: collapse; }
.lb th, .lb td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); }
.lb th { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.lb tr.me td { background: rgba(255, 183, 3, .10); }
.lb .medal { font-size: 1.2rem; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }

/* Tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px; background: var(--surface); border-radius: 999px; border: 1px solid var(--line); scrollbar-width: none; }
.tabs button { flex: 1 0 auto; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.tabs button.active { background: var(--surface-2); color: var(--text); }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; z-index: 200; padding: 16px; animation: fade .2s ease; }
.modal { width: 100%; max-width: 440px; max-height: 90vh; overflow: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); animation: pop .25s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }

/* Toast */
.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); animation: pop .25s ease; font-weight: 600; }
.toast.good { background: var(--good); color: #052b14; }
.toast.bad { background: var(--bad); color: #2b0505; }

/* Badge chips */
.badges { display: flex; flex-wrap: wrap; gap: 10px; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 86px; text-align: center; font-size: .72rem; color: var(--muted); }
.badge .ico { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; background: var(--surface-2); border: 2px solid var(--line); filter: grayscale(1); opacity: .45; }
.badge.earned .ico { filter: none; opacity: 1; border-color: var(--brand); box-shadow: 0 0 18px rgba(255, 183, 3, .35); }
.badge.earned { color: var(--text); }

.footer-note { text-align: center; color: var(--muted); font-size: .78rem; padding: 24px 16px 40px; }

/* Small 3D diorama panels inside card games (shared/scene3d.js) */
.scene3d { position: relative; height: 230px; margin-top: 16px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--bg-2); box-shadow: var(--shadow); }
@media (min-width: 760px) { .scene3d { height: 300px; } }
.scene3d[hidden] { display: none; }
.scene3d-canvas { display: block; width: 100%; height: 100%; }

/* Confetti canvas */
#aa-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 250; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---- A/L syllabus tags (shared/syllabus.js) ---- */
.syl-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; margin: 2px 4px 2px 0; border-radius: 999px; font-size: .72rem; font-weight: 600; line-height: 1.5; background: rgba(34, 193, 195, .14); color: #8fecee; border: 1px solid rgba(34, 193, 195, .28); white-space: normal; text-align: left; cursor: help; }
.syl-row { display: flex; flex-wrap: wrap; gap: 2px; margin: 6px 0 0; }
