:root {
  --ink: #080b17;
  --panel: #101629;
  --panel-light: #18213a;
  --line: #2b3654;
  --text: #e8f1ff;
  --muted: #7e8cae;
  --cyan: #36e1ed;
  --cyan-dark: #157d9d;
  --red: #ff536e;
  --red-dark: #a52c52;
  --amber: #ffd166;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--ink); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Courier New", "Microsoft YaHei", monospace;
  background:
    radial-gradient(circle at 15% 8%, rgba(29, 87, 115, .2), transparent 30rem),
    radial-gradient(circle at 90% 45%, rgba(115, 30, 70, .13), transparent 28rem),
    linear-gradient(rgba(31, 44, 70, .13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 44, 70, .13) 1px, transparent 1px),
    #080b17;
  background-size: auto, auto, 32px 32px, 32px 32px, auto;
}

button, kbd { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.arcade-shell {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.brand-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 50px);
  line-height: .95;
  letter-spacing: -3px;
  text-shadow: 3px 3px 0 #17223c;
}

h1 span { color: var(--cyan); }
.brand-block p { margin: 8px 0 0; color: #9caac5; font-size: 11px; letter-spacing: 3px; }

.system-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: rgba(16, 22, 41, .8);
  box-shadow: 3px 3px 0 #05070e;
  color: #a6b3cd;
  font-size: 10px;
  letter-spacing: 1px;
  white-space: nowrap;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.audio-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  background: rgba(16, 22, 41, .8);
  box-shadow: 3px 3px 0 #05070e;
  color: #a6b3cd;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
}
.audio-toggle:hover { color: var(--text); border-color: #4c5b7d; }
.audio-toggle:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
.audio-glyph { color: var(--cyan); font-size: 14px; line-height: 1; }
.audio-toggle.muted .audio-glyph, .audio-toggle.muted #muteLabel { color: #66738f; }

.system-badge strong { padding-left: 8px; border-left: 1px solid var(--line); color: var(--cyan); }
.status-dot { width: 7px; height: 7px; background: var(--cyan); box-shadow: 0 0 9px var(--cyan); animation: blink 1.8s steps(2) infinite; }

.scoreboard {
  display: grid;
  grid-template-columns: 1fr 100px 1fr;
  gap: 18px;
  align-items: center;
  margin-bottom: 12px;
}

.player-hud { min-width: 0; }
.player-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.player-two .player-meta { text-align: right; justify-content: flex-end; }
.player-meta > div { min-width: 0; flex: 1; }

.player-tag {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 28px;
  border: 1px solid currentColor;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, .45);
}

.player-one .player-tag, .p1-controls .player-tag { color: var(--cyan); background: rgba(54, 225, 237, .09); }
.player-two .player-tag, .p2-controls .player-tag { color: var(--red); background: rgba(255, 83, 110, .09); }

.player-meta h2 { margin: 0 0 3px; font-size: 14px; letter-spacing: 1px; }
.player-meta h2 small { margin-left: 6px; color: var(--muted); font-size: 8px; letter-spacing: .5px; }
.player-meta p { margin: 0; color: var(--muted); font-size: 9px; letter-spacing: 1px; }
.hp-number { font-size: 25px; line-height: 1; font-variant-numeric: tabular-nums; }
.player-one .hp-number { color: var(--cyan); }
.player-two .hp-number { color: var(--red); }

.health-track {
  position: relative;
  height: 16px;
  padding: 3px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #050812;
  box-shadow: 2px 2px 0 #05070d;
}

