@font-face { font-family: 'Future'; src: url(../fonts/kenney-future.ttf); font-display: swap; }
@font-face { font-family: 'Mini'; src: url(../fonts/kenney-mini-square.ttf); font-display: swap; }
:root { --field: #0aa67c; --deep: #05513f; --deeper: #033629; --hot: #ff3f6c; --hot2: #c81e4a; --cream: #fff6dc; --sun: #ffe45c; --side: 148px; }
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; background: var(--field); color: var(--cream); font-family: 'Mini', ui-monospace, monospace; overflow: hidden; }
#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; }
[hidden] { display: none !important; }
h1, h2, .btn, .done-title, #lvname { font-family: 'Future', 'Mini', sans-serif; font-weight: 400; letter-spacing: .02em; }

.btn { appearance: none; border: 0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 16px; color: var(--cream); background: var(--hot); box-shadow: 0 5px 0 var(--hot2), 0 5px 0 3px var(--deeper); border: 3px solid var(--deeper); font-size: 16px; line-height: 1; min-height: 44px; white-space: nowrap; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--hot2), 0 1px 0 3px var(--deeper); }
.btn.big { font-size: 22px; padding: 14px 22px; }
.btn:focus-visible { outline: 4px solid var(--sun); outline-offset: 3px; }
.btn[aria-disabled="true"] { filter: saturate(.3) brightness(.8); }
kbd { font-family: 'Mini', monospace; font-size: .62em; background: var(--cream); color: var(--deeper); padding: 4px 6px; border-bottom: 3px solid #cfc39a; line-height: 1; }
body.touch kbd { display: none; }

/* home */
#homecv { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.home-ui { position: absolute; inset: 0; display: grid; grid-template-rows: 1fr auto; justify-items: center; padding: max(3vh, env(safe-area-inset-top)) 4vw max(5vh, env(safe-area-inset-bottom)); pointer-events: none; }
.home-ui > * { pointer-events: auto; }
#logo { align-self: start; margin-top: 3vh; font-size: min(15vw, 26vh); line-height: .86; text-align: center; color: var(--cream); text-shadow: .06em .06em 0 var(--hot), .12em .12em 0 var(--deeper); display: flex; gap: .25em; flex-wrap: wrap; justify-content: center; }
#logo span { display: inline-block; animation: bump .833s infinite cubic-bezier(.2, 1.6, .4, 1); transform-origin: 50% 100%; }
#logo span:nth-child(2) { animation-delay: .416s; }
@keyframes bump { 0%, 100% { transform: scale(1, 1); } 12% { transform: scale(1.06, .86); } 30% { transform: scale(.97, 1.08) translateY(-4%); } }
.home-btns { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; align-items: center; }

/* levels */
#levels { background: var(--field); display: grid; grid-template-rows: auto 1fr; }
.bar { display: flex; align-items: center; gap: 18px; padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left)); background: var(--deep); border-bottom: 4px solid var(--deeper); }
.bar h2 { font-size: 26px; }
.why { margin-left: auto; font-size: 15px; color: var(--sun); min-height: 1.2em; text-align: right; }
#worlds { overflow-y: auto; -webkit-overflow-scrolling: touch; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); align-content: start; }
.world { padding: 12px 14px 16px; border-bottom: 4px solid var(--deeper); border-right: 4px solid var(--deeper); background: var(--w); }
.world h3 { font-family: 'Future'; font-weight: 400; font-size: 18px; margin-bottom: 10px; display: flex; gap: 10px; align-items: baseline; text-shadow: 2px 2px 0 rgba(0, 0, 0, .35); }
.world h3 small { font-family: 'Mini'; font-size: 13px; opacity: .95; }
.world .tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.lv { appearance: none; border: 3px solid var(--deeper); background: var(--cream); color: var(--deeper); font-family: 'Future'; padding: 8px 4px 6px; min-height: 64px; cursor: pointer; box-shadow: 0 5px 0 var(--deeper); display: grid; gap: 4px; justify-items: center; align-content: center; }
.lv b { font-size: 22px; font-weight: 400; }
.lv i { font-family: 'Mini'; font-style: normal; font-size: 12px; line-height: 1.05; text-align: center; }
.lv.done { background: var(--sun); }
.lv.locked { background: rgba(3, 54, 41, .55); color: rgba(255, 246, 220, .7); box-shadow: none; }
.lv.next { background: var(--hot); color: var(--cream); animation: bump 1.2s infinite; }
.lv:focus-visible { outline: 4px solid var(--cream); outline-offset: 2px; }

