* { box-sizing: border-box; }
:root { color-scheme: dark; font-family: system-ui, sans-serif; background: #102c26; color: #f1f6ed; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; border: 1px solid #6b9788; background: #224e42; color: inherit; border-radius: .45rem; padding: .4rem .65rem; touch-action: manipulation; }
button:disabled { opacity: .52; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid #8bc9ff; outline-offset: 2px; }
input { min-width: 0; background: #102c26; color: inherit; border: 1px solid #6b9788; border-radius: .35rem; padding: .35rem; }
[hidden] { display: none !important; }
main { width: min(100%, 850px); margin: auto; height: 100dvh; display: flex; flex-direction: column; min-height: 0; padding: max(.45rem, env(safe-area-inset-top)) max(.55rem, env(safe-area-inset-right)) max(.3rem, env(safe-area-inset-bottom)) max(.55rem, env(safe-area-inset-left)); }
header, .dialog-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
h1 { font-size: clamp(1.25rem, 5vw, 2rem); margin: 0; line-height: 1.1; }
header p { margin: .12rem 0 .4rem; color: #a9c4b9; font-size: .75rem; }
.welcome { align-self: center; width: min(100%, 31rem); margin: auto 0; border: 1px solid #6b9788; background: #184236; border-radius: .7rem; padding: clamp(.75rem, 4vw, 2rem); overflow: auto; }
h2 { margin: 0; font-size: 1.25rem; }
.welcome p, dialog p { color: #cee1d5; }
.primary { background: #e0e9c5; color: #173629; border-color: #e0e9c5; font-weight: 700; }
#seed-form { margin-top: 1rem; display: grid; gap: .3rem; }
#seed-form div { display: flex; gap: .35rem; }
#seed-form input { flex: 1; }
#play { flex: 1; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto; gap: clamp(.2rem, 1vh, .65rem); }
.hud { display: grid; grid-template-columns: repeat(3, 1fr); background: #193d34; border-radius: .4rem; padding: .28rem .5rem; }
.hud div { display: flex; justify-content: center; align-items: baseline; gap: .4rem; font-variant-numeric: tabular-nums; }
.hud span, #feedback { font-size: .75rem; color: #c4d9cc; }
#towers { background: #1c5647; border: 1px solid #517f70; border-radius: .55rem; padding: .35rem; display: grid; grid-template: repeat(3, minmax(0, 1fr)) / repeat(3, minmax(0, 1fr)); gap: .35rem; overflow: hidden; }
.slot { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; background: #164236; border: 1px solid #619181; border-radius: .45rem; padding: .2rem; }
.target { min-height: 0; min-width: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); align-items: center; gap: .12rem; border: 0; background: transparent; padding: .1rem .16rem .2rem; }
.requirement { font-size: clamp(.65rem, 2.7vw, .85rem); line-height: 1.13; min-width: 0; overflow-wrap: anywhere; }
.requirement strong { font-variant-numeric: tabular-nums; }
.card { color: #251f16; background: #f4ead1; border: 1px solid #baae91; border-radius: .36rem; font-weight: 700; overflow-wrap: anywhere; text-wrap: pretty; }
.top { display: grid; place-items: center; align-self: stretch; max-height: 3.4rem; margin: auto 0; min-height: 75%; font-size: clamp(.72rem, 2.9vw, 1.03rem); padding: .15rem; }
.top:empty { visibility: hidden; }
.slot.stacked .top { box-shadow: 0 2px #ac9c76; }
.slot.ready { border-color: #f1d579; }
.score { font-size: .75rem; padding: .17rem .2rem; min-height: 24px; }
.score:not(:disabled) { background: #f1d579; color: #2a2415; font-weight: 700; }
.slot.rejected { outline: 2px solid #ff9b91; outline-offset: -2px; }
.lane-head { display: flex; justify-content: space-between; align-items: center; margin: 0 0 .22rem; font-size: .79rem; }
#cancel { font-size: .72rem; padding: .15rem .4rem; }
#lane { position: relative; height: clamp(2.75rem, 8.4dvh, 4.4rem); border-radius: .45rem; background: #0a2520; outline: 1px solid #517f70; overflow: hidden; }
.incoming { position: absolute; top: .16rem; bottom: .16rem; left: 0; width: calc(100% / var(--capacity) - 4px); margin-left: 2px; padding: .12rem; font-size: var(--word-size); line-height: 1.07; }
.incoming[aria-pressed="true"] { box-shadow: inset 0 0 0 3px #206db4; background: #eef4fd; }
.controls { display: flex; gap: .3rem; flex-wrap: wrap; }
.controls button { flex: 1; padding: .25rem .35rem; font-size: .82rem; }
#feedback { min-height: 1rem; margin: 0; line-height: 1; }
#results { display: grid; grid-template-columns: 1fr auto; gap: .2rem .5rem; }
#results dd { margin: 0; font-variant-numeric: tabular-nums; }
dialog { color: inherit; background: #183c32; width: min(94vw, 40rem); max-height: 90dvh; border: 1px solid #7ba99a; border-radius: .65rem; }
dialog::backdrop { background: #061713b5; }
#fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; margin-bottom: .65rem; }
#fields label { min-width: 0; display: flex; flex-direction: column; font-size: .8rem; gap: .14rem; }
#fields input[type="checkbox"] { align-self: flex-start; }
details { margin-top: .7rem; }
.diagnostic-actions { display: flex; gap: .35rem; margin: .45rem 0; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 35dvh; overflow: auto; font-size: .75rem; }
