:root { --paper: #F4EBDD; --ink: #5A4632; --gold: #E8B85A; --night: #2A201A; --ui: 1; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
body { display: grid; place-items: center; font-family: "Nunito", "Trebuchet MS", system-ui, sans-serif; color: var(--paper); }
#stage { position: relative; overflow: hidden; background: var(--paper); }
#view { position: absolute; inset: 0; display: block; }
#overlay { position: absolute; inset: 0; pointer-events: none; }
#overlay > * { pointer-events: auto; }
button { font: inherit; }

/* ---- HUD ---- */
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud[hidden] { display: none; }
.hud button { pointer-events: auto; }
.hud-left { position: absolute; left: calc(12px + env(safe-area-inset-left)); top: calc(10px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 4px; }
.hud-row { display: flex; gap: 3px; }
.heart svg { width: calc(22px * var(--ui)); height: calc(20px * var(--ui)); fill: #C8564B; stroke: #3E2A20; stroke-width: 1.5; filter: drop-shadow(0 1px 0 rgba(0,0,0,.35)); }
.heart.empty svg { fill: rgba(244,235,221,.25); }
.chirp-meter { display: flex; gap: 4px; align-items: center; }
.chirp-meter .pip { width: calc(16px * var(--ui)); height: calc(10px * var(--ui)); border-radius: 50%; border: 1.5px solid #3E2A20; background: rgba(244,235,221,.25); }
.chirp-meter .pip.full { background: var(--gold); }
.chirp-meter.silent .pip { opacity: .3; }
.trio { display: flex; gap: 6px; margin-top: 4px; }
.portrait { width: 52px; height: 52px; border-radius: 50%; border: 2.5px solid rgba(244,235,221,.55); background: rgba(42,32,26,.55); padding: 0; overflow: hidden; display: grid; place-items: center; cursor: pointer; color: var(--night); font-size: 14px; font-weight: 700; }
.portrait img { width: 130%; height: 130%; object-fit: contain; }
.portrait.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(232,184,90,.4); }
.portrait.queued { animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { border-color: transparent; } }
.hud-right { position: absolute; right: calc(12px + env(safe-area-inset-right)); top: calc(10px + env(safe-area-inset-top)); display: flex; gap: 8px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(244,235,221,.6); background: rgba(42,32,26,.55); color: var(--paper); display: grid; place-items: center; cursor: pointer; padding: 0; }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }
.prompt, .hint, .toast, .item-card { background: rgba(42,32,26,.82); border: 2px solid rgba(244,235,221,.35); border-radius: 14px; color: var(--paper); font-size: max(15px, calc(17px * var(--ui))); line-height: 1.35; }
.prompt { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom)); padding: 6px 14px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.hint { position: absolute; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top)); max-width: min(60%, 640px); padding: 8px 16px; text-align: center; text-wrap: balance; }
.hint[hidden], .prompt[hidden], .item-card[hidden], .listen[hidden] { display: none; }
.toasts { position: absolute; left: 50%; transform: translateX(-50%); top: 30%; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast { padding: 6px 14px; text-wrap: balance; text-align: center; max-width: 70vw; animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.item-card { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); padding: 14px 26px; text-align: center; border-color: var(--gold); animation: pop .3s ease-out; }
.card-kicker { font-size: .8em; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.card-name { font-size: 1.5em; font-weight: 800; margin: 2px 0 6px; }
.card-verb { display: flex; gap: 4px; align-items: center; justify-content: center; flex-wrap: wrap; }
.cap { display: inline-flex; align-items: center; justify-content: center; min-width: 1.7em; height: 1.6em; padding: 0 .4em; border: 2px solid var(--paper); border-bottom-width: 3.5px; border-radius: 6px; font-weight: 800; font-size: .9em; background: rgba(244,235,221,.12); }
.cap-pad, .cap-glyph { border-radius: 50%; min-width: 1.8em; height: 1.8em; padding: 0 .3em; }
.cap-glyph svg { width: 1.1em; height: 1.1em; color: var(--paper); }
.cap-touch { border-radius: 999px; }
.listen { position: absolute; left: 50%; bottom: calc(76px + 50px * var(--ui) + env(safe-area-inset-bottom)); transform: translateX(-50%); }
.listen-arrow { width: calc(104px * var(--ui)); height: calc(104px * var(--ui)); border-radius: 50%; box-shadow: 0 0 22px 8px rgba(232,184,90,.35); /* [final-S] bigger, a soft glow */ background: rgba(42,32,26,.45) no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 60'%3E%3Cpath d='M10 30h32M34 18l14 12-14 12' fill='none' stroke='%23F4EBDD' stroke-width='6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-size: 74%; filter: drop-shadow(0 0 6px rgba(232,184,90,.9)) drop-shadow(0 2px 2px rgba(0,0,0,.5)); }

/* ---- menus ---- */
.menus { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 40%, rgba(59,74,122,.55), rgba(20,16,14,.88)); }
.menus[hidden], .menus:empty { display: none; }
.panel { min-width: min(420px, 80%); max-width: 90%; max-height: 92%; overflow: auto; padding: 22px 30px; text-align: center; background: rgba(42,32,26,.88); border: 2px solid rgba(244,235,221,.35); border-radius: 22px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.panel h1 { font-family: "Patrick Hand", "Comic Sans MS", cursive; font-size: clamp(36px, 7vw, 72px); margin: 0 0 4px; color: var(--paper); text-wrap: balance; letter-spacing: .02em; }
.panel h2 { font-size: clamp(22px, 3.5vw, 32px); margin: 0 0 10px; text-wrap: balance; }
.panel .sub { margin: 0 0 16px; font-size: max(15px, 1.05em); opacity: .9; text-wrap: balance; }
.panel .note { margin: 14px 0 0; font-size: 16px; color: var(--gold); text-wrap: balance; }
.panel .note:empty { display: none; }
.panel-press .note { animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .5; } }
.menu-list { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.menu-btn { min-height: 44px; padding: 8px 20px; font-size: max(16px, 1.1em); font-weight: 700; color: var(--paper); background: rgba(244,235,221,.08); border: 2px solid rgba(244,235,221,.3); border-radius: 12px; cursor: pointer; outline: none; }
.menu-btn.focus { border-color: var(--gold); background: rgba(232,184,90,.22); box-shadow: 0 0 0 3px rgba(232,184,90,.35); }
.menu-btn:disabled { opacity: .4; cursor: default; }
.howto { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px 20px; margin: 0 0 16px; text-align: left; font-size: 16px; }
.howto-row { display: flex; align-items: center; gap: 8px; }

/* ---- touch controls ---- */
/* the touch layer covers the whole viewport, so on wide phones the buttons sit over the letterbox bars */
.touch-layer { position: fixed; inset: 0; display: none; pointer-events: none; z-index: 2; }
.touch-layer.on { display: block; }
.touch-stick-zone { position: absolute; left: 0; top: 30%; width: 33%; bottom: 0; pointer-events: auto; touch-action: none; }
.touch-stick-base { position: absolute; width: 140px; height: 140px; margin: -70px 0 0 -70px; border-radius: 50%; background: rgba(244,235,221,.16); border: 2px solid rgba(244,235,221,.35); pointer-events: none; }
.touch-stick-base[hidden] { display: none; }
.touch-stick-knob { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; border-radius: 50%; background: rgba(244,235,221,.45); transform: translate(-50%,-50%); }
.touch-btn { position: absolute; display: grid; place-items: center; border-radius: 50%; pointer-events: auto; touch-action: none; color: rgba(42,32,26,.9); font-weight: 800; font-size: 14px; background: radial-gradient(circle at 40% 35%, rgba(244,235,221,.6), rgba(214,196,170,.45) 60%, rgba(160,130,100,.35)); border: 2px solid rgba(244,235,221,.6); }
.touch-btn.down { background: rgba(232,184,90,.75); }
.touch-btn[hidden] { display: none; }
.tb-jump  { width: 88px; height: 88px; right: calc(14px + env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom)); }
.tb-use   { width: 72px; height: 72px; right: calc(112px + env(safe-area-inset-right)); bottom: calc(22px + env(safe-area-inset-bottom)); }
.tb-chirp { width: 72px; height: 72px; right: calc(22px + env(safe-area-inset-right)); bottom: calc(112px + env(safe-area-inset-bottom)); }
.tb-kick  { width: 64px; height: 64px; right: calc(116px + env(safe-area-inset-right)); bottom: calc(104px + env(safe-area-inset-bottom)); }
.tb-ear   { width: 64px; height: 64px; right: calc(194px + env(safe-area-inset-right)); bottom: calc(26px + env(safe-area-inset-bottom)); }

/* ---- turn your phone ---- */
.rotate-note { display: none; position: fixed; inset: 0; z-index: 10; background: var(--night); color: var(--paper); place-items: center; align-content: center; text-align: center; font-size: 20px; padding: 20px; }
.rotate-icon { width: 60px; height: 96px; border: 4px solid var(--paper); border-radius: 12px; margin: 0 auto 16px; animation: turn 2s ease-in-out infinite; }
@keyframes turn { 50% { transform: rotate(90deg); } }
@media (orientation: portrait) and (pointer: coarse) { .rotate-note { display: grid; } }
/* [orchestrator] phones: keep the sign banner clear of the HUD icon row */
@media (max-width: 1000px) { .hint { top: calc(64px + env(safe-area-inset-top)); max-width: min(64%, 560px); font-size: max(14px, calc(15px * var(--ui))); } }
/* [final-G] wide touch screens (the view fills the width, the cricket sits ~40% down): the sign banner goes up between the
   hearts and the icon row, so it never covers him */
@media (max-height: 500px) and (pointer: coarse) { .hint { top: calc(6px + env(safe-area-inset-top)); max-width: min(42%, 460px); font-size: 13px; line-height: 1.25; padding: 5px 10px; }
  .toasts { top: calc(80px + env(safe-area-inset-top)); } .toast { font-size: 13px; line-height: 1.25; max-width: min(56vw, 480px); } }