/* play: stage on top, inventory and actions at the side, timeline and lanes along the bottom. Sizes are fixed per level so the stage never changes size mid-level. */
#play { display: grid; grid-template-columns: 1fr var(--side); grid-template-rows: 1fr var(--deck-h, 150px); background: var(--deeper); padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#stage { grid-column: 1; grid-row: 1; position: relative; overflow: hidden; min-height: 0; min-width: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; cursor: grab; }
#side { min-width: 0; overflow: hidden; grid-column: 2; grid-row: 1 / span 2; background: var(--deep); border-left: 4px solid var(--deeper); display: grid; grid-template-rows: auto 1fr auto; gap: 6px; padding: 6px; min-height: 0; }
#lvname { font-size: 14px; line-height: 1.05; text-align: center; color: var(--sun); height: 32px; overflow: visible; white-space: normal; overflow-wrap: anywhere; display: grid; align-content: center; }
#inv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; align-content: start; }
.chip { position: relative; appearance: none; border: 3px solid var(--deeper); background: var(--field); height: 44px; padding: 0; cursor: grab; touch-action: none; display: grid; place-items: center; }
.chip canvas { width: 34px; height: 30px; image-rendering: pixelated; pointer-events: none; }
.chip .n { position: absolute; right: 1px; bottom: 0; font-family: 'Future'; font-size: 13px; color: var(--cream); text-shadow: 1px 1px 0 var(--deeper), -1px 1px 0 var(--deeper), 1px -1px 0 var(--deeper), -1px -1px 0 var(--deeper); }
.chip.sel { background: var(--hot); outline: 3px solid var(--sun); }
.chip.empty { background: var(--deeper); }
.chip.empty canvas { opacity: .35; }
#invname { grid-column: 1 / -1; font-size: 12px; text-align: center; height: 14px; color: var(--cream); }
#acts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 9px 6px; padding-bottom: 5px; }
#acts .btn { padding: 4px 4px; font-size: 12px; min-height: 34px; gap: 5px; box-shadow: 0 3px 0 var(--hot2), 0 3px 0 3px var(--deeper); }
#acts .btn.big { grid-column: 1 / -1; font-size: 17px; min-height: 40px; }
#acts .btn:nth-child(4) { grid-column: 1 / -1; background: var(--deep); box-shadow: 0 3px 0 var(--deeper); }
#acts .btn.on { background: var(--sun); color: var(--deeper); }
/* desktop: prompts, not buttons */
body:not(.touch) #acts .btn { background: transparent; box-shadow: none; border-color: transparent; justify-content: flex-start; min-height: 26px; padding: 2px 2px; font-size: 13px; }
body:not(.touch) #acts { grid-template-columns: 1fr; gap: 2px; }
body:not(.touch) #acts .btn.on { color: var(--sun); }
body:not(.touch) #acts .btn.big { font-size: 15px; }
body:not(.touch) #acts kbd { font-size: 11px; min-width: 44px; text-align: center; }
#deck { grid-column: 1; grid-row: 2; position: relative; background: var(--deep); border-top: 4px solid var(--deeper); display: grid; grid-template-rows: 20px 1fr; min-height: 0; min-width: 0; }
#status { font-size: 13px; line-height: 20px; padding: 0 8px; white-space: nowrap; overflow: hidden; color: var(--cream); background: var(--deeper); }
#status.warn { color: var(--sun); }
#strip { width: 100%; height: 100%; touch-action: none; cursor: ew-resize; }
#donebar { position: absolute; inset: 0; background: var(--hot); display: flex; align-items: center; justify-content: center; gap: 3vw; padding: 0 16px; }
#donebar .btn:not(.big) { background: var(--deep); box-shadow: 0 5px 0 var(--deeper); }
.done-title { font-size: clamp(20px, 4vw, 44px); text-shadow: 3px 3px 0 var(--deeper); }
#done-runs { font-size: 16px; }
#donebar .btn.big { background: var(--sun); color: var(--deeper); box-shadow: 0 5px 0 #b89b1e, 0 5px 0 3px var(--deeper); }
.dragghost { position: fixed; pointer-events: none; z-index: 50; width: 48px; height: 42px; image-rendering: pixelated; transform: translate(-50%, -60%); }

