/* ============================================================
   LoomLearn — the one account behind every learning game.
   Calm warm paper, ink type, Fraunces display. Colour lives in
   ONE place: the woven tapestry of every game's own colour.
   Clear product, not a craft fair.
   ============================================================ */
:root {
  color-scheme: light;
  --bg:     #f7f0e0;
  --bg-2:   #efe4cd;
  --card:   #fffdf7;
  --ink:    #2a2620;
  --ink-2:  #5f5648;
  --muted:  #94866f;
  --line:   #e7dbc1;
  --line-2: #d9c8a6;
  --accent: #3c4f9e;   /* one restrained accent — deep indigo */

  /* each game's identity colour (used only in the loom + tiny dots) */
  --hist: #c99a33; --geo: #35779e; --econ: #4e9a5d; --sci: #3fa7bd;
  --math: #4f5fb0; --eng: #b8563c; --phil: #875eb0;

  --good: #4e9a5d; --bad: #b8563c;
  --radius: 16px; --radius-sm: 11px;
  --shadow: 0 12px 30px rgba(90,60,20,.10);
  --shadow-sm: 0 4px 14px rgba(90,60,20,.08);
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --maxw: 1040px; --fs: 17px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: var(--fs); line-height: 1.6; -webkit-font-smoothing: antialiased; min-height: 100dvh; }
a { color: var(--accent); text-underline-offset: 3px; }
h1,h2,h3 { font-family: var(--display); font-weight: 800; line-height: 1.08; margin: 0; color: var(--ink); letter-spacing: -.01em; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: #e7d9b4; color: var(--ink); }
.skip-link { position: absolute; left: -9999px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { left: 8px; top: 8px; z-index: 99; }

/* ---- App bar ---- */
.appbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px clamp(16px,5vw,32px); background: rgba(247,240,224,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-glyph { display: inline-flex; color: var(--accent); }
.brand-glyph svg { width: 25px; height: 25px; display: block; }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 21px; letter-spacing: -.02em; }
.brand-name .thin { color: var(--accent); }
.appbar-actions { display: flex; align-items: center; gap: 16px; }
.appbar-actions a:not(.btn) { color: var(--ink); text-decoration: none; font-weight: 600; }
.appbar-actions a:not(.btn):hover { color: var(--accent); }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid var(--line-2);
  background: var(--card); color: var(--ink); padding: 12px 22px; border-radius: 11px; font-weight: 700; font-size: 15.5px; text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fbf5e8; }
.btn-primary:hover { background: #40382d; border-color: #40382d; color: #fbf5e8; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; } .btn-lg { padding: 15px 26px; font-size: 16.5px; }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-danger:hover { background: var(--bad); color: #fff; }

/* ============================================================
   LANDING
   ============================================================ */
.hero { max-width: var(--maxw); margin: 0 auto; padding: clamp(34px,7vw,68px) clamp(20px,5vw,28px) 20px;
  display: grid; gap: clamp(28px,5vw,52px); align-items: center; }
@media (min-width: 840px) { .hero { grid-template-columns: 1.05fr .95fr; } }
.hero-copy .eyebrow { display: inline-block; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: 13px; color: var(--accent); margin-bottom: 16px; }
.hero-copy h1 { font-size: clamp(38px,6.6vw,60px); }
.hero-copy .lede { max-width: 40ch; margin: 20px 0 0; color: var(--ink-2); font-size: clamp(17px,2.4vw,20px); }
.hero-copy .cta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 28px; }
.hero-art { display: flex; justify-content: center; }
.loom-art { width: 100%; max-width: 440px; border-radius: 14px; box-shadow: var(--shadow); background: var(--card); padding: 14px; border: 1px solid var(--line); }
.loom-art img { display: block; width: 100%; border-radius: 6px; }
.loom-cap { text-align: center; font-size: 13px; color: var(--muted); margin-top: 10px; font-weight: 600; }

/* how it works */
.how-wrap { max-width: var(--maxw); margin: 0 auto; padding: clamp(24px,5vw,48px) clamp(20px,5vw,28px); }
.section-head { text-align: center; margin-bottom: 30px; }
.section-head h2 { font-size: clamp(26px,4.5vw,38px); }
.section-head p { color: var(--ink-2); margin: 8px auto 0; max-width: 52ch; }
.how { display: grid; gap: 22px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .how { grid-template-columns: repeat(3,1fr); } }
.how-step { padding: 4px 4px 4px 0; }
.how-step .n { font-family: var(--display); font-weight: 900; font-size: 30px; color: var(--accent); line-height: 1; }
.how-step h3 { font-size: 20px; margin: 10px 0 6px; }
.how-step p { margin: 0; color: var(--ink-2); font-size: 15.5px; }

/* every game — clean list, colour only as a small woven dot */
.games-wrap { max-width: var(--maxw); margin: 0 auto; padding: clamp(10px,3vw,28px) clamp(20px,5vw,28px) 60px; }
.games { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill,minmax(300px,1fr)); }
.game { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow-sm); transition: transform .12s, border-color .12s; }
.game:hover { transform: translateY(-2px); border-color: var(--dot); }
.game .dot { width: 14px; height: 14px; border-radius: 4px; background: var(--dot); flex: none; }
.game .g-nm { font-family: var(--display); font-weight: 700; font-size: 17px; }
.game .g-desc { color: var(--muted); font-size: 13.5px; }
.game .g-go { margin-left: auto; color: var(--muted); font-weight: 700; }

