/* Phone controller: kraft paper, cream cards, big thumbs-first buttons in the player's own colour (--c). */
:root {
    --ink: #2A1F17;
    --ink-2: #5A4535;
    --cream: #FBF6EA;
    --kraft: #C8A06A;
    --kraft-d: #9C7646;
    --red: #C0312B;
    --pine: #24513E;
    --gold: #F2B33D;
    --c: #C0312B;
    --f-head: 'Shantell Sans', 'Segoe Print', sans-serif;
    --f-type: 'Courier Prime', 'Courier New', monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--kraft); color: var(--ink); font-family: var(--f-head); overscroll-behavior: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
#app { min-height: 100dvh; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2 { margin: 0; line-height: 1.1; }

.screen { min-height: 100dvh; padding: max(24px, env(safe-area-inset-top)) 18px 24px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.screen.center { justify-content: center; }
.screen h1 { font-size: 34px; font-weight: 800; transform: rotate(-1.5deg); }
.small { font: 14px var(--f-type); color: var(--ink-2); }
.small a { color: inherit; }
.error { font: 700 15px var(--f-type); color: #fff; background: var(--red); padding: 6px 12px; }

.code { justify-content: center; }
.code form { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 320px; }
.code input { font: 800 52px var(--f-type); text-align: center; letter-spacing: .25em; text-transform: uppercase; padding: 12px 0 12px .25em; border: 0; background: var(--cream); box-shadow: 0 4px 0 rgba(42, 31, 23, .3); width: 100%; }

.big-btn { border: 0; background: var(--red); color: #fff; font-size: 22px; font-weight: 800; padding: 16px 24px; box-shadow: 0 5px 0 #8E1F1A; border-radius: 6px; }
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #8E1F1A; }
.ghost { border: 2px dashed rgba(42, 31, 23, .45); background: transparent; padding: 8px 16px; font: 700 15px var(--f-type); border-radius: 6px; }

.pick .stickers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; max-width: 420px; }
.sticker { position: relative; border: 0; background: var(--cream); padding: 10px 6px 8px; box-shadow: 0 4px 0 rgba(42, 31, 23, .25); display: flex; flex-direction: column; align-items: center; gap: 4px; transform: rotate(-1deg); }
.sticker:nth-child(even) { transform: rotate(1.2deg); }
.sticker img { width: 92px; height: 92px; border-radius: 50%; background: color-mix(in srgb, var(--c) 25%, white); border: 4px solid var(--c); }
.sticker span { font-weight: 800; font-size: 18px; }
.sticker.taken { opacity: .45; filter: grayscale(.9); }
.sticker em { position: absolute; top: 40%; font: 700 15px var(--f-type); font-style: normal; background: var(--ink); color: var(--cream); padding: 2px 8px; transform: rotate(-8deg); }

.ready { justify-content: center; }
.me-big { width: 170px; height: 170px; border-radius: 50%; border: 6px solid var(--c); background: var(--cream); }

/* controller shell */
.shell { height: 100dvh; display: flex; flex-direction: column; }
.bar { flex: none; display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 10px 8px; background: var(--c); color: #fff; }
.bar img { width: 38px; height: 38px; border-radius: 50%; background: var(--cream); }
.bar b { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .status { font: 700 12px var(--f-type); margin-left: auto; }
.bar .status:not(.on) { background: var(--ink); padding: 2px 6px; }
.bar .status.on { display: none; }
.tabs { display: flex; margin-left: auto; }
.status:not(.on) + .tabs { margin-left: 6px; }
.tabs button { border: 0; background: rgba(0, 0, 0, .2); color: #fff; padding: 6px 10px; font-weight: 700; font-size: 14px; }
.tabs button.on { background: var(--cream); color: var(--ink); }
.gear { border: 0; background: transparent; color: #fff; font-size: 22px; padding: 2px 4px; }
.bar > .gear:first-of-type { margin-left: auto; }
.status:not(.on) ~ .gear, .tabs ~ .gear { margin-left: 4px; }
.ready-bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--ink); color: var(--cream); font: 700 14px var(--f-type); }
.ready-bar[hidden] { display: none; }
.ready-bar button { flex: none; border: 0; border-radius: 999px; padding: 10px 18px; background: var(--gold); color: var(--ink); font: 800 17px var(--f-head); box-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
.ready-bar.done { justify-content: center; background: var(--pine); }
.controls-note { font: 700 12px var(--f-type); color: var(--ink-2); max-width: 30ch; }
.stage { flex: 1; min-height: 0; display: flex; padding-bottom: env(safe-area-inset-bottom); }

.pad { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 16px; text-align: center; min-height: 0; }
.pad h2 { font-size: 26px; font-weight: 800; }
.pad p { margin: 0; font-size: 17px; color: var(--ink-2); }
.pad.wait h2 { font-size: 30px; transform: rotate(-1deg); }
.wait-me { width: 120px; height: 120px; border-radius: 50%; border: 5px solid var(--c); background: var(--cream); }
.pulse { animation: pulse .25s ease-out; }
@keyframes pulse { 40% { transform: scale(.94); filter: brightness(1.2); } }

.big-ring { width: min(62vw, 260px); aspect-ratio: 1; border-radius: 50%; border: 10px solid var(--c); background: var(--cream); display: grid; place-items: center; box-shadow: 0 6px 0 rgba(42, 31, 23, .25); }
.big-ring span { font-size: 38px; font-weight: 800; }

.swipe-zone, .slice-zone, .trackpad { position: relative; width: 100%; flex: 1; min-height: 0; border-radius: 12px; background: var(--cream); box-shadow: inset 0 0 0 4px var(--c); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 0 18px; text-align: center; touch-action: none; }
.swipe-zone b { font-size: 34px; }
.swipe-zone small, .slice-zone small, .trackpad small { font: 700 14px var(--f-type); color: var(--ink-2); }
.arrow-up { width: 60px; height: 70px; background: var(--c); clip-path: polygon(50% 0, 100% 45%, 68% 45%, 68% 100%, 32% 100%, 32% 45%, 0 45%); animation: rise 1s ease-in-out infinite; }
@keyframes rise { 50% { transform: translateY(-12px); } }
.slice-zone canvas { position: absolute; inset: 0; pointer-events: none; }
.slice-zone small { position: absolute; top: 12px; }

.fire, .tap-btn, .mash { border: 0; border-radius: 18px; background: var(--b, var(--c)); color: #fff; font-size: 34px; font-weight: 800; box-shadow: 0 7px 0 rgba(42, 31, 23, .35); touch-action: none; }
.fire { width: 100%; flex: 1; max-height: 55vh; }
.aim.touch .fire { flex: none; height: 110px; }
.tap-btn { width: min(78vw, 300px); aspect-ratio: 1; border-radius: 50%; }
.tap-btn:disabled { opacity: .55; }
.mash { width: 100%; flex: 1; max-height: 50vh; }
.fire:active, .tap-btn:active, .mash:active { transform: translateY(4px); box-shadow: 0 3px 0 rgba(42, 31, 23, .35); }

.calibrate h2 { font-size: 24px; }
.calib-art { width: 120px; height: 120px; border-radius: 50%; background: var(--cream); position: relative; }
.calib-art::before { content: ''; position: absolute; left: 50%; top: 50%; width: 34px; height: 64px; margin: -32px -17px; background: var(--ink); border-radius: 8px; transform: perspective(200px) rotateX(55deg); }
.calib-art::after { content: ''; position: absolute; left: 50%; top: 6px; width: 4px; height: 26px; margin-left: -2px; background: var(--red); }

.level, .stick { position: relative; width: min(70vw, 240px); aspect-ratio: 1; border-radius: 50%; background: var(--cream); box-shadow: inset 0 0 0 6px var(--c), 0 5px 0 rgba(42, 31, 23, .2); touch-action: none; }
.level::after { content: ''; position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px; border-radius: 50%; border: 3px dashed rgba(42, 31, 23, .3); }
.bubble, .knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: var(--c); box-shadow: 0 4px 0 rgba(42, 31, 23, .3); }

.meter { width: 60px; height: min(40vh, 260px); background: var(--cream); border-radius: 30px; overflow: hidden; display: flex; align-items: flex-end; box-shadow: inset 0 0 0 4px var(--c); }
.meter i { width: 100%; height: 100%; background: var(--c); transform-origin: bottom; transform: scaleY(0); }
.meter.wide { width: 100%; height: 26px; }
.meter.wide i { transform-origin: left; transform: scaleX(0); }

.choices .opts { width: 100%; display: grid; gap: 10px; }
.choices .opts.many { grid-template-columns: 1fr 1fr; }
.choices button { border: 0; border-radius: 10px; background: var(--o); color: #fff; font-size: 20px; font-weight: 800; padding: 16px 10px; min-height: 64px; box-shadow: 0 5px 0 rgba(42, 31, 23, .3); display: flex; align-items: center; justify-content: center; gap: 8px; }
.choices button img { width: 44px; height: 44px; border-radius: 50%; background: #fff; }
.choices[data-locked] button:not(.picked) { opacity: .35; }
.choices button.picked { outline: 5px solid var(--ink); }
.locked { font: 700 18px var(--f-type); }

.number .readout { font: 800 44px var(--f-type); background: var(--cream); padding: 6px 18px; min-width: 70%; box-shadow: 0 4px 0 rgba(42, 31, 23, .25); }
.number .unit { font-size: .6em; margin-right: 6px; }
.number .keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 340px; }
.number .keys button { border: 0; background: var(--cream); font: 800 26px var(--f-type); padding: 12px 0; border-radius: 8px; box-shadow: 0 4px 0 rgba(42, 31, 23, .25); }
.number .keys [data-k="OK"] { background: var(--c); color: #fff; }
.number.locked .keys { opacity: .4; }

.trace canvas, .draw canvas { background: #fff; border-radius: 10px; box-shadow: 0 0 0 4px var(--c); touch-action: none; }
.trace.done canvas { opacity: .5; }
.trace .round, .draw h2 { font: 700 18px var(--f-type); color: var(--ink); }
.draw h2 b { font-family: var(--f-head); font-size: 26px; }

.throw .ammo { display: flex; gap: 12px; width: 100%; flex: 1; max-height: 50vh; }
.throw .ammo button { flex: 1; border: 0; border-radius: 16px; font-size: 22px; font-weight: 800; color: #fff; box-shadow: 0 6px 0 rgba(42, 31, 23, .35); touch-action: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.throw .ammo button::before { content: ''; width: 72px; height: 72px; border-radius: 50%; }
.throw .tomato { background: #B8392F; }
.throw .tomato::before { background: radial-gradient(circle at 35% 35%, #FF7A66, #E2372C 60%); box-shadow: inset 0 6px 0 -2px #3E8E41; }
.throw .egg { background: #3A7BD5; }
.throw .egg::before { background: radial-gradient(circle at 40% 35%, #fff, #F3EBDA); border-radius: 50% 50% 48% 48% / 60% 60% 40% 40%; }

.message h1 { font-size: 40px; font-weight: 800; transform: rotate(-2deg); }
.message.gold { background: var(--gold); }
.message.back { background: var(--gold); animation: glow 1s ease-in-out infinite alternate; }
@keyframes glow { to { background: #FFE08A; } }
.message.out { background: rgba(42, 31, 23, .15); }

.sheet { position: fixed; inset: 0; background: rgba(42, 31, 23, .5); display: grid; place-items: end center; z-index: 10; }
.sheet-card { background: var(--cream); width: 100%; padding: 20px 18px max(20px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.sheet-card { max-height: 100dvh; overflow-y: auto; }
.sheet-card h2 { margin: 0; }
.sheet .advice { margin: 0; font: 700 15px var(--f-type); line-height: 1.35; text-align: left; }
.sheet .level { --c: var(--pine); flex: none; width: 110px; margin: 0 auto; }
.sheet .bubble { width: 30px; height: 30px; margin: -15px; }
.sheet .level::after { width: 24px; height: 24px; margin: -12px; }
.checks { margin: 0; display: flex; flex-direction: column; gap: 4px; text-align: left; font: 14px var(--f-type); }
.checks div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 8px; background: rgba(42, 31, 23, .06); border-left: 5px solid var(--red); }
.checks div.ok { border-left-color: var(--pine); }
.checks dt { font-weight: 700; }
.checks dd { margin: 0; text-align: right; }
.sheet [hidden] { display: none; }

/* shown when the TV wants motion and this phone can only give touch */
.motion-warn { flex: none; border: 0; padding: 8px 12px; background: var(--gold); color: var(--ink); font: 700 13px var(--f-type); line-height: 1.3; text-align: left; }
.motion-warn[hidden] { display: none; }

/* a layout the player has to notice without looking (the hot present landed on them) */
.pad.hot { background: var(--red); animation: hot .35s ease-in-out infinite alternate; }
.pad.hot p, .pad.hot .ghost { color: #fff; }
@keyframes hot { to { background: #E8623D; } }

/* host panel */
.host { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; -webkit-overflow-scrolling: touch; }
.host section { background: var(--cream); padding: 10px 12px 12px; box-shadow: 0 3px 0 rgba(42, 31, 23, .2); }
.host h3 { margin: 0 0 8px; font-size: 17px; }
.host .row, .host .grid { display: flex; flex-wrap: wrap; gap: 8px; }
.host .row + .row, .host .row + .grid { margin-top: 8px; }
.host .grid button { flex: 1 1 45%; }
.host button { border: 0; background: var(--ink); color: var(--cream); padding: 10px 12px; font-weight: 700; font-size: 15px; border-radius: 6px; }
.host button.go { background: var(--pine); }
.host button.danger { background: var(--red); }
.host button.ghost { background: transparent; color: var(--ink); }
.host button.mini { padding: 4px 10px; font-size: 16px; }
.host .force { display: block; margin-top: 8px; font: 700 14px var(--f-type); }
.host button:disabled { opacity: .4; }
.host .small { margin: 0; }

/* boss controller: one big button per fighter */
.targets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.targets button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; background: #fff; color: var(--ink); border: 4px solid var(--c); border-radius: 12px; box-shadow: 0 4px 0 rgba(42, 31, 23, .3); }
.targets button:disabled { box-shadow: none; }
.targets img { width: 54px; height: 54px; border-radius: 50%; background: color-mix(in srgb, var(--c) 25%, white); }
.targets small { font: 12px var(--f-type); }
.host select { font: inherit; width: 100%; padding: 8px; margin-top: 4px; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.plist li { display: flex; align-items: center; gap: 8px; border-left: 5px solid var(--c); padding-left: 6px; }
.plist img { width: 32px; height: 32px; border-radius: 50%; }
.plist span { flex: 1; font-weight: 700; font-size: 15px; display: flex; flex-direction: column; }
.plist small { font: 12px var(--f-type); color: var(--ink-2); }
.plist .fix { flex: none; flex-direction: row; align-items: center; gap: 6px; }

/* /sensors test page */
.sensor-test { padding: 1em 1em 3em; }
.sensor-test h1 { margin: .2em 0 .4em; font-size: 2em; }
.sensor-test .perm { font: 700 .9em var(--f-type); }
.st-pad { position: relative; aspect-ratio: 16 / 9; background: var(--cream); box-shadow: 0 4px 0 rgba(42, 31, 23, .25); overflow: hidden; margin: .6em 0; }
.st-cursor { position: absolute; left: 50%; top: 50%; width: 1.6em; height: 1.6em; margin: -.8em; border-radius: 50%; border: .3em solid var(--red); }
.st-row { display: flex; gap: .6em; }
.st-row button { flex: 1; font: 700 1em var(--f-head); border: 0; padding: .6em; background: var(--cream); box-shadow: 0 3px 0 rgba(42, 31, 23, .25); }
.st-meter { display: flex; align-items: center; gap: .6em; margin-top: .8em; font: 700 .9em var(--f-type); }
.st-meter span { width: 4em; }
.st-meter div { position: relative; flex: 1; height: 1.2em; background: var(--cream); overflow: hidden; }
.st-tilt { position: absolute; left: 50%; top: 0; width: 1.2em; height: 100%; margin-left: -.6em; background: var(--red); }
.st-shake { display: block; height: 100%; background: var(--red); }
.st-raw { font: .8em var(--f-type); white-space: pre-wrap; background: var(--cream); padding: .6em; margin-top: 1em; }
.st-log { font: .85em var(--f-type); padding-left: 1.4em; }
