/* Arcadia — play view: HUD, bezel, CRT effects, overlays, initials, touch pad */
.play {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: radial-gradient(900px 500px at 50% 0%, rgba(var(--c5-rgb), .2), transparent 70%), radial-gradient(700px 400px at 50% 100%, rgba(var(--c0-rgb), .12), transparent 70%), var(--bg);
  animation: play-in .45s var(--ease);
}
@keyframes play-in { from { opacity: 0; transform: scale(1.04); } }
.hud { display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 12px; flex: none; border-bottom: 1px solid rgba(var(--fg-rgb), .08); background: rgba(0,0,0,.2); }
.hud-title { margin: 0; font-size: .95rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--c1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 auto; text-shadow: 0 0 12px rgba(var(--c1-rgb), .5); }
.hud-stats { display: flex; gap: 16px; flex: none; }
.stat { display: grid; line-height: 1.05; text-align: right; }
.stat small { font-size: .62rem; letter-spacing: .2em; color: var(--muted); }
.stat b { font-size: 1.1rem; font-variant-numeric: tabular-nums; color: var(--c2); min-width: 3ch; }
#hud-hi-wrap b { color: var(--c3); }
#hud-hi-wrap.beat b { color: var(--c0); animation: hl-blink .6s steps(2) 6; }
.hud-actions { display: flex; gap: 6px; flex: none; }
@media (max-width: 640px) {
  .hud { gap: 6px; padding: 0 8px; height: 54px; }
  .hud-title { display: none; }
  .hud-stats { flex: 1; justify-content: center; gap: 12px; }
  .hud-actions .icon-btn { width: 40px; height: 40px; }
  #btn-crt { display: none; }
}
@media (max-width: 380px) { #btn-hud-settings { display: none; } }

.bezel { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 10px; }
.crt {
  position: relative; flex: none; background: #000; border-radius: 8px; overflow: hidden; width: 320px; height: 240px;
  box-shadow: 0 0 0 8px #0a0a0f, 0 0 0 10px rgba(var(--fg-rgb), .14), 0 24px 60px rgba(0,0,0,.6), 0 0 90px -24px var(--c0);
  transition: border-radius .3s;
}
.crt canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; outline: none; -webkit-user-select: none; user-select: none; }
.crt canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--c2); }
.crt-scan, .crt-vignette, .crt-glare { position: absolute; inset: 0; pointer-events: none; display: none; }
.crt.fx-scan .crt-scan { display: block; background: repeating-linear-gradient(180deg, rgba(0,0,0,.32) 0 1px, transparent 1px 3px); }
.crt.fx-curve { border-radius: 26px / 22px; }
.crt.fx-curve .crt-vignette { display: block; background: radial-gradient(ellipse 75% 70% at 50% 50%, transparent 62%, rgba(0,0,0,.6) 100%); box-shadow: inset 0 0 50px rgba(0,0,0,.55), inset 0 0 6px rgba(0,0,0,.9); border-radius: inherit; }
.crt.fx-curve .crt-glare { display: block; background: radial-gradient(ellipse 60% 40% at 28% 12%, rgba(255,255,255,.10), transparent 60%), linear-gradient(180deg, rgba(255,255,255,.035), transparent 30%); border-radius: inherit; }
.crt.fx-chroma canvas { filter: url(#crt-chroma); }
.crt.fx-glow canvas { filter: saturate(1.18) brightness(1.06) contrast(1.04); }
.crt.fx-glow.fx-chroma canvas { filter: url(#crt-chroma) saturate(1.18) brightness(1.06) contrast(1.04); }
.crt.fx-glow { box-shadow: 0 0 0 8px #0a0a0f, 0 0 0 10px rgba(var(--fg-rgb), .14), 0 24px 60px rgba(0,0,0,.6), 0 0 110px -16px var(--c1); }
.crt.fx-flicker .crt-scan { animation: flicker .12s steps(2) infinite; }
.crt.fx-flicker .crt-vignette::after { content: ""; position: absolute; left: 0; right: 0; height: 26%; background: linear-gradient(180deg, transparent, rgba(255,255,255,.045), transparent); animation: roll 7s linear infinite; }
.crt.fx-flicker:not(.fx-curve) .crt-vignette { display: block; background: none; box-shadow: none; }
@keyframes flicker { 0% { opacity: .86; } 100% { opacity: 1; } }

.play-help { margin: 0; padding: 4px 12px 10px; text-align: center; font-size: .74rem; color: var(--muted); flex: none; }
body.has-pad .play-help { display: none; }
@media (max-height: 560px) { .play-help { display: none; } }

/* overlays live above the whole play area so small game screens still fit them */
.overlay {
  position: fixed; left: 0; right: 0; bottom: 0; top: calc(60px + env(safe-area-inset-top)); z-index: 45; display: flex; align-items: center; justify-content: center;
  padding: 14px; overflow: auto; background: rgba(var(--bg-rgb), .72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: ov-in .3s var(--ease);
}
@media (max-width: 640px) { .overlay { top: calc(54px + env(safe-area-inset-top)); } }
@keyframes ov-in { from { opacity: 0; } }
.ov-card {
  width: min(500px, 100%); margin: auto; padding: 22px 20px; border-radius: 18px; text-align: center;
  background: linear-gradient(180deg, rgba(var(--c0-rgb), .10), transparent 120px), rgba(var(--bg2-rgb), .94);
  box-shadow: inset 0 0 0 2px rgba(var(--c0-rgb), .55), 0 30px 70px rgba(0,0,0,.6), 0 0 60px -20px var(--c0);
  animation: card-pop .4s var(--ease);
}
@keyframes card-pop { from { transform: translateY(10px) scale(.96); opacity: 0; } }
.ov-title { display: flex; justify-content: center; color: var(--c2); }
.ov-title .px-svg { height: clamp(26px, 6vw, 44px); filter: drop-shadow(0 0 10px rgba(var(--c2-rgb), .6)) drop-shadow(3px 3px 0 rgba(var(--c0-rgb), .75)); }
.ov-tag { margin: 10px 0 0; color: var(--c1); font-weight: 700; }
.mode-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 16px 0 4px; }
.mode-btn { min-height: 40px; padding: 8px 14px; border: 0; border-radius: 10px; font-size: .8rem; font-weight: 700; background: rgba(var(--fg-rgb), .06); color: var(--fg); box-shadow: inset 0 0 0 2px rgba(var(--fg-rgb), .2); transition: box-shadow .2s, background .2s; }
.mode-btn:hover { box-shadow: inset 0 0 0 2px var(--c1); }
.mode-btn[aria-pressed="true"] { background: var(--c1); color: var(--bg); box-shadow: 0 0 18px -2px var(--c1); }
.ov-controls { list-style: none; margin: 14px auto 0; padding: 12px 14px; display: grid; gap: 4px; max-width: 420px; text-align: left; font-size: .8rem; color: rgba(var(--fg-rgb), .85); background: rgba(0,0,0,.25); border-radius: 10px; }
.ov-controls li::before { content: "▸ "; color: var(--c3); }
.ov-best { margin: 12px 0 0; font-size: .8rem; font-weight: 700; color: var(--c3); letter-spacing: .06em; }
.ov-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }
.ov-actions.col { flex-direction: column; align-items: stretch; max-width: 280px; margin-left: auto; margin-right: auto; }
.ov-joke { margin: 16px 0 0; font-size: .78rem; color: var(--muted); font-style: italic; }
.ov-score { margin: 14px 0 0; display: flex; align-items: baseline; justify-content: center; gap: 10px; }
.ov-score small { font-size: .7rem; letter-spacing: .2em; color: var(--muted); }
.ov-score b { font-size: 2.1rem; color: var(--c2); font-variant-numeric: tabular-nums; text-shadow: 0 0 16px rgba(var(--c2-rgb), .6); }
.ov-msg { margin: 6px 0 0; color: rgba(var(--fg-rgb), .86); font-size: .88rem; }
.ov-table { margin-top: 14px; max-height: 38vh; overflow: auto; text-align: left; }
.ov-table .score-table li { padding: 5px 10px; font-size: .86rem; }
.blink-soft { animation: blink-soft 1.4s ease-in-out infinite; }
@keyframes blink-soft { 50% { box-shadow: 0 4px 0 rgba(0,0,0,.5), 0 0 40px rgba(var(--c0-rgb), .8); } }

.ini-entry { margin-top: 14px; padding: 14px; border-radius: 14px; background: rgba(0,0,0,.25); outline: none; }
.ini-entry:focus-visible { box-shadow: inset 0 0 0 2px var(--c2); }
.ini-title { margin: 0 0 10px; font-weight: 800; color: var(--c0); }
.ini-slots { display: flex; justify-content: center; gap: 12px; }
.ini-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ini-arrow { width: 52px; height: 32px; border: 0; border-radius: 8px; background: rgba(var(--fg-rgb), .08); color: var(--fg); font-size: .8rem; }
.ini-arrow:hover { background: var(--c1); color: var(--bg); }
.ini-slot { width: 56px; height: 64px; border: 0; border-radius: 10px; font-size: 2rem; font-weight: 800; color: var(--c2); background: rgba(var(--bg-rgb), .85); box-shadow: inset 0 0 0 2px rgba(var(--fg-rgb), .2); }
.ini-slot.cur { box-shadow: inset 0 0 0 3px var(--c2), 0 0 18px -2px var(--c2); animation: slot-blink 1s steps(2) infinite; }
@keyframes slot-blink { 50% { color: rgba(var(--c2-rgb), .35); } }
.ini-help { margin: 10px 0; font-size: .74rem; color: var(--muted); }

/* touch pad */
.touchpad { flex: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 18px calc(12px + env(safe-area-inset-bottom)); user-select: none; -webkit-user-select: none; touch-action: none; }
.tp-dpad { position: relative; width: 150px; height: 150px; flex: none; touch-action: none; border-radius: 50%; background: radial-gradient(circle, rgba(var(--fg-rgb), .05), transparent 70%); }
.tp-arm { position: absolute; background: rgba(var(--fg-rgb), .1); box-shadow: inset 0 0 0 2px rgba(var(--fg-rgb), .28); transition: background .08s; }
.tp-arm.up { left: 34%; top: 2%; width: 32%; height: 36%; border-radius: 12px 12px 4px 4px; }
.tp-arm.down { left: 34%; bottom: 2%; width: 32%; height: 36%; border-radius: 4px 4px 12px 12px; }
.tp-arm.left { top: 34%; left: 2%; height: 32%; width: 36%; border-radius: 12px 4px 4px 12px; }
.tp-arm.right { top: 34%; right: 2%; height: 32%; width: 36%; border-radius: 4px 12px 12px 4px; }
.tp-hub { position: absolute; left: 34%; top: 34%; width: 32%; height: 32%; background: rgba(var(--fg-rgb), .08); }
.tp-dpad[data-dir~="up"] .tp-arm.up, .tp-dpad[data-dir~="down"] .tp-arm.down, .tp-dpad[data-dir~="left"] .tp-arm.left, .tp-dpad[data-dir~="right"] .tp-arm.right { background: var(--c1); box-shadow: 0 0 18px var(--c1); }
.tp-dpad[data-axis="h"] .tp-arm.up, .tp-dpad[data-axis="h"] .tp-arm.down, .tp-dpad[data-axis="v"] .tp-arm.left, .tp-dpad[data-axis="v"] .tp-arm.right { opacity: .15; }
.tp-mid { flex: 1; display: flex; justify-content: center; }
.tp-small { width: 56px; height: 34px; border: 0; border-radius: 99px; font-weight: 800; font-size: .78rem; color: var(--fg); background: rgba(var(--fg-rgb), .1); box-shadow: inset 0 0 0 2px rgba(var(--fg-rgb), .25); touch-action: none; }
.tp-small.on { background: var(--c2); color: var(--bg); }
.tp-btns { display: flex; align-items: flex-end; gap: 12px; flex: none; }
.tp-btn { width: 74px; height: 74px; border: 0; border-radius: 50%; color: var(--bg); font-weight: 800; touch-action: none; -webkit-tap-highlight-color: transparent;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.4), transparent 45%), var(--c0); box-shadow: 0 6px 0 rgba(0,0,0,.45), 0 0 22px rgba(var(--c0-rgb), .4); transition: transform .06s, box-shadow .06s; }
.tp-btn span { font-size: .72rem; letter-spacing: .04em; }
.tp-b { background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.4), transparent 45%), var(--c1); box-shadow: 0 6px 0 rgba(0,0,0,.45), 0 0 22px rgba(var(--c1-rgb), .4); margin-bottom: 26px; }
.tp-c { width: 58px; height: 58px; background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.4), transparent 45%), var(--c2); margin-bottom: 52px; }
.tp-btn.on { transform: translateY(4px) scale(.95); box-shadow: 0 2px 0 rgba(0,0,0,.45), 0 0 30px var(--fg); }
@media (max-width: 380px) {
  .tp-dpad { width: 128px; height: 128px; }
  .tp-btn { width: 64px; height: 64px; }
  .tp-c { width: 50px; height: 50px; }
  .touchpad { padding-left: 10px; padding-right: 10px; }
}
@media (orientation: landscape) and (max-height: 540px) {
  body.has-pad .touchpad { position: fixed; left: 0; right: 0; bottom: 0; z-index: 42; pointer-events: none; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  body.has-pad .touchpad > * { pointer-events: auto; }
  body.has-pad .tp-mid { align-self: flex-end; }
  body.has-pad .bezel { padding-left: 180px; padding-right: 180px; }
}
body.is-fs .hud { background: rgba(0,0,0,.4); }