.foot { text-align: center; padding: 24px 20px 40px; color: var(--muted); font-weight: 600; font-size: 14px; }
.foot a { color: var(--ink-2); }

/* ---- game launcher (front page) ---- */
.launch { max-width: 820px; margin: 0 auto; padding: clamp(30px,6vw,58px) clamp(20px,5vw,28px) 6px; text-align: center; }
.launch .eyebrow { display: inline-block; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: 13px; color: var(--accent); margin-bottom: 14px; }
.launch h1 { font-size: clamp(38px,7vw,62px); }
.launch .lede { max-width: 44ch; margin: 16px auto 0; color: var(--ink-2); font-size: clamp(16px,2.4vw,19px); }
.launch .cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.game-grid { max-width: var(--maxw); margin: 0 auto; padding: clamp(26px,4vw,42px) clamp(20px,5vw,28px) 30px; display: grid; gap: 18px; grid-template-columns: repeat(auto-fill,minmax(300px,1fr)); }
.gcard { --c: var(--hist); display: flex; flex-direction: column; text-decoration: none; color: var(--ink);
  background: color-mix(in srgb, var(--c) 9%, var(--card)); border: 2px solid color-mix(in srgb, var(--c) 34%, var(--line));
  border-radius: 20px; padding: 20px; box-shadow: var(--shadow-sm); transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease; }
.gcard:hover { transform: translateY(-4px); border-color: var(--c); box-shadow: 0 18px 34px color-mix(in srgb, var(--c) 26%, transparent); }
.gcard-top { display: flex; align-items: center; gap: 14px; }
.gcard .logo { width: 62px; height: 62px; border-radius: 16px; flex: none; box-shadow: 0 4px 12px rgba(0,0,0,.22); background: #111; }
.gcard h3 { font-size: 23px; }
.gcard .subj { font-weight: 800; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--c); margin-bottom: 2px; }
.gcard .tag { color: var(--ink-2); font-size: 15px; margin: 13px 0 0; flex: 1; line-height: 1.45; }
.gcard .play { margin-top: 16px; align-self: flex-start; display: inline-flex; align-items: center; gap: 7px; background: var(--ink); color: #fbf5e8; font-weight: 800; padding: 9px 18px; border-radius: 999px; font-size: 14px; }
.gcard:hover .play { transform: translateX(2px); }

/* ============================================================
   AUTH + DASHBOARD
   ============================================================ */
.auth-wrap { max-width: 500px; margin: 0 auto; padding: clamp(22px,5vw,44px) 18px 52px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(22px,5vw,34px); }
.card + .card { margin-top: 16px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head h1 { font-size: clamp(28px,6vw,38px); }
.auth-head p { color: var(--ink-2); margin: 8px 0 0; }

.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 700; font-size: 14.5px; color: var(--ink); margin-bottom: 6px; }
.field .hint { font-size: 13.5px; color: var(--muted); margin-top: 6px; }
input[type=text],input[type=email],input[type=password],input[type=date],select,textarea {
  width: 100%; background: #fffdf7; color: var(--ink); border: 1.5px solid var(--line-2); border-radius: 10px; padding: 12px 14px; font-family: inherit; font-size: 16px; }
input:focus,select:focus,textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(60,79,158,.16); }
input::placeholder { color: var(--muted); }
.mono { font-family: ui-monospace,Menlo,Consolas,monospace; letter-spacing: .08em; }
select option { background: #fffdf7; color: var(--ink); }

.pillset { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line-2); background: var(--card); color: var(--ink-2); padding: 8px 14px; border-radius: 999px; font-size: 14.5px; font-weight: 600; }
.pill input { position: absolute; opacity: 0; width: 0; height: 0; }
.pill:hover { border-color: var(--accent); }
.pill.on { border-color: var(--accent); background: var(--accent); color: #fff; }

.choices { display: grid; gap: 12px; }
@media (min-width: 480px) { .choices.two { grid-template-columns: 1fr 1fr; } }
.choice { text-align: left; border: 1.5px solid var(--line); background: var(--card); border-radius: var(--radius); padding: 18px; display: flex; gap: 14px; align-items: flex-start; box-shadow: var(--shadow-sm); transition: transform .12s, border-color .12s; }
.choice:hover { transform: translateY(-2px); border-color: var(--accent); }
.choice .ico { font-family: var(--display); font-weight: 900; font-size: 28px; color: var(--accent); width: 34px; text-align: center; line-height: 1; }
.choice h3 { font-size: 20px; }
.choice p { margin: 3px 0 0; color: var(--ink-2); font-size: 14.5px; }

.steps { display: flex; align-items: center; justify-content: center; gap: 9px; margin-bottom: 20px; }
.steps .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); }
.steps .dot.on { background: var(--accent); }
.steps .dot.done { background: var(--good); }
.step { display: none; } .step.active { display: block; }

