/* Dusk Duel 2: a letterboxed 16:9 arena, glass HUD, dark dusk cards, touch pads on phones. */
@font-face { font-family: "Unbounded"; font-weight: 700; font-display: swap; src: url("/assets/fonts/unbounded-700.woff2") format("woff2"); }
@font-face { font-family: "Unbounded"; font-weight: 800; font-display: swap; src: url("/assets/fonts/unbounded-800.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-weight: 500; font-display: swap; src: url("/assets/fonts/sora-500.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-weight: 700; font-display: swap; src: url("/assets/fonts/sora-700.woff2") format("woff2"); }

:root { --spawn: #31e981; --ink-on-spawn: #0b1a12; --font-display: "Unbounded", system-ui, sans-serif; --font-body: "Sora", system-ui, sans-serif; --fg: #f4f1ea; --fg-2: rgba(244, 241, 234, 0.72); --line: rgba(255, 255, 255, 0.14); --glass: rgba(14, 10, 20, 0.6); --glass-2: rgba(255, 255, 255, 0.08); --page: #120d16; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--page); color: var(--fg); font-family: var(--font-body); font-weight: 500; overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-font-smoothing: antialiased; touch-action: none; }
button { font: inherit; color: inherit; }
.stage { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(60% 50% at 50% 40%, #241a2c, #0b0810 70%); }
#game { display: block; width: min(100vw, calc(100vh * 16 / 9)); height: min(100vh, calc(100vw * 9 / 16)); outline: 0; background: #000; image-rendering: auto; }
body.touching #game { height: min(100vh, calc(100vw * 9 / 16)); }

.hud { position: fixed; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px; padding: max(8px, env(safe-area-inset-top)) 10px 6px; pointer-events: none; z-index: 10; }
.hud-brand { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; pointer-events: auto; opacity: 0.9; }
.hud-brand svg { width: 28px; height: 28px; display: block; filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); }
.hud-title { font-family: var(--font-display); font-size: 0.85rem; font-weight: 800; margin: 0; }
.hud-actions { margin-left: auto; display: flex; gap: 6px; pointer-events: auto; }
.icon-btn { width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(10px); color: var(--fg); display: grid; place-items: center; cursor: pointer; transition: transform 0.15s, background 0.15s; }
.icon-btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.14); }
.icon-btn svg { width: 17px; height: 17px; fill: currentColor; }
#btn-sound .ic-off { display: none; }
#btn-sound[aria-pressed="false"] .ic-on { display: none; }
#btn-sound[aria-pressed="false"] .ic-off { display: block; }
body.fighting .hud-brand, body.fighting #btn-help { opacity: 0.55; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(10px); z-index: 40; background: rgba(20, 14, 24, 0.92); border: 1px solid var(--line); color: var(--fg); padding: 10px 16px; border-radius: 999px; font-size: 0.88rem; font-weight: 700; opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: none; }

/* touch controls */
.touch { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
.touch[hidden] { display: none; }
.tpad { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); width: 168px; height: 168px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 4px; pointer-events: none; }
.tpad .tb:nth-child(1) { grid-column: 2; grid-row: 1; } .tpad .tb:nth-child(2) { grid-column: 1; grid-row: 2; } .tpad .tb:nth-child(3) { grid-column: 3; grid-row: 2; } .tpad .tb:nth-child(4) { grid-column: 2; grid-row: 3; }
.tbtn { position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); width: 236px; height: 170px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 6px; pointer-events: none; }
.tb { pointer-events: auto; border: 1.5px solid rgba(255,255,255,0.22); background: rgba(20, 14, 26, 0.55); color: #fff; border-radius: 16px; font-family: var(--font-display); font-weight: 800; font-size: 0.95rem; touch-action: none; display: grid; place-items: center; backdrop-filter: blur(4px); }
.tb.on { background: rgba(49, 233, 129, 0.55); border-color: var(--spawn); }
.tb-l { grid-column: 1; grid-row: 2; } .tb-h { grid-column: 2; grid-row: 2; } .tb-s { grid-column: 3; grid-row: 2; } .tb-g { grid-column: 4; grid-row: 2; }
.tb-e { grid-column: 2; grid-row: 1; } .tb-u { grid-column: 3; grid-row: 1; background: rgba(255, 190, 60, 0.3); } .tb-d { grid-column: 4; grid-row: 1; }

/* cards */
.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 12px; background: rgba(6, 4, 12, 0.6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); overflow: auto; }
.overlay[hidden] { display: none; }
.card { width: 100%; max-width: 480px; color: var(--fg); background: linear-gradient(180deg, rgba(44, 30, 46, 0.97), rgba(16, 10, 20, 0.99)); border: 1px solid var(--line); border-radius: 24px; padding: 22px 22px 20px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55); animation: pop 0.28s cubic-bezier(.2,.9,.2,1.2); max-height: calc(100dvh - 24px); overflow: auto; }
.card-wide { max-width: 760px; }
@keyframes pop { from { transform: scale(0.94) translateY(10px); opacity: 0; } }
.kicker { margin: 0 0 6px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--spawn); }
.card h2 { margin: 0 0 14px; font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; letter-spacing: -0.02em; line-height: 1.1; }
.card h3 { margin: 0 0 8px; font-family: var(--font-display); font-weight: 700; font-size: 0.9rem; }
.muted { color: var(--fg-2); margin: 0; line-height: 1.55; font-size: 0.95rem; }
.small { font-size: 0.8rem; margin-top: 10px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 999px; border: 1.5px solid transparent; font-weight: 700; font-size: 0.92rem; cursor: pointer; text-decoration: none; color: inherit; transition: transform 0.15s, box-shadow 0.15s; }
.btn-primary { background: var(--spawn); color: var(--ink-on-spawn); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(49, 233, 129, 0.35); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { border-color: var(--fg); }
.btn[hidden] { display: none; }
.row { display: flex; align-items: center; gap: 12px; margin: 8px 0; flex-wrap: wrap; }
.row[hidden] { display: none; }
.lbl { flex: none; width: 84px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-2); }
.seg { display: flex; gap: 4px; background: var(--glass-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 0.82rem; cursor: pointer; color: var(--fg-2); transition: background 0.15s, color 0.15s; }
.seg button.on { background: var(--spawn); color: var(--ink-on-spawn); }
.chk { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; color: var(--fg-2); margin: 8px 0 0; cursor: pointer; }
.chk[hidden] { display: none; }
.chk input { width: 18px; height: 18px; accent-color: var(--spawn); margin: 0; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 6px 0 14px; }
.mode { text-align: left; border: 1px solid var(--line); background: var(--glass-2); border-radius: 16px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; transition: border-color 0.15s, transform 0.15s; }
.mode:hover { border-color: var(--spawn); transform: translateY(-2px); }
.mode b { font-family: var(--font-display); font-weight: 800; font-size: 0.95rem; }
.mode span { color: var(--fg-2); font-size: 0.8rem; line-height: 1.4; }
.roster { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 6px 0 10px; }
.fighter { border: 2px solid var(--line); background: var(--glass-2); border-radius: 16px; padding: 8px 8px 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: border-color 0.15s, transform 0.15s; position: relative; }
.fighter canvas { width: 100%; height: auto; display: block; border-radius: 10px; background: linear-gradient(180deg, #2a1f35, #140c18); }
.fighter b { font-family: var(--font-display); font-weight: 800; font-size: 0.85rem; }
.fighter small { color: var(--fg-2); font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; }
.fighter.p1 { border-color: #31e981; } .fighter.p2 { border-color: #ff6b6b; } .fighter.p1.p2 { border-color: #ffd34d; }
.fighter.locked { opacity: 0.45; }
.fighter.locked::after { content: "LOCKED"; position: absolute; top: 8px; right: 8px; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.1em; background: rgba(0,0,0,0.6); padding: 3px 6px; border-radius: 6px; }
.fighter-bio { margin: 4px 0 8px; color: var(--fg-2); font-size: 0.88rem; line-height: 1.5; min-height: 2.6em; }
.moves-mini { display: flex; flex-wrap: wrap; gap: 6px; }
.moves-mini span { font-size: 0.74rem; border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; color: var(--fg-2); }
.moves-mini span b { color: var(--fg); font-weight: 700; }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.keys { border-collapse: collapse; width: 100%; font-size: 0.82rem; }
.keys th { text-align: left; white-space: nowrap; padding: 4px 8px 4px 0; vertical-align: top; }
.keys td { padding: 4px 0; color: var(--fg-2); line-height: 1.45; }
.card kbd { font-family: inherit; font-weight: 700; font-size: 0.78em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; background: var(--glass-2); margin: 0 1px; }
.rules { margin: 0 0 12px; padding-left: 18px; color: var(--fg-2); font-size: 0.84rem; line-height: 1.5; }
.rules li { margin-bottom: 6px; }
.rules b { color: var(--fg); }
.movelist { font-size: 0.8rem; color: var(--fg-2); line-height: 1.5; }
.movelist b { color: var(--fg); }
.card-win { text-align: center; }
.card-win .card-actions { justify-content: center; }

@media (max-width: 700px) {
  .help-cols { grid-template-columns: 1fr; }
  .roster { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .fighter { padding: 5px 4px 6px; border-radius: 10px; }
  .fighter b { font-size: 0.68rem; } .fighter small { display: none; }
  .card { padding: 16px 14px 14px; border-radius: 18px; }
  .card h2 { font-size: 1.15rem; }
  .lbl { width: 70px; }
  .seg button { padding: 5px 9px; font-size: 0.76rem; }
  .modes { grid-template-columns: 1fr 1fr; }
  .mode span { display: none; }
  .hud-title { display: none; }
  .icon-btn { width: 30px; height: 30px; }
}
@media (max-height: 520px) {
  .tpad { width: 136px; height: 136px; } .tbtn { width: 200px; height: 136px; } .tb { font-size: 0.8rem; border-radius: 12px; }
}
@media (prefers-reduced-motion: reduce) { .card { animation: none; } }

/* phones held upright: the arena sits under the header and the pads take the space below it */
@media (orientation: portrait) and (max-width: 820px) {
  .stage { align-items: start; padding-top: 54px; }
  #game { width: 100vw; height: calc(100vw * 9 / 16); }
  .tpad { width: 196px; height: 196px; bottom: max(14px, env(safe-area-inset-bottom)); }
  .tbtn { width: calc(100vw - 196px - 32px); max-width: 230px; height: 196px; bottom: max(14px, env(safe-area-inset-bottom)); grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
  .tb { font-size: 1rem; border-radius: 14px; }
  .tb-l { grid-column: 1; grid-row: 1; } .tb-h { grid-column: 2; grid-row: 1; } .tb-s { grid-column: 3; grid-row: 1; }
  .tb-g { grid-column: 1; grid-row: 2; } .tb-e { grid-column: 2; grid-row: 2; } .tb-u { grid-column: 3; grid-row: 2; }
  .tb-d { grid-column: 3; grid-row: 3; }
}
@media (max-height: 480px) {
  .hud { padding-top: 4px; }
  .icon-btn { width: 28px; height: 28px; }
  .icon-btn svg { width: 14px; height: 14px; }
  .hud-brand svg { width: 22px; height: 22px; }
}

/* cover and video captures: the arena alone */
body.demo .hud, body.demo .toast, body.demo .touch { display: none; }
