:root {
  --cream: #fff4e0;
  --paper: #fff9ee;
  --honey: #e8a53c;
  --honey-d: #b8741e;
  --rose: #d9534f;
  --rose-d: #a8322f;
  --green: #6fae4a;
  --ink: #4a2a18;
  --muted: #8a6a50;
  --shadow: 0 6px 0 rgba(74, 42, 24, 0.25), 0 12px 24px rgba(40, 20, 10, 0.25);
  --font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", "Varela Round", "Trebuchet MS", system-ui, sans-serif;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2a1a12; color: var(--ink); font-family: var(--font); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.hidden { display: none !important; }
#view { position: fixed; inset: 0; }
#view canvas { display: block; touch-action: none; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 55%, rgba(40,15,0,0.45) 100%); }
#fx-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
button { font-family: var(--font); cursor: pointer; color: inherit; }
kbd { font-family: var(--font); font-size: 0.75em; padding: 1px 6px; border-radius: 6px; background: var(--ink); color: var(--cream); }

/* floating score texts */
.ftext { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 26px; text-shadow: 0 2px 0 #4a2a18, 0 0 10px rgba(0,0,0,0.4); white-space: nowrap; text-align: center; -webkit-text-stroke: 1px rgba(74,42,24,0.5); }
.ftext small { display: block; font-size: 14px; color: #fff; -webkit-text-stroke: 0; }

/* speech bubbles */
.bubble { position: fixed; z-index: 6; left: 0; top: 0; padding: 6px 14px; border-radius: 18px; background: #fff; color: var(--ink); font-weight: 800; font-size: 18px; box-shadow: 0 4px 0 rgba(0,0,0,0.2); transform: translate(-50%, -100%) scale(0); transition: transform 0.18s; pointer-events: none; white-space: nowrap; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -9px; margin-left: -8px; border: 9px solid transparent; border-top-color: #fff; border-bottom: 0; }
.bubble.show { transform: translate(-50%, -100%) scale(1); }
.bubble.zzz { background: #e8f0ff; color: #5a6ab0; font-style: italic; }
.bubble.big { font-size: 34px; padding: 2px 16px; color: var(--rose); }
#act-bubble { position: fixed; z-index: 6; transform: translate(-50%, -100%); display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 8px; border-radius: 20px; background: rgba(255, 249, 238, 0.95); box-shadow: 0 3px 0 rgba(74,42,24,0.3); font-size: 15px; pointer-events: none; overflow: hidden; animation: bob 0.8s ease-in-out infinite alternate; }
#act-bubble #act-icon { font-size: 20px; }
#act-bubble i { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--rose); width: 0; }
body.touch #act-key { display: none; }
@keyframes bob { from { margin-top: 0; } to { margin-top: -5px; } }

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
#hud-top { position: absolute; top: 10px; left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); display: flex; justify-content: space-between; align-items: flex-start; }
.pill { background: rgba(255, 249, 238, 0.92); border-radius: 18px; box-shadow: var(--shadow); padding: 6px 14px; display: flex; align-items: center; gap: 8px; }
.pill small { font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--muted); display: block; }
#hud-score b { font-size: 28px; font-weight: 900; min-width: 70px; }
.combo { font-weight: 900; font-size: 22px; color: #fff; background: var(--rose); border-radius: 12px; padding: 1px 9px; transform: scale(0); transition: transform 0.15s; }
.combo.on { transform: scale(1); }
.combo.pop { animation: pop 0.3s; }
@keyframes pop { 50% { transform: scale(1.5); } }
#hud-timer { position: absolute; left: 50%; transform: translateX(-50%); width: 70px; height: 70px; }
#hud-timer svg { width: 100%; height: 100%; transform: rotate(-90deg); filter: drop-shadow(0 4px 0 rgba(74,42,24,0.3)); }
#hud-timer .bg { fill: rgba(255,249,238,0.95); stroke: #f0dcc0; stroke-width: 6; }
#hud-timer .fg { fill: none; stroke: var(--green); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 176; transition: stroke 0.3s; }
#hud-timer span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; font-weight: 900; }
#hud-timer.low .fg { stroke: var(--rose); }
#hud-timer.low span { color: var(--rose); animation: pop 1s infinite; }
#hud-right { display: flex; gap: 10px; align-items: flex-start; }
#hud-mamie span { font-size: 28px; }
#hud-mamie.s3 { background: #ffd8d0; animation: pop 0.6s infinite; }
.gauge { width: 130px; height: 12px; border-radius: 8px; background: #ecd9bd; overflow: hidden; margin-top: 3px; }
.gauge i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #8ac46a, #e8c040, #e0603a); border-radius: 8px; transition: width 0.15s; }
.gauge.culot i { background: linear-gradient(90deg, #e05a8a, #f09a4a); }
.round-btn { pointer-events: auto; width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,249,238,0.92); box-shadow: var(--shadow); font-size: 18px; font-weight: 900; }
#hud-culot { position: absolute; top: 76px; left: calc(12px + var(--safe-l)); padding: 5px 12px; }
#hud-culot span { font-size: 24px; }
#hud-culot.hurt { animation: shake 0.4s; background: #ffd0d0; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.tip { position: absolute; left: 50%; top: 92px; transform: translateX(-50%) scale(0.8); opacity: 0; max-width: min(560px, 80vw); text-align: center; background: var(--ink); color: var(--cream); padding: 10px 18px; border-radius: 16px; font-weight: 700; font-size: 17px; transition: opacity 0.25s, transform 0.25s; box-shadow: var(--shadow); }
.tip.show { opacity: 1; transform: translateX(-50%) scale(1); }
#hypno { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); background: #fff0f6; padding: 12px 20px; border-radius: 18px; text-align: center; box-shadow: var(--shadow); font-size: 22px; animation: pop 0.5s infinite; }
#hypno .gauge { width: 200px; height: 16px; }
#kb-help { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); background: rgba(74,42,24,0.7); color: var(--cream); border-radius: 12px; padding: 5px 14px; font-size: 13px; white-space: nowrap; }
body.touch #kb-help, body.pad #kb-help { display: none; }

/* ---------------- touch controls ---------------- */
#touch-ui { display: none; }
body.touch.in-game #touch-ui { display: block; }
body.in-game.paused #touch-ui { display: none; }
#joy-zone { position: fixed; left: 0; top: 90px; bottom: 0; width: 50vw; z-index: 3; touch-action: none; }
#joy-base { position: fixed; width: 128px; height: 128px; margin: -64px 0 0 -64px; border-radius: 50%; background: rgba(255,249,238,0.2); border: 3px solid rgba(255,249,238,0.55); display: none; z-index: 3; pointer-events: none; left: 120px; top: 70%; }
#joy-base.on { display: block; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; border-radius: 50%; background: rgba(255,249,238,0.85); transform: translate(-50%, -50%); box-shadow: 0 3px 0 rgba(74,42,24,0.3); }
.tbtn { position: fixed; z-index: 4; border: 0; border-radius: 50%; width: 76px; height: 76px; background: rgba(255,249,238,0.9); box-shadow: 0 5px 0 rgba(74,42,24,0.35); display: flex; flex-direction: column; align-items: center; justify-content: center; touch-action: none; overflow: hidden; }
.tbtn span { font-size: 28px; line-height: 1; }
.tbtn small { font-size: 9px; font-weight: 900; letter-spacing: 0.5px; margin-top: 2px; }
.tbtn.down { transform: translateY(4px); box-shadow: 0 1px 0 rgba(74,42,24,0.35); }
#tb-action { width: 104px; height: 104px; right: calc(24px + var(--safe-r)); bottom: 28px; background: #ffe7c0; }
#tb-action span { font-size: 38px; }
#tb-action.ready { background: #ffd26a; animation: glow 0.8s infinite alternate; }
@keyframes glow { to { box-shadow: 0 5px 0 rgba(74,42,24,0.35), 0 0 26px #ffd26a; } }
#tb-action-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(217,83,79,0.35); }
#tb-jump { right: calc(140px + var(--safe-r)); bottom: 22px; }
#tb-crawl { right: calc(40px + var(--safe-r)); bottom: 146px; width: 64px; height: 64px; }
#tb-crawl.on { background: #bfe39a; }

/* ---------------- screens ---------------- */
.screen { position: fixed; inset: 0; z-index: 10; display: none; align-items: center; justify-content: center; padding: 16px calc(16px + var(--safe-r)) 16px calc(16px + var(--safe-l)); }
.screen.active { display: flex; }
.screen.transparent { background: none; }
.screen.modal { background: rgba(42, 26, 18, 0.55); z-index: 12; }
.art { position: absolute; inset: 0; background-size: cover; background-position: center; }
.art.dim::after { content: ''; position: absolute; inset: 0; background: rgba(42, 26, 18, 0.55); }
.title-box { position: relative; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px 30px; }
.logo { margin: 0; font-size: clamp(48px, 10vw, 104px); font-weight: 900; line-height: 0.95; letter-spacing: -1px; transform: rotate(-3deg); }
.logo span { display: inline-block; color: #ffd25e; -webkit-text-stroke: 3px #4a2a18; text-shadow: 0 6px 0 #4a2a18, 0 12px 20px rgba(0,0,0,0.5); }
.logo span + span { color: #ff7a6a; margin-left: 4px; }
.tagline { margin: 0; font-weight: 800; color: #fff; font-size: 20px; text-shadow: 0 2px 4px rgba(0,0,0,0.7); }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.who { color: #fff; font-weight: 700; text-shadow: 0 2px 4px rgba(0,0,0,0.8); font-size: 15px; }
.btn { border: 0; border-radius: 16px; padding: 11px 18px; font-size: 17px; font-weight: 800; background: var(--paper); color: var(--ink); box-shadow: 0 5px 0 rgba(74,42,24,0.35); transition: transform 0.08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(74,42,24,0.35); }
.btn.big { font-size: 24px; padding: 14px 34px; }
.btn.primary { background: linear-gradient(#ffd25e, #e8a53c); color: #4a2a18; box-shadow: 0 5px 0 var(--honey-d); }
.btn.small { font-size: 14px; padding: 7px 12px; border-radius: 12px; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn:disabled { opacity: 0.45; }
.panel { position: relative; background: var(--cream); border-radius: 26px; box-shadow: var(--shadow); padding: 16px 20px; max-height: 100%; width: min(620px, 100%); display: flex; flex-direction: column; gap: 10px; }
.panel.wide { width: min(900px, 100%); }
.panel.small { width: min(380px, 100%); align-items: stretch; text-align: center; }
.panel.side { margin-left: auto; width: min(430px, 56vw); height: 100%; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel h2 { margin: 0; font-size: 24px; font-weight: 900; }
.panel h3 { margin: 8px 0 4px; font-size: 15px; color: var(--muted); }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; flex: 1; }
.name-row { display: flex; align-items: center; gap: 6px; }
.name-row b { flex: 1; font-size: 19px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border: 0; border-radius: 12px; padding: 6px 10px; font-weight: 800; font-size: 13px; background: #f3e2c4; }
.tabs button.on { background: var(--honey); color: #fff; }
.tab-body { display: flex; flex-direction: column; gap: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.card { border: 3px solid transparent; background: var(--paper); border-radius: 16px; padding: 8px 10px; text-align: left; box-shadow: 0 3px 0 rgba(74,42,24,0.2); }
.card.on { border-color: var(--honey); background: #fff1d6; }
.card b { display: block; font-size: 15px; }
.card small { display: block; font-size: 12px; color: var(--green); font-weight: 700; }
.card small.con { color: var(--rose); }
.card.locked { opacity: 0.55; }
.card .lock { float: right; font-size: 12px; font-weight: 900; color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 44px; height: 44px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 3px 0 rgba(74,42,24,0.25); position: relative; }
.sw.on { outline: 3px solid var(--honey); outline-offset: 2px; }
.chip { border: 0; border-radius: 14px; padding: 8px 12px; background: var(--paper); font-weight: 800; font-size: 14px; box-shadow: 0 3px 0 rgba(74,42,24,0.2); }
.chip.on { background: var(--honey); color: #fff; }
.chip.locked { opacity: 0.5; }
.chip small { font-size: 10px; margin-left: 4px; }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.lvl { position: relative; border-radius: 18px; overflow: hidden; background: #2a1a12; color: #fff; border: 0; padding: 0; text-align: left; box-shadow: var(--shadow); min-height: 180px; display: flex; flex-direction: column; justify-content: flex-end; }
.lvl .img { position: absolute; inset: 0; background-size: cover; background-position: center; }
.lvl .img.soon { background: repeating-linear-gradient(45deg, #5a3a26, #5a3a26 12px, #4a2e1e 12px, #4a2e1e 24px); }
.lvl .info { position: relative; padding: 10px 12px; background: linear-gradient(transparent, rgba(30,15,5,0.9) 35%); }
.lvl b { font-size: 17px; display: block; }
.lvl small { opacity: 0.85; }
.lvl .st { color: #ffd25e; font-size: 20px; letter-spacing: 2px; }
.lvl .st i { font-style: normal; opacity: 0.3; }
.lvl .st i.on { opacity: 1; }
.lvl ul { margin: 4px 0 0; padding-left: 18px; font-size: 12px; }
.lvl li.done { color: #bff58a; }
.lvl.locked { opacity: 0.7; }
.star-count { font-weight: 900; color: var(--honey-d); font-size: 18px; }
.board .rowb { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 12px; }
.board .rowb:nth-child(odd) { background: #f7e8cf; }
.board .rowb.me { background: #ffe0a0; }
.board .rk { width: 28px; font-weight: 900; font-size: 18px; text-align: center; }
.board .dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 2px 0 rgba(0,0,0,0.2); }
.board .nm { flex: 1; font-weight: 800; }
.board .sc { font-weight: 900; }
.board .empty { text-align: center; color: var(--muted); padding: 20px; }
.board .gap { text-align: center; color: var(--muted); padding: 2px; }
.board .hint { text-align: center; color: var(--muted); font-size: 13px; padding: 8px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 800; padding: 8px 4px; }
.opt input[type=range] { flex: 1; max-width: 220px; accent-color: var(--honey); }
.opt input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--honey); }
.privacy { font-size: 13px; color: var(--muted); background: var(--paper); border-radius: 12px; padding: 10px; margin-top: 8px; line-height: 1.4; }
.panel.end { width: min(760px, 100%); }
.end-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 14px; min-height: 0; flex: 1; }
.end-grid > div:first-child { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.stars { font-size: 58px; letter-spacing: 6px; }
.stars i { font-style: normal; color: #e8d6b8; display: inline-block; transform: scale(0.6); transition: transform 0.3s, color 0.3s; }
.stars i.on { color: #ffc21e; transform: scale(1.1); text-shadow: 0 4px 0 #b8741e; }
.end-score b { font-size: 50px; font-weight: 900; display: block; text-align: center; line-height: 1; }
.end-score small { display: block; text-align: center; color: var(--muted); font-weight: 800; }
.end-best { margin-top: 6px; font-weight: 800; text-align: center; }
.end-best .nb { color: var(--rose); animation: pop 0.8s infinite; display: inline-block; }
.unlock { margin-top: 8px; background: #fff0c8; border-radius: 12px; padding: 6px 10px; font-weight: 800; text-align: center; }
.end-log { max-height: 46vh; }
.end-log ul { list-style: none; margin: 0; padding: 0; }
.end-log li { display: flex; justify-content: space-between; padding: 3px 6px; border-bottom: 1px dashed #e6d2b2; font-weight: 700; font-size: 15px; }
.end-log .ch li.done { color: var(--green); }
.end-log .ch li { color: var(--muted); }
#pf-list .pf { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 12px; background: var(--paper); margin-bottom: 6px; }
#pf-list .pf.on { background: #ffe8b8; }
#pf-list .pf b { flex: 1; text-align: left; }
.name-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 44vh; }
.name-cols > div { display: flex; flex-direction: column; gap: 4px; }
.name-cols .chip { text-align: center; }
.name-preview { font-weight: 900; font-size: 20px; }

/* portrait lock */
#rotate { position: fixed; inset: 0; z-index: 50; background: #3a2418; color: var(--cream); display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-weight: 800; font-size: 20px; }
#rotate div { font-size: 64px; animation: tilt 1.6s infinite; }
@keyframes tilt { 50% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }

/* small landscape phones */
@media (max-height: 460px) {
  .panel { padding: 10px 14px; gap: 6px; border-radius: 20px; }
  .panel h2 { font-size: 20px; }
  .btn.big { font-size: 20px; padding: 10px 26px; }
  .logo { font-size: 56px; }
  .tagline { font-size: 16px; }
  .title-box { gap: 8px; }
  #hud-timer { width: 58px; height: 58px; }
  #hud-timer span { font-size: 22px; }
  #hud-score b { font-size: 22px; }
  .gauge { width: 96px; }
  #hud-culot { top: 64px; }
  .tip { top: 74px; font-size: 15px; }
  .levels { gap: 8px; }
  .lvl { min-height: 150px; }
  .stars { font-size: 42px; }
  .end-score b { font-size: 38px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .card { padding: 5px 8px; }
  .sw { width: 36px; height: 36px; }
}
@media (max-width: 700px) {
  .levels { grid-template-columns: repeat(3, minmax(160px, 1fr)); overflow-x: auto; }
}
#tb-action.mash { background: #ff9ec0; animation: pop 0.35s infinite; }
#hypno b { display: block; font-size: 19px; margin-bottom: 6px; }
