@font-face { font-family: "Lora"; src: url("Lora.ttf") format("truetype"); font-display: swap; }
:root {
  --night: #0c1a20; --fog: #15313a; --fog2: #1d404a;
  --gold: #f2c14e; --gold-soft: #f7dc95; --pumpkin: #e8792b; --parch: #f3e7cb; --teal: #2f8f8a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root { color-scheme: dark; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--parch); font-family: "Lora", Georgia, serif; overflow: hidden; }
button { font-family: inherit; cursor: pointer; }
#app { position: fixed; inset: 0; background: radial-gradient(ellipse at 50% 0%, #1f4a55 0%, #0c1a20 70%); }
#app::before { content: ""; position: absolute; inset: 0; background: url("cards/set-summit.jpg") center/cover; opacity: .18; filter: blur(6px); }

.screen { position: absolute; inset: 0; display: none; padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.screen.on { display: flex; }

/* intro */
#intro { background: #000; display: none; align-items: center; justify-content: center; z-index: 30; padding: 0; }
#intro.on { display: flex; }
#intro video { width: 100%; height: 100%; object-fit: contain; }
#intro .skip { position: absolute; bottom: 18px; right: 22px; margin: 0; font-size: 15px; opacity: .6; }

/* cover */
#cover { align-items: center; justify-content: center; text-align: center; }
.cover-inner { max-width: 640px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cover-cat { width: clamp(110px, 26vmin, 200px); aspect-ratio: 1; object-fit: cover; border-radius: 50%; border: 4px solid var(--gold); box-shadow: 0 0 40px rgba(242,193,78,.45); animation: floaty 3.2s ease-in-out infinite; }
h1 { margin: 4px 0 0; color: var(--gold); font-size: clamp(38px, 8.5vmin, 76px); line-height: .98; text-shadow: 0 4px 0 rgba(0,0,0,.45); }
h2 { margin: 0 0 12px; color: var(--gold-soft); font-size: clamp(24px, 4.6vmin, 40px); text-align: center; }
.sub { margin: 4px 0 8px; font-size: clamp(17px, 3vmin, 23px); line-height: 1.4; }
.tiny { font-size: 14px; opacity: .7; margin: 6px 0 0; }
.home { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); color: var(--gold-soft); font-size: 15px; opacity: .8; }

.btn { border: 3px solid var(--gold-soft); border-radius: 999px; color: #fff; font-weight: 700; font-size: clamp(20px, 3.4vmin, 28px); padding: 12px 34px; box-shadow: 0 6px 0 rgba(0,0,0,.35); text-shadow: 0 2px 0 rgba(0,0,0,.35); transition: transform .12s; }
.btn:active { transform: scale(.94); }
.btn.big { font-size: clamp(30px, 6vmin, 48px); padding: 14px 70px; animation: breathe 2.2s ease-in-out infinite; }
.pumpkin { background: var(--pumpkin); }
.night { background: var(--fog2); }

/* menu */
#menu { align-items: center; justify-content: center; overflow-y: auto; }
.menu-inner { width: min(920px, 100%); display: flex; flex-direction: column; align-items: center; gap: 8px; margin: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 18px; }
.chip { background: rgba(12,26,32,.7); border: 2px solid rgba(247,220,149,.45); color: var(--parch); border-radius: 999px; padding: 10px 20px; font-size: clamp(16px, 2.8vmin, 21px); }
.chip.on { background: var(--teal); border-color: var(--gold); color: #fff; box-shadow: 0 0 18px rgba(242,193,78,.4); }
.sizes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 42vw), 1fr)); gap: 14px; width: 100%; }
.size { background: linear-gradient(180deg, var(--fog2), var(--fog)); border: 3px solid rgba(247,220,149,.55); border-radius: 22px; padding: 16px 10px 14px; color: var(--parch); display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform .12s; }
.size:active { transform: scale(.95); }
.size b { color: var(--gold); font-size: clamp(22px, 3.8vmin, 30px); }
.size .n { font-size: 16px; }
.size .best { color: var(--gold); letter-spacing: 3px; font-size: 22px; min-height: 26px; }
.size .best i { color: rgba(247,220,149,.25); font-style: normal; }
.size .mini { display: grid; gap: 3px; margin: 6px 0 2px; }
.size .mini span { width: 12px; height: 15px; border-radius: 3px; background: var(--pumpkin); box-shadow: inset 0 0 0 1.5px var(--gold-soft); }
.link { background: none; border: 0; color: var(--gold-soft); font-size: 17px; margin-top: 14px; text-decoration: underline; }

/* game */
#play { flex-direction: column; gap: 8px; }
.bar { display: flex; align-items: center; gap: 8px; min-width: 0; justify-content: space-between; flex-wrap: nowrap; }
.stat { background: rgba(12,26,32,.6); border-radius: 999px; padding: 6px 14px; font-size: clamp(15px, 2.6vmin, 20px); white-space: nowrap; }
.stat b { color: var(--gold); }
.pill { background: rgba(12,26,32,.75); border: 2px solid rgba(247,220,149,.5); color: var(--gold-soft); border-radius: 999px; padding: 7px 16px; font-size: clamp(14px, 2.4vmin, 18px); white-space: nowrap; }
#board { flex: 1; display: grid; gap: var(--gap, 10px); justify-content: center; align-content: center; min-height: 0; }
.praise { text-align: center; margin: 0; min-height: 1.4em; color: var(--gold-soft); font-size: clamp(18px, 3.2vmin, 26px); font-weight: 700; text-shadow: 0 2px 0 rgba(0,0,0,.5); }