.health-fill { width: 100%; height: 100%; transition: width .12s steps(5), background-color .15s; }
.player-one .health-fill { background: var(--cyan); box-shadow: 0 0 10px rgba(54, 225, 237, .4); }
.player-two .health-fill { margin-left: auto; background: var(--red); box-shadow: 0 0 10px rgba(255, 83, 110, .35); }
.health-fill.low { background: var(--amber) !important; }
.health-segments { position: absolute; inset: 3px; pointer-events: none; background: repeating-linear-gradient(90deg, transparent 0, transparent calc(10% - 2px), #080b17 calc(10% - 2px), #080b17 10%); }

.skill-bar { --skill-color: var(--cyan); display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 8px; }
.player-two .skill-bar { flex-direction: row-reverse; }
.skill-key { display: inline-grid; place-items: center; flex: 0 0 auto; min-width: 17px; height: 16px; padding: 0 3px; border: 1px solid #46536f; border-bottom-width: 2px; background: #1a2338; color: #e4ecfb; font-size: 8px; font-weight: 700; }
.skill-name { flex: 0 0 auto; color: #93a1bb; letter-spacing: .5px; white-space: nowrap; }
.skill-cd { flex: 0 0 auto; color: #7d8aa6; font-size: 8px; font-style: normal; letter-spacing: .3px; }
.skill-track { flex: 1; min-width: 24px; height: 5px; overflow: hidden; border: 1px solid #222d45; background: #050812; }
.skill-fill {
  width: 0;
  height: 100%;
  background-color: var(--skill-color, var(--cyan-dark));
  background-image: repeating-linear-gradient(115deg, rgba(255, 255, 255, .24) 0 3px, transparent 3px 8px);
  background-size: 14px 100%;
  animation: skill-flow .7s linear infinite;
  transition: width .12s linear;
}
.skill-state { flex: 0 0 auto; min-width: 25px; color: #65728e; text-align: right; font-variant-numeric: tabular-nums; }
.skill-bar.ready .skill-fill { box-shadow: 0 0 8px var(--skill-color); animation: skill-ready 1.3s ease-in-out infinite; }
.skill-bar.ready .skill-state { color: var(--amber); }
.skill-bar.casting .skill-track { animation: skill-cast .32s steps(4); }
.skill-bar + .skill-bar { margin-top: 4px; }

.round-clock { text-align: center; line-height: 1; }
.round-clock span { display: block; color: var(--amber); font-size: 8px; letter-spacing: 1px; }
.round-clock strong { display: block; margin: 4px 0 2px; font-size: 34px; font-variant-numeric: tabular-nums; text-shadow: 2px 2px 0 #27304b; }
.round-clock strong.danger { color: var(--red); animation: blink .6s steps(2) infinite; }
.round-clock small { color: var(--muted); font-size: 7px; letter-spacing: 2px; }

.screen-frame {
  position: relative;
  padding: 7px;
  border: 1px solid #384563;
  background: #131b2d;
  box-shadow: 0 0 0 4px #080b14, 0 0 0 5px #222d45, 8px 10px 0 rgba(0, 0, 0, .35);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: #080d1d;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
}

.scanlines {
  position: absolute;
  inset: 7px;
  z-index: 2;
  pointer-events: none;
  opacity: .15;
  background: repeating-linear-gradient(0deg, transparent 0, transparent 3px, #000 3px, #000 4px);
}

.screen-corner { position: absolute; z-index: 4; width: 12px; height: 12px; pointer-events: none; }
.corner-tl { top: 2px; left: 2px; border-top: 2px solid var(--cyan); border-left: 2px solid var(--cyan); }
.corner-tr { top: 2px; right: 2px; border-top: 2px solid var(--cyan); border-right: 2px solid var(--cyan); }
.corner-bl { bottom: 2px; left: 2px; border-bottom: 2px solid var(--cyan); border-left: 2px solid var(--cyan); }
.corner-br { bottom: 2px; right: 2px; border-bottom: 2px solid var(--cyan); border-right: 2px solid var(--cyan); }

.game-overlay {
  position: absolute;
  inset: 7px;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 7, 16, .66);
  backdrop-filter: blur(1px);
}

.game-overlay.hidden { display: none; }
.hidden { display: none !important; }
.overlay-panel { width: min(420px, 90%); padding: 22px 20px 18px; border: 1px solid #44526e; background: rgba(10, 15, 29, .94); box-shadow: 5px 5px 0 rgba(0, 0, 0, .5), inset 0 0 0 3px #111a2e; text-align: center; }
.overlay-eyebrow { color: var(--cyan); font-size: 9px; font-weight: 700; letter-spacing: 3px; }
.overlay-panel h2 { margin: 9px 0 8px; font-size: clamp(22px, 4vw, 34px); letter-spacing: 4px; text-shadow: 3px 3px 0 #1a2941; }
.overlay-panel p { margin: 10px 0 16px; color: #aebbd1; font-size: 11px; line-height: 1.6; }
.overlay-panel > small { display: block; margin-top: 10px; color: #65728e; font-size: 8px; }

.pixel-divider { display: flex; align-items: center; justify-content: center; gap: 6px; }
.pixel-divider i { width: 42px; height: 2px; background: #273551; }
.pixel-divider b { width: 6px; height: 6px; background: var(--amber); transform: rotate(45deg); }

#actionButton {
  min-width: 170px;
  padding: 11px 22px;
  border: 0;
  outline: 1px solid #8cf7ff;
  outline-offset: 3px;
  background: var(--cyan);
  color: #07131d;
  box-shadow: 4px 4px 0 #14647c;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 2px;
  cursor: pointer;
}
#actionButton:hover { background: #8cf7ff; transform: translateY(-1px); }
#actionButton:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #14647c; }
#actionButton:focus-visible, #resetButton:focus-visible { outline: 2px solid var(--amber); outline-offset: 4px; }

.mode-actions { display: flex; justify-content: center; gap: 8px; margin: 12px 0 8px; }
.mode-button { padding: 9px 14px; border: 1px solid #3c4b69; background: #131d33; color: #c7d6ee; font-family: inherit; font-size: 10px; font-weight: 700; letter-spacing: 1px; cursor: pointer; }
.mode-button:hover { border-color: var(--cyan); color: #ffffff; }
.join-row { display: flex; justify-content: center; gap: 6px; margin: 10px 0; }
.join-row input { width: 118px; padding: 9px 10px; border: 1px solid #3c4b69; background: #0b1220; color: #ffffff; font-family: inherit; font-size: 15px; letter-spacing: 6px; text-align: center; text-transform: uppercase; }
.join-row input:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
.online-panel { margin: 8px 0 4px; }
.room-status { margin: 6px 0 !important; color: #9fb0cb !important; font-size: 10px !important; }
.room-code { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 8px 0; color: #8fa0bd; font-size: 10px; }
.room-code strong { color: var(--amber); font-size: 20px; letter-spacing: 5px; }
.room-code button { padding: 4px 7px; border: 1px solid #3c4b69; background: #131d33; color: #a9bdd9; font-family: inherit; font-size: 8px; cursor: pointer; }
#onlineStartButton { min-width: 150px; margin-top: 6px; padding: 10px 16px; border: 0; background: var(--amber); color: #1a1206; font-family: inherit; font-size: 11px; font-weight: 900; letter-spacing: 2px; cursor: pointer; box-shadow: 3px 3px 0 #8a5f1f; }
.ghost-button { margin-top: 8px; padding: 6px 10px; border: 1px solid #32405c; background: transparent; color: #8493ad; font-family: inherit; font-size: 9px; cursor: pointer; }

.touch-controls { position: absolute; inset: 0; z-index: 2; display: flex; align-items: flex-end; justify-content: space-between; padding: 12px; pointer-events: none; }
.touch-controls.hidden { display: none !important; }
.touch-cluster { display: flex; align-items: flex-end; gap: 7px; pointer-events: auto; }
.touch-controls button { display: grid; place-items: center; width: 52px; height: 52px; border: 2px solid rgba(140, 247, 255, .5); border-radius: 8px; background: rgba(8, 14, 26, .62); color: #dff4ff; font-family: inherit; font-size: 18px; font-weight: 700; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.touch-controls button:active { background: rgba(37, 185, 209, .45); transform: scale(.94); }
.touch-move {
  display: grid;
  grid-template-areas: "jump jump" "left right";
  grid-template-columns: auto auto;
  gap: 6px;
  justify-items: center;
  align-items: end;
}
.touch-move [data-action="jump"] { grid-area: jump; }
.touch-move [data-action="left"] { grid-area: left; }
.touch-move [data-action="right"] { grid-area: right; }
.touch-actions { gap: 6px; }
.touch-actions button { border-radius: 50%; }
.touch-actions .touch-small { width: 44px; height: 44px; font-size: 12px; }
.touch-actions .touch-attack { width: 62px; height: 62px; border-color: rgba(255, 209, 102, .65); color: #ffe2a1; font-size: 16px; }

.arena-strip { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 4px 11px; color: #6f7d99; font-size: 8px; letter-spacing: 1px; }
.arena-strip > span { display: flex; align-items: center; gap: 6px; }
.arena-strip .arena-tip { color: #9aa8c2; }
.arena-tip b { color: #3c4964; }
.tiny-square { display: inline-block; width: 5px; height: 5px; }
.tiny-square.cyan { background: var(--cyan); }
.tiny-square.amber { background: var(--amber); }

.controls-grid { display: grid; grid-template-columns: 1fr 100px 1fr; gap: 18px; align-items: stretch; }
.control-card { padding: 14px 16px; border: 1px solid #25304a; background: rgba(15, 21, 38, .86); box-shadow: 3px 3px 0 #05070e; }
.p1-controls { border-top-color: var(--cyan-dark); }
.p2-controls { border-top-color: var(--red-dark); }
.control-heading { display: flex; align-items: center; gap: 10px; padding-bottom: 11px; margin-bottom: 10px; border-bottom: 1px dashed #2b3650; }
.control-heading strong { display: block; margin-bottom: 3px; font-size: 11px; }
.control-heading small { display: block; color: var(--muted); font-size: 7px; letter-spacing: 2px; }
.key-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.key-list > div { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.key-list > div > span { display: flex; gap: 3px; min-height: 25px; align-items: center; }
.key-list small { color: #8d9ab4; font-size: 9px; }
.mech-picker { display: flex; align-items: center; gap: 8px; margin-top: 11px; padding-top: 9px; border-top: 1px dashed #2b3650; color: #7e8cae; font-size: 8px; letter-spacing: 1px; }
.mech-picker select { flex: 1; min-width: 0; padding: 6px 7px; border: 1px solid #35425e; background: #111a2e; color: #dfe9fb; font-family: inherit; font-size: 10px; cursor: pointer; }
.mech-picker select:hover { border-color: #4c5b7d; }
.mech-picker select:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.p2-controls .mech-picker { flex-direction: row-reverse; }
.skill-legend { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; padding-top: 9px; border-top: 1px dashed #2b3650; }
.skill-legend > span { display: flex; align-items: center; gap: 6px; font-size: 8px; }
.skill-legend kbd { min-width: 16px; height: 16px; padding: 0 3px; font-size: 8px; border-bottom-width: 2px; }
.skill-legend b { color: #c6d4ec; font-size: 9px; font-weight: 700; }
.skill-legend i { margin-left: auto; color: #6d7b96; font-size: 8px; font-style: normal; }
.p2-controls .skill-legend > span { flex-direction: row-reverse; }
.p2-controls .skill-legend i { margin-left: 0; margin-right: auto; }
kbd { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 5px; border: 1px solid #46536f; border-bottom-width: 3px; background: #1a2338; color: #e4ecfb; font-size: 10px; font-weight: 700; line-height: 1; }
.p1-controls kbd { border-bottom-color: var(--cyan-dark); }
.p2-controls kbd { border-bottom-color: var(--red-dark); }
.versus-mark { display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.versus-mark span, .versus-mark small { font-size: 7px; letter-spacing: 1px; }
.versus-mark strong { margin: 2px 0; color: var(--amber); font-size: 30px; font-style: italic; line-height: 1; text-shadow: 3px 3px 0 #493c28; }

.footer-line { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 18px; color: #52607d; font-size: 7px; letter-spacing: 1px; }
.footer-line > span kbd { min-width: 16px; height: 16px; padding: 0 3px; font-size: 8px; border-bottom-width: 2px; vertical-align: middle; }
.footer-line i { color: var(--amber); font-style: normal; }
#resetButton { padding: 5px 9px; border: 1px solid #293650; background: #10172a; color: #93a1bb; font-size: 9px; cursor: pointer; }
#resetButton:hover { color: var(--text); border-color: #53617e; }
#resetButton kbd { min-width: 18px; height: 18px; margin-right: 4px; padding: 0 3px; font-size: 8px; }

@keyframes blink { 50% { opacity: .35; } }
@keyframes skill-flow { to { background-position: 14px 0; } }
@keyframes skill-ready { 50% { filter: brightness(1.5); } }
@keyframes skill-cast { 0% { filter: brightness(2.4); } 100% { filter: none; } }

@media (max-width: 760px) {
  .arcade-shell { width: min(100% - 16px, 680px); padding-top: 12px; padding-bottom: 10px; }
  .scoreboard, .controls-grid { grid-template-columns: 1fr 64px 1fr; gap: 9px; }
  .controls-grid, .footer-line, .arena-strip { display: none; }
  .topbar { padding-bottom: 10px; }
  .brand-block p { display: none; }
  .screen-frame { padding: 5px; }
  .touch-controls {
    position: fixed;
    inset: 0;
    z-index: 20;
    padding: 0 12px calc(14px + env(safe-area-inset-bottom));
  }
  .game-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    padding: 14px;
    background: rgba(4, 7, 16, .9);
    backdrop-filter: blur(3px);
  }
  .overlay-panel {
    width: min(360px, 100%);
    max-height: calc(100vh - 36px);
    max-height: calc(100dvh - 36px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .player-meta { gap: 6px; }
  .player-tag { width: 28px; height: 24px; }
  .player-meta h2 small { display: none; }
  .hp-number { font-size: 20px; }
  .round-clock strong { font-size: 28px; }
  .control-card { padding: 11px 8px; }
  .key-list { grid-template-columns: repeat(2, 1fr); row-gap: 12px; }
  .control-heading { justify-content: center; }
  .versus-mark span, .versus-mark small { display: none; }
  .footer-line > span { display: none; }
  .footer-line { justify-content: center; }
}

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar-actions { margin-left: auto; }
  .scoreboard { grid-template-columns: 1fr; gap: 6px; }
  .round-clock { order: -1; flex-direction: row; gap: 8px; padding: 2px 4px; }
  .round-clock span, .round-clock small { display: none; }
  .round-clock strong { font-size: 24px; }
  .scoreboard > * { min-width: 0; }
  .player-hud { padding: 8px 9px; }
  .player-meta h2 { font-size: 12px; }
  .player-meta p { font-size: 7px; }
  .skill-bar { gap: 4px; }
  .skill-name { font-size: 8px; }
  .hp-number { font-size: 19px; }
}

@media (max-height: 460px) and (pointer: coarse) {
  .topbar { display: none; }
  .touch-controls button { width: 44px; height: 44px; font-size: 15px; }
  .touch-actions .touch-small { width: 38px; height: 38px; font-size: 11px; }
  .touch-actions .touch-attack { width: 52px; height: 52px; }
}

@media (max-width: 480px) {
  .arcade-shell { width: calc(100% - 16px); }
  .topbar { gap: 10px; }
  .brand-kicker { font-size: 7px; letter-spacing: 1px; }
  .brand-block p { font-size: 8px; letter-spacing: 1px; }
  .system-badge { padding: 7px; font-size: 0; gap: 5px; }
  .system-badge strong { font-size: 10px; }
  .topbar-actions { gap: 6px; }
  .audio-toggle { padding: 7px; }
  .audio-toggle #muteLabel { display: none; }
  .scoreboard { grid-template-columns: 1fr; gap: 6px; }
  .player-meta .player-tag { display: none; }
  .player-meta h2 { font-size: 11px; }
  .player-meta p { font-size: 7px; }
  .hp-number { font-size: 17px; }
  .round-clock span { font-size: 6px; }
  .round-clock strong { font-size: 24px; }
  .round-clock small { font-size: 5px; letter-spacing: 1px; }
  .screen-frame { padding: 4px; }
  .scanlines { inset: 4px; }
  .touch-controls { padding: 0 8px calc(12px + env(safe-area-inset-bottom)); gap: 6px; }
  .touch-cluster { gap: 5px; }
  .touch-controls button { width: 40px; height: 40px; font-size: 15px; }
  .touch-actions { gap: 4px; }
  .touch-actions .touch-small { width: 32px; height: 32px; font-size: 10px; }
  .touch-actions .touch-attack { width: 46px; height: 46px; font-size: 14px; }
  .overlay-panel { padding: 13px 12px 11px; }
  .overlay-panel h2 { margin: 5px 0; font-size: 20px; }
  .overlay-panel p { margin: 6px 0 10px; font-size: 9px; }
  .overlay-panel > small { display: none; }
  #actionButton { min-width: 135px; padding: 8px 14px; font-size: 10px; }
  .arena-strip { font-size: 6px; gap: 5px; }
  .arena-strip .arena-tip { display: none; }
  .control-heading .player-tag { display: none; }
  .control-heading strong { font-size: 10px; }
  .control-heading small { font-size: 6px; }
  .controls-grid { grid-template-columns: 1fr 42px 1fr; gap: 6px; }
  .versus-mark strong { font-size: 22px; }
  .key-list { gap: 8px 3px; }
}

/* ---------- Phone landscape: fullscreen arena, HP top, controls in bottom corners ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  body { background: #05070e; }
  .arcade-shell { width: 100%; height: 100vh; height: 100dvh; padding: 0; }
  .topbar, .controls-grid, .footer-line, .arena-strip { display: none; }

  .scoreboard {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: start;
    margin: 0;
    padding: 6px 12px 16px;
    padding: calc(6px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 16px calc(12px + env(safe-area-inset-left));
    background: linear-gradient(rgba(4, 7, 16, .93), rgba(4, 7, 16, .6) 62%, transparent);
    pointer-events: none;
  }
  .player-hud { padding: 0; }
  .player-meta { gap: 8px; margin-bottom: 4px; }
  .player-meta > div { flex: 0 1 auto; }
  .player-meta h2 { margin: 0; font-size: 11px; letter-spacing: .5px; }
  .player-meta h2 small, .player-meta p, .player-tag { display: none; }
  .hp-number { font-size: 15px; }
  .health-track { height: 9px; padding: 2px; box-shadow: none; }
  .health-segments { inset: 2px; }
  .skill-bar { gap: 4px; margin-top: 3px; }
  .skill-key, .skill-name, .skill-cd { display: none; }
  .skill-track { height: 4px; }
  .skill-state { min-width: 20px; font-size: 7px; }
  .round-clock { order: 0; display: block; padding: 0; }
  .round-clock span, .round-clock small { display: none; }
  .round-clock strong { margin: 0; font-size: 22px; }

  .screen-frame { position: fixed; inset: 0; z-index: 0; padding: 0; border: 0; box-shadow: none; background: #080d1d; }
  canvas { width: 100%; height: 100%; aspect-ratio: auto; object-fit: contain; }
  .scanlines { inset: 0; }
  .screen-corner { display: none; }

  .game-overlay { position: fixed; inset: 0; z-index: 60; padding: 12px; }
  .overlay-panel {
    width: min(420px, 100%);
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .touch-controls {
    position: fixed;
    inset: 0;
    z-index: 20;
    padding: 0 14px 12px;
    padding: 0 calc(14px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
  }
  .touch-cluster { gap: 10px; }
  .touch-controls button {
    width: 58px;
    height: 58px;
    font-size: 20px;
    border-color: rgba(140, 247, 255, .42);
    background: rgba(8, 14, 26, .52);
  }
  .touch-actions {
    display: grid;
    grid-template-areas: "guard skill1" "skill2 attack";
    grid-template-columns: auto auto;
    gap: 8px;
    align-items: end;
    justify-items: end;
  }
  .touch-actions [data-action="guard"] { grid-area: guard; }
  .touch-actions [data-action="skill1"] { grid-area: skill1; }
  .touch-actions [data-action="skill2"] { grid-area: skill2; }
  .touch-actions [data-action="attack"] { grid-area: attack; }
  .touch-actions .touch-small { width: 54px; height: 54px; font-size: 14px; }
  .touch-actions .touch-attack { width: 68px; height: 68px; font-size: 18px; }
}

/* ---------- Portrait gate: ask phone players to rotate ---------- */
.rotate-gate { display: none; }
@media (orientation: portrait) and (max-width: 760px) {
  .rotate-gate:not(.dismissed) {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 28px;
    text-align: center;
    background: radial-gradient(circle at 50% 26%, #10172c, #05070e 72%);
  }
}
.rotate-card { width: 100%; max-width: 300px; }
.rotate-device {
  width: 104px;
  height: 64px;
  margin: 0 auto 22px;
  border: 3px solid var(--cyan);
  border-radius: 8px;
  box-shadow: 0 0 14px rgba(54, 225, 237, .35);
  animation: rotate-tip 2.4s ease-in-out infinite;
}
@keyframes rotate-tip {
  0%, 15% { transform: rotate(0deg); }
  55%, 100% { transform: rotate(-90deg); }
}
.rotate-card h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: 3px; }
.rotate-card p { margin: 0 0 18px; color: #9aa8c2; font-size: 11px; line-height: 1.6; }
#rotateEnterButton { padding: 11px 26px; border: 0; background: var(--cyan); color: #07131d; font-size: 12px; font-weight: 900; letter-spacing: 2px; box-shadow: 4px 4px 0 #14647c; cursor: pointer; }
#rotateEnterButton:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #14647c; }
.rotate-skip { display: block; margin: 16px auto 0; padding: 6px; border: 0; background: none; color: #6c7a96; font-size: 10px; text-decoration: underline; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  .rotate-device { animation: none; }
  .status-dot, .round-clock strong.danger { animation: none; }
  .health-fill { transition: none; }
  .skill-fill, .skill-bar.ready .skill-fill, .skill-bar.casting .skill-track { animation: none; }
}