.panel { position: absolute; inset: 0; background: var(--field); display: grid; place-items: safe center; z-index: 20; overflow: auto; padding: 16px; }
.sheet { width: min(100%, 760px); display: grid; gap: 14px; justify-items: start; }
.sheet h2 { font-size: 34px; text-shadow: 3px 3px 0 var(--deeper); }
#credits-body { display: grid; gap: 8px; font-size: 15px; line-height: 1.3; }
#credits-body b { font-family: 'Future'; font-weight: 400; color: var(--sun); display: block; margin-top: 8px; }
#tweaks-body { display: grid; gap: 12px; font-size: 15px; }
#tweaks-body label { display: grid; gap: 4px; }
#tweaks-body select { font-family: 'Mini'; padding: 8px; border: 3px solid var(--deeper); background: var(--cream); color: var(--deeper); }

#rotate { display: none; position: absolute; inset: 0; z-index: 40; background: var(--hot); place-items: center; align-content: center; gap: 18px; text-align: center; font-family: 'Future'; font-size: 22px; padding: 24px; }
.rot-art { width: 90px; height: 150px; border: 6px solid var(--cream); border-radius: 14px; animation: turn 1.6s infinite ease-in-out; }
@keyframes turn { 0%, 20% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }
/* landscape only applies to the play screen; home, levels and credits work upright */
@media (orientation: portrait) and (pointer: coarse) { body.in-play #rotate { display: grid; } }
@media (orientation: portrait) { .home-btns { flex-direction: column; } #donebar { gap: 12px; } }

/* short phones in landscape */
@media (max-height: 460px) {
  :root { --side: 136px; }
  #lvname { font-size: 11px; height: 26px; }
  .chip { height: 36px; } .chip canvas { width: 28px; height: 25px; }
  #acts { gap: 7px 5px; } #acts .btn { min-height: 30px; font-size: 11px; } #acts .btn.big { min-height: 34px; font-size: 15px; }
  #status { font-size: 11px; }
  .bar h2 { font-size: 18px; } .bar { padding-top: 6px; padding-bottom: 6px; }
  .btn { min-height: 38px; padding: 8px 12px; font-size: 14px; } .btn.big { font-size: 18px; padding: 10px 16px; }
  #logo { font-size: min(13vw, 30vh); margin-top: 0; }
  .lv { min-height: 50px; padding: 4px 2px; } .lv b { font-size: 17px; } .lv i { font-size: 10px; }
  .world { padding: 8px 10px 12px; } .world h3 { font-size: 14px; margin-bottom: 6px; }
}

/* roomy windows: bigger inventory, bigger prompts */
@media (min-height: 600px) {
  :root { --side: 212px; }
  #side { padding: 10px; gap: 10px; }
  #lvname { font-size: 18px; height: 46px; }
  #inv { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .chip { height: 78px; } .chip canvas { width: 68px; height: 60px; } .chip .n { font-size: 20px; right: 4px; bottom: 2px; }
  #invname { font-size: 15px; height: 20px; }
  #deck { grid-template-rows: 28px 1fr; } #status { font-size: 16px; line-height: 28px; padding: 0 12px; }
  body:not(.touch) #acts .btn { font-size: 17px; min-height: 36px; gap: 10px; } body:not(.touch) #acts .btn.big { font-size: 20px; }
  body:not(.touch) #acts kbd { font-size: 13px; min-width: 62px; padding: 6px; }
  body.touch #acts .btn { min-height: 48px; font-size: 15px; } body.touch #acts .btn.big { min-height: 56px; font-size: 20px; }
}

body.touch #acts { grid-template-columns: minmax(0, 1fr); gap: 7px; }
body.touch #acts .btn { grid-column: 1; }

@media (max-height: 460px) {
  .sheet { gap: 8px; } .sheet h2 { font-size: 20px; }
  #credits-body { font-size: 11px; gap: 2px 18px; grid-template-columns: 1fr 1fr; } #credits-body b { margin-top: 4px; grid-column: 1 / -1; }
  #donebar { gap: 10px; padding: 0 8px; } .done-title { font-size: 15px; text-shadow: 2px 2px 0 var(--deeper); } #done-runs { font-size: 11px; }
  #donebar .btn { min-height: 34px; padding: 6px 10px; font-size: 12px; } #donebar .btn.big { font-size: 15px; padding: 8px 12px; }
}
@media (max-height: 345px) {
  #side { gap: 3px; padding: 4px 6px; } #lvname { height: 20px; font-size: 10px; }
  .chip { height: 31px; } .chip canvas { width: 25px; height: 22px; } #invname { height: 11px; font-size: 10px; }
  body.touch #acts { gap: 6px; } #acts .btn { min-height: 27px; } #acts .btn.big { min-height: 30px; }
}
