/* Phonics flashcards look: plain and blocky, for grades 2–3. Stone-grey panels with hard bevelled edges on a dark
   dirt background, square corners everywhere, and one green accent for progress.
   Jersey 15 (a pixel font whose digits stay readable) for the UI; Andika (made for new readers, with a clear a and g) for everything a child reads on a card. */
:root {
  --dirt: #2b2520; --panel: #c6c6c6; --panel-hi: #f4f4f4; --panel-lo: #5a5a5a; --slot: #8b8b8b; --slot-lo: #373737;
  --ink: #1e1e1e; --soft: #4a4a4a; --paper: #f1ead9; --paper-lo: #b9ad90; --white: #fff;
  --btn: #7b7b7b; --btn-hi: #a9a9a9; --btn-lo: #4e4e4e; --go: #4c8a3a; --go-hi: #72b55c; --go-lo: #2f5a23; --no: #8a6a3a; --no-hi: #b08d57; --no-lo: #5c4522;
  --xp: #80d83a; --mark: #b3261e;
  --t0: #6b6b6b; --t1: #9c7446; --t2: #8f8f8f; --t3: #e3e3e3; --t4: #f2c63b; --t5: #4fd8d0;
  --f-ui: "Jersey 15", "Trebuchet MS", system-ui, sans-serif;
  --f-read: "Andika", "Trebuchet MS", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; min-height: 100vh; color: var(--white); font-family: var(--f-ui); font-size: 18px; line-height: 1.35;
  background-color: var(--dirt);
  /* a 16-pixel dirt tile, drawn large and darkened */
  background-image: linear-gradient(rgba(20, 16, 13, .62), rgba(20, 16, 13, .62)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Crect width='16' height='16' fill='%23866043'/%3E%3Cg fill='%23795438'%3E%3Crect x='1' y='1' width='2' height='1'/%3E%3Crect x='6' y='3' width='3' height='1'/%3E%3Crect x='12' y='2' width='2' height='2'/%3E%3Crect x='3' y='7' width='2' height='2'/%3E%3Crect x='9' y='9' width='3' height='1'/%3E%3Crect x='14' y='11' width='2' height='1'/%3E%3Crect x='1' y='13' width='3' height='1'/%3E%3Crect x='7' y='14' width='2' height='1'/%3E%3C/g%3E%3Cg fill='%23997150'%3E%3Crect x='4' y='2' width='1' height='1'/%3E%3Crect x='10' y='5' width='2' height='1'/%3E%3Crect x='0' y='9' width='1' height='2'/%3E%3Crect x='6' y='11' width='2' height='1'/%3E%3Crect x='12' y='14' width='1' height='1'/%3E%3C/g%3E%3Cg fill='%235f4630'%3E%3Crect x='8' y='0' width='1' height='1'/%3E%3Crect x='2' y='4' width='1' height='1'/%3E%3Crect x='14' y='7' width='1' height='1'/%3E%3Crect x='5' y='12' width='1' height='1'/%3E%3Crect x='11' y='12' width='1' height='1'/%3E%3C/g%3E%3C/svg%3E");
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
#app { max-width: 920px; margin: 0 auto; padding: 16px 14px 56px; }
h1, h2, h3, p { margin: 0; }
.shadow { text-shadow: 2px 2px 0 rgba(0, 0, 0, .55); }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.top .ttl { font-weight: 400; font-size: 26px; letter-spacing: .02em; text-shadow: 2px 2px 0 rgba(0, 0, 0, .55); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .sp { flex: 1; }

/* ---------- buttons: a grey block with a light top-left edge and a dark bottom-right edge ---------- */
.btn {
  --b: var(--btn); --hi: var(--btn-hi); --lo: var(--btn-lo);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px;
  background: var(--b); color: var(--white); border: 2px solid #000; border-radius: 0; text-decoration: none;
  font-family: var(--f-ui); font-weight: 400; font-size: 22px; letter-spacing: .03em; text-shadow: 2px 2px 0 rgba(0, 0, 0, .5);
  box-shadow: inset 2px 2px 0 var(--hi), inset -2px -4px 0 var(--lo);
}
.btn:hover, .btn:focus-visible { outline: 2px solid var(--white); outline-offset: 0; filter: brightness(1.12); }
.btn:active { box-shadow: inset 2px 4px 0 var(--lo), inset -2px -2px 0 var(--hi); padding-top: 10px; padding-bottom: 6px; }
.btn[disabled] { filter: grayscale(1) brightness(.7); cursor: default; outline: none; }
.btn.go { --b: var(--go); --hi: var(--go-hi); --lo: var(--go-lo); }
.btn.no { --b: var(--no); --hi: var(--no-hi); --lo: var(--no-lo); }
.btn.big { min-height: 56px; font-size: 27px; padding: 10px 22px; }
.btn { white-space: nowrap; }
.btn.sq { width: 44px; padding: 0; font-size: 20px; }
.btn.on { --b: #5d6f8f; --hi: #8496b6; --lo: #3b4860; }
.btn kbd { font: inherit; font-size: 13px; opacity: .75; border: 1px solid rgba(255, 255, 255, .5); padding: 0 5px; text-shadow: none; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.mid { justify-content: center; }

/* ---------- panels ---------- */
.panel { background: var(--panel); color: var(--ink); border: 2px solid #000; padding: 16px; box-shadow: inset 3px 3px 0 var(--panel-hi), inset -3px -3px 0 var(--panel-lo); }
.panel + .panel, .panel + .group, .group + .panel { margin-top: 16px; }
.panel h2 { font-size: 26px; font-weight: 400; }
.panel p { color: var(--soft); }
.hero h1 { font-size: clamp(36px, 8vw, 54px); font-weight: 400; line-height: 1.05; letter-spacing: .02em; }
.hero p { margin-top: 6px; font-family: var(--f-read); font-size: 17px; }

/* level and XP */
.xp { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.xp b { font-size: 24px; font-weight: 400; white-space: nowrap; }
.bar { flex: 1; height: 16px; background: var(--slot-lo); border: 2px solid #000; position: relative; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--xp); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .35), inset 0 -3px 0 rgba(0, 0, 0, .25); }
.xp small { font-size: 14px; color: var(--soft); white-space: nowrap; }

/* tier counts: one small block per tier */
.tiers { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 15px; color: var(--soft); }
.tiers span { display: inline-flex; align-items: center; gap: 6px; }
.pip { display: inline-block; width: 14px; height: 14px; border: 2px solid #000; background: var(--t0); box-shadow: inset 2px 2px 0 rgba(255, 255, 255, .35), inset -2px -2px 0 rgba(0, 0, 0, .3); flex: none; }
.pip.t1 { background: var(--t1); } .pip.t2 { background: var(--t2); } .pip.t3 { background: var(--t3); } .pip.t4 { background: var(--t4); } .pip.t5 { background: var(--t5); }

/* ---------- deck list ---------- */
.group { margin-top: 22px; }
.group > h2 { font-size: 26px; font-weight: 400; letter-spacing: .04em; text-shadow: 2px 2px 0 rgba(0, 0, 0, .55); margin-bottom: 10px; }
.group > h2 small { font-weight: 400; font-size: 15px; opacity: .8; margin-left: 8px; }
.decks { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.deck { display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: start; text-align: left; text-decoration: none;
  background: var(--panel); color: var(--ink); border: 2px solid #000; padding: 12px; box-shadow: inset 3px 3px 0 var(--panel-hi), inset -3px -3px 0 var(--panel-lo); }
.deck:hover, .deck:focus-visible { outline: 3px solid var(--white); outline-offset: 0; }
.deck h3 { font-size: 26px; font-weight: 400; line-height: 1.1; }
.deck p { font-family: var(--f-read); font-size: 14px; color: var(--soft); line-height: 1.3; margin-top: 3px; }
.deck .count { font-size: 14px; color: var(--soft); margin-top: 8px; display: flex; justify-content: space-between; gap: 8px; }
/* a block: lighter top face, darker side, a row of "teeth" where they meet */
.block { width: 52px; height: 52px; border: 2px solid #000; background:
  linear-gradient(90deg, var(--top) 50%, transparent 50%) 0 16px / 8px 4px repeat-x,
  linear-gradient(var(--top) 0 16px, var(--side) 16px);
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, .28), inset -3px -3px 0 rgba(0, 0, 0, .3); }
/* progress through a deck: one stripe per tier */
.meter { display: flex; height: 10px; margin-top: 6px; background: var(--slot-lo); border: 2px solid #000; }
.meter i { display: block; height: 100%; }
.meter .t1 { background: var(--t1); } .meter .t2 { background: var(--t2); } .meter .t3 { background: var(--t3); } .meter .t4 { background: var(--t4); } .meter .t5 { background: var(--t5); }

/* ---------- deck page ---------- */
.deck-head { display: grid; grid-template-columns: 52px 1fr; gap: 14px; align-items: start; }
.deck-head h1 { font-size: clamp(32px, 7vw, 44px); font-weight: 400; line-height: 1.05; }
.deck-head p { font-family: var(--f-read); margin-top: 4px; }
.opts { margin-top: 14px; }
.opts .lbl { font-size: 15px; color: var(--soft); }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin-top: 12px; }
.slot { text-decoration: none; min-height: 58px; padding: 6px 4px; display: flex; align-items: center; justify-content: center; text-align: center; position: relative;
  background: var(--slot); color: var(--white); border: 0; border-radius: 0; font-family: var(--f-read); font-weight: 700; font-size: 17px; line-height: 1.1;
  box-shadow: inset 2px 2px 0 var(--slot-lo), inset -2px -2px 0 var(--panel-hi); text-shadow: 1px 1px 0 rgba(0, 0, 0, .6); overflow-wrap: anywhere; }
.slot.long { font-size: 12.5px; font-weight: 400; }
.slot:hover, .slot:focus-visible { outline: 3px solid var(--white); outline-offset: -3px; }
.slot .pip { position: absolute; top: 4px; right: 4px; width: 10px; height: 10px; border-width: 1px; box-shadow: none; }

/* ---------- studying ---------- */
.study { max-width: 640px; margin: 0 auto; }
.prog { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 16px; text-shadow: 2px 2px 0 rgba(0, 0, 0, .55); }
.card { width: 100%; min-height: min(56vh, 400px); display: flex; flex-direction: column; text-align: center; padding: 14px 16px 16px; position: relative;
  background: var(--paper); color: var(--ink); border: 3px solid #000; border-radius: 0; font-family: var(--f-read); cursor: pointer;
  box-shadow: inset 4px 4px 0 #fffaf0, inset -4px -4px 0 var(--paper-lo), 6px 6px 0 rgba(0, 0, 0, .45); }
.card:focus-visible { outline: 3px solid var(--white); outline-offset: 2px; }
.card.turn { animation: turn .22s steps(4); }
@keyframes turn { 0% { transform: scaleX(1); } 50% { transform: scaleX(.05); } 100% { transform: scaleX(1); } }
.card .tag { display: flex; justify-content: space-between; gap: 10px; font-family: var(--f-ui); font-size: 14px; color: #6d6450; letter-spacing: .04em; text-transform: uppercase; }
.card .tag .pip { vertical-align: -2px; margin-right: 5px; }
.card .face { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 12px 0; }
.card .ask { font-family: var(--f-ui); font-size: 23px; color: #6d6450; }
.card .front { font-weight: 700; line-height: 1.05; font-size: clamp(64px, 22vw, 128px); overflow-wrap: anywhere; }
.card .front.s2 { font-size: clamp(44px, 13vw, 80px); }
.card .front.s3 { font-size: clamp(28px, 7.5vw, 44px); line-height: 1.2; }
.card .front.s4 { font-size: clamp(22px, 5.5vw, 30px); line-height: 1.3; }
.card .hint { font-family: var(--f-ui); font-size: 16px; color: #6d6450; }
.card .how-many { margin-top: 6px; font-size: 15px; background: var(--ink); color: var(--paper); padding: 2px 10px; }
/* the answer side */
.card .back { flex: 1; display: flex; flex-direction: column; gap: 12px; padding-top: 8px; text-align: left; cursor: default; }
.card .mini { font-weight: 700; font-size: clamp(26px, 7vw, 38px); line-height: 1.1; text-align: center; overflow-wrap: anywhere; }
.card .mini.s3, .card .mini.s4 { font-size: 20px; }
.snd { border-top: 2px solid var(--paper-lo); padding-top: 10px; }
.snd .a { font-size: 19px; font-weight: 700; line-height: 1.3; display: flex; gap: 8px; align-items: baseline; }
.snd .a .n { flex: none; font-family: var(--f-ui); font-size: 14px; background: var(--ink); color: var(--paper); min-width: 22px; text-align: center; padding: 1px 0; }
.words { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.words.lines { flex-direction: column; align-items: flex-start; }
.w { font-family: var(--f-read); font-size: 22px; line-height: 1.2; padding: 4px 10px; background: #fffaf0; color: var(--ink); border: 2px solid var(--ink); border-radius: 0; text-align: left; }
.w b { color: var(--mark); }
.w.say:hover, .w.say:focus-visible { background: var(--ink); color: var(--paper); outline: none; }
.w.say:hover b, .w.say:focus-visible b { color: #ffb4a8; }
.w.now { background: var(--ink); color: var(--paper); } .w.now b { color: #ffb4a8; }
.words.lines .w { font-size: 19px; }
.note { font-size: 17px; line-height: 1.4; padding: 8px 10px; background: #e4dcc6; border-left: 6px solid var(--go); }
.note.x { border-left-color: var(--mark); }
.note strong { font-family: var(--f-ui); font-weight: 400; font-size: 17px; letter-spacing: .05em; text-transform: uppercase; display: block; color: #5a5240; }
.actions { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions.one { grid-template-columns: 1fr; }
.actions.three { grid-template-columns: 1fr auto 1fr; }
.keys { margin-top: 10px; text-align: center; font-size: 14px; opacity: .7; }
@media (hover: none) { .keys { display: none; } }

/* ---------- end of a round ---------- */
.done { text-align: center; }
.done h1 { font-size: clamp(36px, 8vw, 52px); font-weight: 400; }
.done .big-n { font-size: 68px; font-weight: 400; line-height: 1; margin: 12px 0 2px; }
.done .levelup { margin: 12px auto 0; display: inline-block; background: var(--ink); color: var(--xp); padding: 4px 14px; font-size: 22px; }
.done .again { margin-top: 14px; text-align: left; }
.done .row { margin-top: 16px; }

details.panel summary { cursor: pointer; font-size: 22px; }
details.panel p, details.panel li { font-family: var(--f-read); font-size: 16px; color: var(--soft); line-height: 1.5; }
details.panel p { margin-top: 10px; }
details.panel ul { margin: 8px 0 0; padding-left: 20px; }
@media (max-width: 520px) { #app { padding: 12px 10px 48px; } .w { font-size: 20px; } .btn.big { font-size: 22px; padding: 10px 10px; } }
@media (prefers-reduced-motion: reduce) { .card.turn { animation: none; } }
/* The pixel font's small digits are hard to tell apart (5 and S, 2 and 8), so small print and counts use the reading font. */
.snd .a .n, .card .how-many, .count, .tiers, .xp small, .prog, .keys, .lbl, .card .tag, .card .hint, .done p, .group > h2 small, .btn kbd { font-family: var(--f-read); letter-spacing: 0; }
