/* ===== play screen: HUD, results, tutorial ===== */
#play { background: #eaf2fb; }
#playCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.hud-inner { position: absolute; left: 16px; right: 16px; top: calc(12px + var(--safe-t)); height: 84px; }
.hud-score { position: absolute; left: 0; top: 0; max-width: calc(100% - 140px); }
.hud-name { font-size: 14px; font-weight: 800; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 0 6px #fff; }
.hud-num { font-size: 28px; line-height: 1.1; font-weight: 900; color: #26355a; text-shadow: 0 0 8px #fff, 0 0 3px #fff, 0 2px 0 rgba(255,255,255,0.8); font-variant-numeric: tabular-nums; }
.hud-emblem { position: absolute; right: 64px; top: 0; width: 56px; height: 56px; filter: drop-shadow(0 3px 6px rgba(60,90,150,0.25)); }
.hud-emblem svg { display: block; }
.hud-emblem.pulse { animation: embPulse 0.45s cubic-bezier(.2,1.6,.4,1); }
.hud-emblem.shake { animation: embShake 0.35s; }
@keyframes embPulse { 0% { transform: scale(1); } 40% { transform: scale(1.35) rotate(-6deg); filter: drop-shadow(0 0 12px #e8b45a); } 100% { transform: scale(1); } }
@keyframes embShake { 0%,100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.hud-row { position: absolute; left: 0; top: 60px; width: 100%; display: flex; align-items: center; gap: 8px; }
.hud-lv { flex: none; min-width: 52px; text-align: center; padding: 2px 10px; font-size: 14px; font-weight: 900; color: #fff; border-radius: 12px;
  background: linear-gradient(160deg, #7fb0ff, #3f6fd8); box-shadow: 0 2px 6px rgba(40,80,170,0.3); text-shadow: 0 1px 0 rgba(20,40,100,0.4); }
.hud-lv.up { animation: lvUp 0.6s cubic-bezier(.2,1.6,.4,1); }
@keyframes lvUp { 0% { transform: scale(1); } 35% { transform: scale(1.4); background: #e8b45a; } 100% { transform: scale(1); } }
.hud-bar { position: relative; flex: 1 1 auto; height: 12px; border-radius: 8px; background: rgba(255,255,255,0.75); box-shadow: inset 0 0 0 1px rgba(120,150,210,0.4); overflow: hidden; }
.hud-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; border-radius: 8px; background: linear-gradient(90deg, #9cc7ff, #5b8def); }
.hud-bar.low i { background: linear-gradient(90deg, #f7a4b0, #ef7a8a); }
.hud-sec { flex: none; font-size: 16px; font-weight: 900; color: #26355a; min-width: 24px; text-shadow: 0 0 6px #fff; font-variant-numeric: tabular-nums; }

/* results */
.res-modal { text-align: center; padding: 16px 16px 18px; width: min(94%, 400px); }
.res-head { display: flex; align-items: center; justify-content: center; gap: 10px; }
.res-head h2 { font-size: 20px; color: var(--ink); }
.res-crest svg { display: block; }
/* Leo on the left, his speech bubble in its own column on the right: they never overlap */
.res-leo { position: relative; height: 130px; margin: 4px 0 0; display: grid; grid-template-columns: 130px minmax(0, 200px); justify-content: center; align-items: start; column-gap: 14px; }
.res-leobox { width: 130px; height: 130px; grid-column: 1; grid-row: 1; }
.res-bubble { position: relative; grid-column: 2; grid-row: 1; justify-self: start; margin-top: 10px; max-height: 116px; overflow: hidden; background: #fff; border-radius: 16px; padding: 8px 12px; font-size: 14px; font-weight: 700; color: var(--ink);
  box-shadow: 0 4px 12px rgba(60,90,150,0.2); text-align: left; line-height: 1.3; }
.res-bubble::before { content: ""; position: absolute; left: -7px; top: 18px; border: 7px solid transparent; border-right-color: #fff; border-left: 0; }
.res-bubble.pop { animation: popIn 0.25s cubic-bezier(.2,1.5,.4,1); }
.res-scorewrap { position: relative; padding: 4px 0 2px; }
.res-fx { position: absolute; left: 0; top: -20px; width: 100%; height: calc(100% + 40px); z-index: 0; pointer-events: none; }
.res-label { position: relative; font-size: 14px; font-weight: 800; color: var(--sub); }
.res-score { position: relative; font-size: 46px; line-height: 1.05; font-weight: 900; color: var(--ink); text-shadow: 0 3px 0 rgba(255,255,255,0.9), 0 0 14px rgba(232,180,90,0.35); font-variant-numeric: tabular-nums; }
.ribbon { position: relative; display: inline-block; margin-top: 4px; padding: 4px 18px; font-size: 15px; font-weight: 900; color: #fff; letter-spacing: 0.05em;
  background: linear-gradient(160deg, #f3c776, #d49a35); border-radius: 8px; box-shadow: 0 4px 10px rgba(170,120,40,0.4), inset 0 0 0 2px rgba(255,255,255,0.5);
  text-shadow: 0 1px 0 rgba(120,70,0,0.5); animation: ribbonSlam 0.55s 0.5s cubic-bezier(.2,1.8,.4,1) both; }
@keyframes ribbonSlam { 0% { transform: scale(3) rotate(-8deg); opacity: 0; } 100% { transform: scale(1) rotate(-3deg); opacity: 1; } }
.res-best { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 800; color: var(--sub); margin: 6px 0 10px; }
.res-best svg { width: 16px; height: 16px; color: var(--gold-d); }
.res-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.res-tile { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 2px; background: rgba(255,255,255,0.85); border: 1px solid var(--card-line); border-radius: 14px; min-width: 0; }
.res-tile b { font-size: 16px; font-weight: 900; color: var(--ink); }
.res-tile span { font-size: 12px; color: var(--sub); font-weight: 700; line-height: 1.15; }
.res-ic { color: var(--blue); height: 22px; }
.res-ic svg { width: 22px; height: 22px; }
.res-daily { margin-top: 10px; padding: 8px 12px; border-radius: 14px; background: linear-gradient(160deg, #fbe3b0, #f0c36e); color: #6b4510; display: flex; flex-direction: column; font-size: 14px; animation: popIn 0.4s 0.3s both cubic-bezier(.2,1.5,.4,1); }
.res-daily b { font-size: 16px; font-weight: 900; }
.res-gold { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; font-size: 14px; font-weight: 800; color: var(--sub); }
.res-gold img { width: 28px; height: 28px; object-fit: contain; }
.res-gold b { font-size: 22px; font-weight: 900; color: var(--gold-d); }
.res-ad { margin-top: 10px; width: 100%; font-size: 15px; }
.res-btns { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.res-btns .res-main { flex: 1 1 auto; min-width: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-btns .res-sec { white-space: nowrap; }
.res-btns .res-sec { flex: none; min-width: 72px; font-size: 15px; padding: 0 12px; }
.res-btns .res-trophy { flex: none; }

/* tutorial */
.tut { text-align: center; }
.tut-head { display: flex; align-items: center; gap: 12px; text-align: left; margin-bottom: 10px; }
.tut-head h2 { font-size: 20px; color: var(--ink); margin-bottom: 4px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 10px; color: #fff; font-size: 14px; font-weight: 800; text-shadow: 0 1px 0 rgba(0,0,0,0.25); }
.tut-demo { display: block; width: 100%; max-width: 320px; height: clamp(150px, 30vh, 210px); margin: 0 auto; border-radius: 18px; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.8), 0 4px 14px rgba(60,90,150,0.18); }
.tut-text { font-size: 15px; line-height: 1.5; font-weight: 700; color: var(--ink); margin: 12px 4px 14px; text-wrap: balance; line-break: strict; overflow-wrap: normal; hyphens: none; }
.tut-go { width: 100%; white-space: nowrap; }
.tut-head h2 { line-height: 1.2; text-wrap: balance; }
.ph, .ph .w { display: inline-block; max-width: 100%; }