.qr-box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; width: max-content; margin: 0 auto 14px; box-shadow: var(--shadow-sm); }
.qr-box svg { display: block; width: 200px; height: 200px; }
.secret { text-align: center; font-family: ui-monospace,Menlo,Consolas,monospace; letter-spacing: .14em; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px; word-break: break-all; font-size: 14px; color: var(--accent); font-weight: 600; }
.backup-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-family: ui-monospace,Menlo,Consolas,monospace; font-size: 14px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 14px; }
.otp-input { text-align: center; font-size: 26px; letter-spacing: .5em; font-family: ui-monospace,Menlo,Consolas,monospace; }

.alert { border-radius: 10px; padding: 11px 14px; font-size: 14.5px; margin-bottom: 14px; border: 1px solid; }
.alert.err { color: #7c2e1f; background: #f7e6e0; border-color: color-mix(in srgb,var(--bad) 40%,var(--line)); }
.alert.ok  { color: #2c5330; background: #e6f0e5; border-color: color-mix(in srgb,var(--good) 40%,var(--line)); }
.alert.info{ color: #2c3a72; background: #e8ebf6; border-color: color-mix(in srgb,var(--accent) 34%,var(--line)); }
.hidden { display: none !important; }
.muted { color: var(--muted); } .center { text-align: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt { margin-top: 16px; } .sm { font-size: 14px; }
.validity { font-size: 14px; margin-top: 7px; min-height: 18px; font-weight: 600; }
.validity.ok { color: var(--good); } .validity.bad { color: var(--bad); }

/* Dashboard */
.dash { max-width: var(--maxw); margin: 0 auto; padding: clamp(20px,5vw,40px) clamp(16px,5vw,28px) 60px; }
.dash-head { margin-bottom: 22px; }
.dash-head h1 { font-size: clamp(30px,5vw,44px); }
.dash-head .sub { color: var(--ink-2); margin-top: 4px; }
.stat-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat .num { font-family: var(--display); font-weight: 900; font-size: 40px; line-height: 1; color: var(--accent); }
.stat .lbl { color: var(--ink-2); font-weight: 700; font-size: 13.5px; text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(18px,4vw,24px); margin-bottom: 18px; box-shadow: var(--shadow-sm); }
.panel h2 { font-size: 24px; margin-bottom: 12px; }
.badge { display: inline-block; font-weight: 700; font-size: 12px; letter-spacing: .03em; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb,var(--accent) 14%,var(--card)); color: var(--accent); border: 1px solid color-mix(in srgb,var(--accent) 32%,var(--line)); }
.badge.gold { background: color-mix(in srgb,var(--hist) 16%,var(--card)); color: #8a5f14; border-color: color-mix(in srgb,var(--hist) 42%,var(--line)); }
table.grid-table { width: 100%; border-collapse: collapse; font-size: 16px; }
table.grid-table th, table.grid-table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
table.grid-table th { color: var(--ink-2); font-weight: 700; font-size: 13.5px; text-transform: uppercase; letter-spacing: .04em; }
.code-chip { font-family: ui-monospace,Menlo,Consolas,monospace; letter-spacing: .1em; background: var(--bg-2); border: 1px solid var(--line-2); padding: 3px 10px; border-radius: 8px; color: var(--accent); font-weight: 700; }
.app-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill,minmax(170px,1fr)); }
.app-tile { --c: var(--hist); display: flex; align-items: center; gap: 11px; padding: 14px 15px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); text-decoration: none; color: var(--ink); transition: transform .12s, border-color .12s; }
.app-tile:hover { transform: translateY(-2px); border-color: var(--c); }
.app-tile:nth-child(1){ --c: var(--hist); } .app-tile:nth-child(2){ --c: var(--geo); }
.app-tile:nth-child(3){ --c: var(--econ); } .app-tile:nth-child(4){ --c: var(--sci); }
.app-tile:nth-child(5){ --c: var(--math); } .app-tile:nth-child(6){ --c: var(--eng); }
.app-tile:nth-child(7){ --c: var(--phil); }
.app-tile .sw { width: 12px; height: 30px; border-radius: 4px; background: var(--c); flex: none; }
.app-tile .nm { font-family: var(--display); font-weight: 700; font-size: 16px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