.card { width: var(--cw); height: var(--ch); perspective: 900px; background: none; border: 0; padding: 0; }
.card .in { position: relative; display: block; width: 100%; height: 100%; transition: transform .45s cubic-bezier(.3,1.4,.5,1); transform-style: preserve-3d; }
.card.up .in, .card.done .in { transform: rotateY(180deg); }
.card .f { position: absolute; inset: 0; border-radius: calc(var(--cw) * .1); backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; box-shadow: 0 5px 12px rgba(0,0,0,.45); }
.card .back { background:
    radial-gradient(circle at 50% 46%, rgba(242,193,78,.55) 0 14%, transparent 15%),
    radial-gradient(circle at 50% 50%, #1f5560, #10303a 75%);
  border: 3px solid var(--gold); display: flex; align-items: center; justify-content: center; }
.card .back::after { content: "★"; color: var(--gold-soft); font-size: calc(var(--cw) * .32); text-shadow: 0 0 12px rgba(242,193,78,.9); }
.card .back::before { content: ""; position: absolute; inset: 6%; border: 2px dashed rgba(247,220,149,.35); border-radius: calc(var(--cw) * .07); }
.card .face { transform: rotateY(180deg); background: var(--parch); border: 3px solid var(--gold); display: flex; flex-direction: column; }
.card .face img { width: 100%; flex: 1; min-height: 0; object-fit: cover; display: block; }
.card .face span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; background: var(--night); color: var(--gold); font-weight: 700; font-size: clamp(9px, calc(var(--cw) * .11), 19px); line-height: 1.1; padding: 3px 2px 4px; text-align: center; overflow: hidden; overflow-wrap: anywhere; }
.card.done .face { box-shadow: 0 0 0 3px var(--gold-soft), 0 0 26px rgba(242,193,78,.85); animation: pop .5s ease-out; }
.card.shake .in { animation: shake .4s; }
.card:focus-visible { outline: 3px solid #fff; outline-offset: 3px; border-radius: 12px; }

/* well done */
#done { align-items: center; justify-content: center; background: rgba(12,26,32,.55); z-index: 5; }
.panel { background: rgba(21,49,58,.95); border: 3px solid var(--gold); border-radius: 28px; padding: 26px 26px 22px; width: min(620px, 100%); text-align: center; animation: pop .5s ease-out; }
.stars { font-size: clamp(54px, 11vmin, 84px); letter-spacing: 8px; line-height: 1; margin: 4px 0 8px; }
.stars span { color: #3a4c56; display: inline-block; }
.stars span.lit { color: var(--gold); text-shadow: 0 0 22px rgba(242,193,78,.9); animation: pop .5s ease-out both; }
.panel p { font-size: clamp(17px, 3vmin, 22px); margin: 6px 0; }
.rupert { color: var(--gold-soft); font-style: italic; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

/* sparkles */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.sp { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle, #fff 0 20%, var(--gold) 45%, transparent 70%); animation: fly .9s ease-out forwards; }

@keyframes floaty { 50% { transform: translateY(-10px) rotate(-3deg); } }
@keyframes breathe { 50% { transform: scale(1.05); } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: rotateY(180deg) translateX(0); } 25% { transform: rotateY(180deg) translateX(-6px); } 75% { transform: rotateY(180deg) translateX(6px); } }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .btn.big, .cover-cat { animation: none; } }

/* screen-size fixes, 2 Dec */
button, .chip, .size, .pill { min-height: 44px; }
@media (max-width: 480px) {
  .stat { font-size: 14px; padding: 5px 10px; }
  .pill { font-size: 14px; padding: 6px 11px; }
  .bar { gap: 5px; }
  .chip { padding: 9px 14px; font-size: 15px; }
  .sizes { gap: 10px; }
}
/* short screens: phones on their side, short laptop windows */
@media (max-height: 520px) {
  .cover-inner { gap: 4px; }
  .cover-cat { width: 64px; animation: none; }
  h1 { font-size: clamp(26px, 7vh, 40px); }
  .sub { font-size: 15px; margin: 0 0 4px; }
  .btn.big { font-size: 26px; padding: 8px 44px; }
  .tiny { display: none; }
  h2 { font-size: 20px; margin-bottom: 6px; }
  .chips { margin-bottom: 8px; }
  .sizes { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .size { padding: 8px 6px; border-radius: 16px; }
  .size .mini { display: none; }
  .link { margin-top: 6px; }
  #play { gap: 4px; }
  .praise { font-size: 15px; min-height: 1.2em; }
  .panel { padding: 14px 18px; }
  .stars { font-size: 44px; margin: 0; }
  .row { margin-top: 8px; }
}

/* learning cards, 4 Dec */
.card .face.text { background: radial-gradient(circle at 50% 40%, #fff8e6, var(--parch) 70%); align-items: center; justify-content: center; }
.card .face .txt { color: #1d404a; font-weight: 700; line-height: 1; text-align: center; padding: 0 4%; overflow-wrap: normal; hyphens: manual; }
.card .face .txt.letter { font-size: calc(var(--cw) * .62); color: var(--pumpkin); text-shadow: 0 3px 0 rgba(0,0,0,.12); }
.card .face .txt.word { font-size: calc(var(--cw) * .24); }
.card .face .txt.sum { font-size: calc(var(--cw) * .24); color: var(--teal); }
.card .face .txt.num { font-size: calc(var(--cw) * .42); color: var(--pumpkin); }
#levelHead { margin-top: 0; }
#levels { margin-bottom: 12px; }
