@font-face { font-family: "Fredoka"; src: url(/fonts/fredoka-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url(/fonts/space-grotesk-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url(/fonts/space-grotesk-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --field: #1e8cff;      /* azure sky */
  --deep: #0a3d8f;       /* a deep shade of the field, never grey */
  --ink: #06275e;
  --btn: #ff5a36;        /* tomato */
  --btn-deep: #c43216;
  --cream: #fff6e8;
  --mine: #ff5a36;
  --foe: #7b2cff;
  --gold: #fff35c;
  --vh: 100vh;
  --top: 52px;
  --dock: 256px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--field); color: var(--cream); font: 500 15px/1.35 "Space Grotesk", system-ui, sans-serif; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
h1, h2 { font-family: "Fredoka", system-ui, sans-serif; font-weight: 700; margin: 0; }

#app { position: fixed; inset: 0; height: var(--vh); overflow: hidden;
  background: radial-gradient(120% 80% at 50% 0%, #6cc3ff 0%, var(--field) 55%, #1670db 100%); }
#stage { position: absolute; left: 0; right: 0; top: 0; height: var(--vh); background: center top / cover no-repeat; }
#board { display: block; width: 100%; height: 100%; touch-action: none; }
#overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#app[data-screen="play"] #stage, #app[data-screen="run"] #stage, #app[data-screen="result"] #stage { top: var(--top); height: calc(var(--vh) - var(--top) - var(--dock) - var(--safe-b)); }

.screen { position: absolute; inset: 0; display: none; }
#app[data-screen="home"] #home, #app[data-screen="levels"] #levels, #app[data-screen="result"] #result, #app[data-screen="credits"] #credits { display: flex; }
#top, #dock { display: none; }
#app[data-screen="play"] :is(#top, #dock), #app[data-screen="run"] :is(#top, #dock), #app[data-screen="result"] :is(#top, #dock) { display: flex; }

/* ---------- keys and buttons ---------- */
.key { display: none; font: 700 11px/1 "Space Grotesk"; padding: 4px 6px; border-radius: 5px; background: rgba(6, 39, 94, .35); border: 1.5px solid currentColor; margin-right: 8px; letter-spacing: .02em; }
@media (hover: hover) and (pointer: fine) { .key { display: inline-block; } }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 22px; border-radius: 14px;
  background: var(--deep); font: 700 19px/1 "Fredoka"; box-shadow: 0 5px 0 var(--ink); transition: transform .08s, box-shadow .08s; }
.btn.primary { background: var(--btn); box-shadow: 0 5px 0 var(--btn-deep); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.big { min-height: 72px; font-size: 30px; padding: 0 44px; border-radius: 18px; }
.btn:disabled { background: var(--deep); box-shadow: 0 5px 0 var(--ink); opacity: .75; cursor: default; }
.chip { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; background: rgba(6, 39, 94, .55); font: 700 15px/1 "Space Grotesk"; }

/* ---------- home ---------- */
#home { flex-direction: column; justify-content: space-between; align-items: center; padding: max(28px, env(safe-area-inset-top)) 16px calc(18px + var(--safe-b)); pointer-events: none; }
#home > * { pointer-events: auto; }
.title { font-size: clamp(76px, 24vw, 168px); line-height: .82; text-align: center; color: var(--cream); letter-spacing: -.02em;
  text-shadow: 0 6px 0 var(--ink), 0 14px 30px rgba(6, 39, 94, .45); animation: wobble 3.2s ease-in-out infinite; }
.title span { display: block; }
.title span:last-child { color: var(--gold); animation: wind 1.6s ease-in-out infinite; display: inline-block; width: 100%; }
@keyframes wobble { 50% { transform: rotate(-2deg) translateY(-4px); } }
@keyframes wind { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(1.06); } }
.home-foot { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.shelf { width: 100%; max-width: 980px; }

/* ---------- bars ---------- */
.bar { position: absolute; left: 0; right: 0; top: 0; height: var(--top); align-items: center; gap: 12px; padding: 0 12px; padding-top: env(safe-area-inset-top); z-index: 3; }
#levels .bar, #credits .bar { display: flex; position: relative; background: var(--deep); }
.bar h2 { font-size: 24px; flex: 1; white-space: nowrap; }
.playbar { background: var(--deep); }
.lv-num { font: 700 15px "Space Grotesk"; opacity: .8; }

/* ---------- levels ---------- */
#levels, #credits { flex-direction: column; background: rgba(10, 61, 143, .6); backdrop-filter: blur(4px); }
.level-list { flex: 1; overflow-y: auto; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-content: start; }
.lv { position: relative; min-height: 112px; border-radius: 0; padding: 12px; text-align: left; background: var(--btn); box-shadow: 0 5px 0 var(--btn-deep); display: flex; flex-direction: column; justify-content: space-between; }
.lv b { font: 700 34px/1 "Fredoka"; }
.lv span { font: 700 17px/1.1 "Fredoka"; }
.lv .st { font-size: 22px; letter-spacing: 2px; color: var(--gold); }
.lv .st i { font-style: normal; color: rgba(6, 39, 94, .45); }
.lv.locked { background: var(--deep); box-shadow: 0 5px 0 var(--ink); opacity: .7; }
.credit-list { padding: 18px 16px; overflow-y: auto; max-width: 760px; }
.credit-list p { margin: 0 0 14px; }
.credit-list b { display: block; font: 700 17px "Fredoka"; }

/* ---------- dock ---------- */
#dock { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--dock) + var(--safe-b)); padding: 8px 12px calc(10px + var(--safe-b)); flex-direction: column; gap: 8px; background: var(--deep); z-index: 3; }
.info { margin: 0; height: 77px; font-size: 14px; line-height: 19px; overflow: hidden; }
.info b { font-family: "Fredoka"; font-size: 16px; }
.info em { font-style: normal; font-weight: 700; color: var(--gold); }
.info .foe { color: #c9a6ff; } .info .mine { color: #ffb199; }
.tray { display: flex; gap: 6px; height: 104px; }
.mon { position: relative; flex: 1 1 0; min-width: 0; border-radius: 12px; background: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 0 2px 4px; overflow: hidden; transition: transform .12s; }
.mon img { position: absolute; top: -2px; left: 50%; width: 82px; max-width: 120%; transform: translateX(-50%); pointer-events: none; }
.mon .nm { position: relative; font: 700 12px/1 "Fredoka"; white-space: nowrap; }
.mon .stats { position: relative; display: flex; gap: 3px; font: 700 12px/1 "Space Grotesk"; margin-top: 3px; }
.mon .stats span { display: inline-flex; align-items: center; gap: 1px; padding: 2px 3px; border-radius: 5px; background: rgba(0, 0, 0, .45); }
.mon .stats img { position: static; width: 11px; transform: none; filter: invert(1); }
.mon.sel { outline: 3px solid var(--gold); transform: translateY(-4px); }
.mon.used { opacity: .35; }
.mon.used.focus { opacity: 1; outline: 3px solid var(--mine); }
.mon .x { display: none; position: absolute; top: 3px; right: 3px; z-index: 2; width: 22px; height: 22px; border-radius: 50%; background: var(--mine); font: 700 13px/22px "Space Grotesk"; }
.mon.used.focus .x { display: block; }
.mon .num { position: absolute; top: 4px; left: 6px; font: 700 13px "Fredoka"; color: var(--gold); }
.go-row { display: flex; gap: 8px; flex: none; }
#start { min-height: 56px; font-size: 22px; flex: 1; }
#skip { display: none; min-height: 56px; font-size: 20px; flex: 0 0 34%; }
#app[data-screen="run"] #skip { display: inline-flex; }

/* run: the dock becomes the order of this loop */
.order { display: flex; gap: 6px; height: 104px; align-items: center; overflow: hidden; padding: 0 8px; }
.order .o { position: relative; flex: 0 0 auto; width: 52px; height: 64px; border-radius: 12px; background: var(--ink); border: 3px solid var(--mine); overflow: hidden; transition: transform .15s, opacity .2s; }
.order .o.foe { border-color: var(--foe); }
.order .o img { width: 100%; }
.order .o b { position: absolute; bottom: 1px; right: 3px; font: 700 13px "Fredoka"; text-shadow: 0 1px 2px #000; }
.order .o.now { transform: scale(1.22); z-index: 2; box-shadow: 0 0 0 3px var(--gold); }
.order .o.done { opacity: .45; }
.order .o.dead { opacity: .15; }

/* ---------- labels over creatures ---------- */
.hp { position: absolute; left: 0; top: 0; width: 48px; height: 12px; border-radius: 6px; background: rgba(6, 39, 94, .8); border: 2px solid var(--mine); will-change: transform; }
.hp.foe { border-color: var(--foe); }
.hp i { display: block; height: 100%; border-radius: 3px; background: #6dff7e; transition: width .25s; }
.hp b { position: absolute; right: -24px; top: -5px; font: 700 14px "Fredoka"; color: var(--cream); text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.hp.now { box-shadow: 0 0 0 3px var(--gold); }
.hp.gone { display: none !important; }
.pop { position: absolute; left: 0; top: 0; font: 700 30px/1 "Fredoka"; color: #fff; text-shadow: 0 3px 0 #b3001b, 0 0 8px rgba(0, 0, 0, .5); will-change: transform; }
.pop.heal { color: #b7ffcf; text-shadow: 0 3px 0 #0b7a3a, 0 0 8px rgba(0, 0, 0, .5); }
.toast { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); padding: 10px 16px; border-radius: 12px; background: var(--ink); font: 700 15px "Space Grotesk"; white-space: nowrap; z-index: 5; animation: toast 1.8s forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -8px); } 12%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
.loopbanner { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); font: 700 46px "Fredoka"; color: var(--cream); text-shadow: 0 5px 0 var(--ink); animation: banner .9s forwards; white-space: nowrap; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); } 20%, 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1); } }

/* ---------- result ---------- */
#result { align-items: center; justify-content: center; padding: 16px; background: rgba(6, 39, 94, .55); z-index: 6; }
.panel { width: 100%; max-width: 440px; padding: 22px 18px; background: var(--field); border: 4px solid var(--ink); text-align: center; box-shadow: 0 10px 0 var(--ink); animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); max-height: 100%; overflow-y: auto; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.panel h2 { font-size: 40px; text-shadow: 0 4px 0 var(--ink); }
.stars { font-size: 64px; letter-spacing: 6px; color: var(--gold); text-shadow: 0 4px 0 var(--ink); margin: 6px 0; }
.stars i { font-style: normal; color: rgba(6, 39, 94, .55); text-shadow: none; }
.stars span { display: inline-block; animation: star .4s cubic-bezier(.3, 1.8, .5, 1) backwards; }
@keyframes star { from { transform: scale(0) rotate(-40deg); } }
.r-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.r-pair { display: flex; gap: 10px; } .r-pair .btn { flex: 1; padding: 0 10px; }
.panel h2 { line-height: 1; } .stars { line-height: 1.1; }

/* ---------- wide screens ---------- */
@media (min-width: 900px) {
  :root { --dock: 178px; }
  #dock { flex-direction: row; flex-wrap: wrap; align-items: stretch; padding: 10px max(16px, calc(50vw - 560px)); }
  .info { width: 100%; height: 50px; }
  .tray, .order { flex: 1; height: 100px; }
  .mon { max-width: 120px; }
  .go-row { width: 240px; flex-direction: column; }
  #start, #skip { min-height: 46px; flex: 1; }
}

/* the narrowest phones: the longest creature text still fits its three reserved lines */
@media (max-width: 340px) { .info { font-size: 12px; line-height: 19px; letter-spacing: -.015em; } .info b { font-size: 14px; } }

/* where the picked creature lands its first hit */
.rtag { position: absolute; left: 0; top: 0; padding: 5px 10px; border-radius: 999px; background: var(--mine); color: #fff; font: 700 15px/1 "Fredoka"; white-space: nowrap; box-shadow: 0 3px 0 var(--btn-deep); pointer-events: none; z-index: 2; }
.rtag.foe { background: var(--foe); box-shadow: 0 3px 0 #4a12a8; }
.rtag.none { opacity: .9; font-size: 13px; }

/* move pattern on the card: where one move can land it */
.mon .glyph { position: absolute; top: 3px; right: 3px; width: 30px; z-index: 1; background: rgba(6, 39, 94, .7); border-radius: 6px; padding: 1px; }
.mon .reach { position: absolute; top: 36px; right: 4px; z-index: 1; font: 700 11px/1 "Space Grotesk"; padding: 2px 4px; border-radius: 5px; background: rgba(6, 39, 94, .7); }
.mon .stats .sw { width: 11px; height: 11px; }
.info u { text-decoration: none; font-weight: 700; color: var(--gold); }
.hp s { position: absolute; left: -22px; top: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--gold); color: var(--ink); font: 700 13px/20px "Fredoka"; text-align: center; text-decoration: none; }
.why { display: block; margin-top: 10px; font-size: 14px; opacity: .92; }
.coach { position: fixed; z-index: 7; pointer-events: none; transform: translate(-20%, -10%); }
.coach span { display: block; font-size: 44px; animation: tapme 1s ease-in-out infinite; filter: drop-shadow(0 3px 0 rgba(6, 39, 94, .6)); }
.coach b { display: block; margin-top: 2px; padding: 6px 10px; border-radius: 10px; background: var(--ink); font: 700 14px "Fredoka"; white-space: nowrap; transform: translateX(-30%); }
@keyframes tapme { 50% { transform: translateY(10px) scale(.92); } }
