@font-face { font-family: "Noto Music"; src: url("fonts/NotoMusic-Regular.ttf") format("truetype"); font-display: block; }
:root {
  --cocoa: #3d211b; --rose: #9c625e; --gold: #d4a72c; --gold-soft: #b8925a; --cream: #f8f1e7; --ink: #2a1a15;
  --ok: #2e9e5b; --bad: #d64045; --card: rgba(255, 250, 243, 0.97);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: #1f1430; color: var(--ink); overflow: hidden;
  font-family: -apple-system, "SF Pro Rounded", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
#app { position: fixed; inset: 0; overflow: hidden; }
button { touch-action: manipulation; }
.install-tip { background: #fff4d6; border-radius: 10px; padding: 6px 10px; color: var(--cocoa); }
#game { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
#game canvas { display: block; }
.hidden { display: none !important; }

/* экраны */
.screen { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: 12px;
  background: radial-gradient(circle at 30% 20%, #6b3f7a 0%, #2b1a3d 55%, #1a1026 100%); z-index: 20; overflow: auto; }
.screen.show { display: flex; }
.screen.overlay { background: rgba(20, 10, 30, 0.6); backdrop-filter: blur(2px); z-index: 30; }
.card { background: var(--card); border-radius: 22px; padding: 18px 22px; max-width: 420px; width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35); text-align: center; display: flex; flex-direction: column; gap: 10px; margin: auto; }
.card.wide { max-width: 640px; }
.brand { font-size: 11px; letter-spacing: .18em; color: var(--gold-soft); font-weight: 700; }
h1 { margin: 0; font-size: clamp(28px, 6vw, 40px); color: var(--cocoa); line-height: 1.05; }
h2 { margin: 0; font-size: 22px; color: var(--cocoa); }
h3 { margin: 4px 0; font-size: 18px; line-height: 1.3; color: var(--ink); }
.tagline { margin: 0; color: var(--rose); }
.small { font-size: 12px; color: #7a6a64; margin: 0; }
#menuHero { width: 72px; height: 96px; margin: 0 auto; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.btn { font: inherit; font-weight: 700; font-size: 16px; border: 0; border-radius: 14px; padding: 11px 20px; cursor: pointer;
  background: linear-gradient(180deg, #e2b84a, #c99a26); color: #2b1a10; box-shadow: 0 3px 0 #8f6b15; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #8f6b15; }
.btn.big { font-size: 20px; padding: 14px 28px; }
.btn.ghost { background: #efe3d3; color: var(--cocoa); box-shadow: 0 3px 0 #cdb89f; }
.btn.icon { min-width: 48px; }

/* выбор героя */
.tabs { display: flex; gap: 8px; justify-content: center; }
.tab { font: inherit; font-weight: 700; padding: 8px 18px; border-radius: 999px; border: 2px solid #e3d3bf; background: #fff; cursor: pointer; color: var(--cocoa); }
.tab.on { background: var(--cocoa); color: #fff; border-color: var(--cocoa); }
.hero-layout { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }
#heroBig { width: 108px; height: 144px; background: radial-gradient(circle, #fff7e6 0%, #f1e2c9 70%); border-radius: 18px; }
.outfits { display: flex; gap: 8px; }
.outfit { border: 3px solid transparent; background: #fff; border-radius: 14px; padding: 6px; cursor: pointer; font: inherit; font-size: 13px; color: var(--cocoa); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.outfit canvas { width: 48px; height: 64px; }
.outfit.on { border-color: var(--gold); background: #fff8e3; }

/* уровни */
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.level { border: 0; border-radius: 16px; padding: 10px 12px; text-align: left; cursor: pointer; font: inherit; color: #fff; min-height: 86px;
  display: flex; flex-direction: column; gap: 4px; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.level.forest { background: linear-gradient(160deg, #4caf50, #2d6e3a); }
.level.castle { background: linear-gradient(160deg, #7a4a86, #2a1d4a); }
.level.cave { background: linear-gradient(160deg, #3b6f8a, #1c2236); }
.level.sky { background: linear-gradient(160deg, #6bb8ff, #8a7fd8); }
.level.hall { background: linear-gradient(160deg, #a8323e, #3d1420); }
.level b { font-size: 16px; }
.level b { font-size: 18px; }
.level span { font-size: 13px; opacity: .9; }
.level .lv-stars { color: #ffd166; letter-spacing: 2px; margin-top: auto; }
.level .lv-stars small { color: #fff; letter-spacing: 0; opacity: .9; margin-left: 6px; }

/* HUD */
#hud { position: absolute; top: max(6px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right));
  display: flex; align-items: center; justify-content: space-between; gap: 8px; z-index: 10; pointer-events: none; }
.hud-left, .hud-right { display: flex; gap: 6px; align-items: center; }
.lives { font-size: 22px; color: #ff4d6d; text-shadow: 0 1px 2px rgba(0,0,0,.5); letter-spacing: 1px; }
.lives .lost { color: rgba(255,255,255,.35); }
.pill { background: rgba(0,0,0,.45); color: #fff; padding: 4px 10px; border-radius: 999px; font-size: 14px; }
.bonus-icons span { background: rgba(255,209,102,.9); border-radius: 999px; padding: 3px 8px; font-size: 13px; }
.hud-btn { pointer-events: auto; width: 38px; height: 38px; border-radius: 12px; border: 0; background: rgba(0,0,0,.45); color: #fff; font-weight: 800; font-size: 15px; cursor: pointer; }
.boss-bar { display: flex; flex-direction: column; align-items: center; color: #fff; font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.boss-bar i { display: block; width: 150px; height: 10px; background: rgba(0,0,0,.5); border-radius: 6px; overflow: hidden; }
.boss-bar em { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #e01e37, #b5179e); transition: width .3s; }

/* сенсорные кнопки */
#touch { position: absolute; inset: auto 0 0 0; height: 0; z-index: 11; }
#touch .pad { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 14px; }
#touch .left { left: max(18px, env(safe-area-inset-left)); }
#touch .right { right: max(18px, env(safe-area-inset-right)); }
#touch button { width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); background: rgba(0,0,0,.32); color: #fff; font-size: 22px; font-weight: 800; touch-action: none; }
#touch button.on { background: rgba(212,167,44,.65); }
#touch .jump { width: 74px; height: 74px; }
#touch .fire { font-size: 16px; letter-spacing: -2px; }

/* реплики */
#subtitle { position: absolute; left: 50%; transform: translateX(-50%); top: 52px; max-width: min(560px, 76vw); z-index: 12;
  background: rgba(255,250,243,.95); border-radius: 16px; padding: 8px 14px 8px 8px; display: flex; gap: 10px; align-items: center;
  font-size: 14px; line-height: 1.3; box-shadow: 0 6px 18px rgba(0,0,0,.25); pointer-events: none; }
#subtitle .avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--cocoa); color: #ffd166; display: grid; place-items: center; font-size: 17px; }

/* испытание */
.task { max-width: 520px; gap: 8px; }
.task-head { display: flex; gap: 6px; justify-content: center; }
.badge { background: var(--cocoa); color: #ffd166; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.badge.soft { background: #efe3d3; color: var(--cocoa); }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.opt { font: inherit; font-size: 16px; font-weight: 600; padding: 12px 10px; border-radius: 14px; border: 2px solid #e3d3bf; background: #fff; cursor: pointer; color: var(--ink); }
.opt:disabled { cursor: default; }
.opt.right { background: #dff5e6; border-color: var(--ok); color: #135c32; }
.opt.wrong { background: #fde2e2; border-color: var(--bad); color: #8b1e22; text-decoration: line-through; }
.opt.gone { display: none; }
.msg { margin: 0; min-height: 1.3em; font-size: 15px; color: var(--rose); }
.msg.ok { color: var(--ok); font-weight: 700; } .msg.bad { color: var(--bad); font-weight: 700; }
.msg small { display: block; color: #5e4b44; font-weight: 400; margin-top: 4px; }
.listen { margin: 0 auto; }
.tap-area { font: inherit; font-size: 18px; font-weight: 800; width: 100%; max-width: 300px; height: 92px; margin: 4px auto; border-radius: 22px;
  border: 0; background: linear-gradient(180deg, #9c625e, #6f3f3b); color: #fff; box-shadow: 0 5px 0 #4a2622; touch-action: none; cursor: pointer; }
.tap-area.hit { transform: translateY(3px); box-shadow: 0 2px 0 #4a2622; background: linear-gradient(180deg, #d4a72c, #a87f17); }
.tap-dots { margin: 6px 0 2px; display: flex; gap: 6px; justify-content: center; min-height: 14px; }
.tap-dots i { width: 12px; height: 12px; border-radius: 50%; background: #e3d3bf; }
.tap-dots i.on { background: var(--gold); }
.staff { width: 100%; max-width: 320px; margin: 0 auto; color: var(--ink); }

/* итоги */
.stars { font-size: 40px; color: #ffd166; text-shadow: 0 2px 0 #b8860b; letter-spacing: 6px; }
.stars .off { color: #e3d3bf; text-shadow: none; }
.stats { display: grid; gap: 4px; font-size: 15px; }
.stats b { color: var(--cocoa); }

#rotate { display: none; position: fixed; inset: 0; z-index: 50; background: #2b1a3d; color: #fff; text-align: center; flex-direction: column; align-items: center; justify-content: center; font-size: 18px; padding: 24px; }
#rotate div { font-size: 54px; }
@media (orientation: portrait) and (pointer: coarse) { #rotate.need { display: flex; } }
@media (pointer: coarse) { .desktop-only { display: none; } }
@media (max-height: 420px) {
  .card { padding: 12px 16px; gap: 7px; border-radius: 18px; }
  h1 { font-size: 28px; } h3 { font-size: 16px; }
  #menuHero { width: 54px; height: 72px; }
  .opt { padding: 9px 8px; font-size: 15px; }
  .tap-area { height: 70px; }
  #heroBig { width: 81px; height: 108px; }
}
