:root {
  color-scheme: dark;
  --ink: #080a13;
  --panel: #101525;
  --line: #29354e;
  --cyan: #53e9ff;
  --pink: #ff4b9a;
  --muted: #8f9cb6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: #f2f6ff;
  background:
    radial-gradient(ellipse at 50% 18%, rgba(30, 48, 94, .32), transparent 52%),
    linear-gradient(180deg, #0b0e1b 0%, #070911 68%, #05060c 100%);
}
.page-shell { width: min(1240px, calc(100% - 44px)); margin: 0 auto; padding: 20px 0 18px; }
.site-header, .site-footer { display: flex; align-items: center; justify-content: space-between; }
.site-header { height: 42px; margin: 0 0 15px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; letter-spacing: .1em; font-size: 14px; font-weight: 900; }
.brand-mark { display: grid; place-items: center; width: 31px; height: 28px; color: #08101c; background: var(--cyan); border: 2px solid #b9f9ff; box-shadow: 3px 3px 0 #176183; font-size: 12px; transform: skew(-5deg); }
.brand-name b { color: var(--cyan); }
.header-status { color: #a7b3cb; font-size: 10px; letter-spacing: .16em; }
.status-dot, .underbar-light { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: #6cffb2; box-shadow: 0 0 9px #6cffb2; vertical-align: 1px; }
.header-divider { margin: 0 7px; color: #414c64; }
.game-stage { position: relative; }
.game-frame { position: relative; overflow: hidden; width: 100%; aspect-ratio: 16 / 9; background: #080b17; border: 1px solid #354562; box-shadow: 0 0 0 4px #101526, 0 0 0 5px #26334b, 0 22px 70px rgba(0,0,0,.58), 0 0 40px rgba(26, 199, 255, .08); }
#game { display: block; width: 100%; height: 100%; outline: none; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; }
#game:focus-visible { box-shadow: inset 0 0 0 2px rgba(83,233,255,.8); }
.frame-corner { position: absolute; z-index: 2; width: 12px; height: 12px; pointer-events: none; }
.corner-tl { top: 0; left: 0; border-top: 2px solid var(--cyan); border-left: 2px solid var(--cyan); }
.corner-tr { top: 0; right: 0; border-top: 2px solid var(--pink); border-right: 2px solid var(--pink); }
.corner-bl { bottom: 0; left: 0; border-bottom: 2px solid var(--pink); border-left: 2px solid var(--pink); }
.corner-br { bottom: 0; right: 0; border-bottom: 2px solid var(--cyan); border-right: 2px solid var(--cyan); }
.underbar { display: flex; justify-content: space-between; padding: 9px 4px 0; color: #71809e; font-size: 9px; letter-spacing: .15em; }
.underbar-left { color: #9aa8c2; }
.underbar-light { width: 5px; height: 5px; margin-right: 6px; background: var(--pink); box-shadow: 0 0 8px var(--pink); }
.underbar-right b { color: var(--cyan); padding: 0 5px; }
.controls { margin: 25px 0 0; padding: 15px 18px 14px; border: 1px solid #202a40; background: linear-gradient(110deg, rgba(17,23,39,.9), rgba(10,14,25,.74)); box-shadow: inset 0 1px rgba(255,255,255,.025); }
.controls-heading { display: flex; align-items: center; gap: 11px; color: #75839f; font-size: 9px; letter-spacing: .16em; }
.controls-heading span:first-child { color: var(--cyan); font-weight: 900; }
.controls-rule { width: 30px; height: 1px; background: #35435d; }
.key-row { display: flex; flex-wrap: wrap; align-items: center; gap: 13px 20px; margin-top: 12px; }
.key-group { display: inline-flex; align-items: center; gap: 5px; min-height: 26px; }
.keycap { display: inline-grid; place-items: center; min-width: 25px; height: 25px; padding: 0 6px; color: #e3eaf7; font-size: 10px; font-weight: 900; border: 1px solid #46536b; border-bottom-width: 3px; background: linear-gradient(#263149,#151c2c); box-shadow: 0 2px 5px rgba(0,0,0,.28); }
.keycap.attack-key { color: #ffaad2; border-color: #804866; background: linear-gradient(#47243b,#261727); }
.keycap.special-key { color: #8ef6ff; border-color: #3d7884; background: linear-gradient(#1a4654,#122936); }
.keycap.throw-key { min-width: 55px; color: #ffd587; border-color: #81663c; background: linear-gradient(#473824,#282114); font-size: 8px; }
.key-label { margin-left: 2px; color: #c0c9d8; font-size: 10px; white-space: nowrap; }
.controls-note { margin: 12px 0 0; color: #75839f; font-size: 10px; line-height: 1.6; }
.site-footer { margin-top: 20px; padding-top: 12px; border-top: 1px solid rgba(70,84,111,.28); color: #596680; font-size: 8px; letter-spacing: .13em; }
.site-footer b { color: var(--pink); padding-left: 5px; }

/* Touch controls are enabled for phones/tablets; desktop keeps its keyboard layout. */
.touch-controls { display: none; }
.touch-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 42px;
  min-height: 42px;
  padding: 4px 5px;
  border: 1px solid rgba(139, 176, 210, .55);
  border-bottom: 3px solid rgba(89, 125, 161, .8);
  border-radius: 9px;
  color: #f3f8ff;
  background: linear-gradient(180deg, rgba(45,60,87,.92), rgba(15,24,41,.94));
  box-shadow: 0 3px 9px rgba(0,0,0,.35), inset 0 1px rgba(255,255,255,.12);
  font: inherit;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  cursor: pointer;
  pointer-events: auto;
}
.touch-btn:focus { outline: none; }
.touch-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.touch-btn.is-held {
  transform: translateY(2px) scale(.97);
  border-color: #d9faff;
  border-bottom-width: 1px;
  color: #fff;
  background: linear-gradient(180deg, rgba(61,142,169,.98), rgba(19,61,82,.98));
  box-shadow: 0 0 16px rgba(71,222,255,.48), inset 0 0 12px rgba(255,255,255,.17);
}
.touch-glyph { font-size: 17px; font-weight: 1000; line-height: 1; }
.touch-label { color: #c3d2e6; font-size: 7px; font-weight: 900; letter-spacing: .04em; line-height: 1.1; white-space: nowrap; }
.touch-move { width: clamp(46px, 13vw, 58px); height: clamp(46px, 13vw, 58px); }
.touch-utility { width: clamp(39px, 11.2vw, 51px); height: clamp(42px, 12vw, 54px); }
.touch-action { width: clamp(48px, 13.6vw, 62px); height: clamp(48px, 13.6vw, 62px); }
.touch-guard { color: #bff7ff; border-color: rgba(75,202,224,.62); }
.touch-punch, .touch-kick { color: #ffe0ef; border-color: rgba(255,102,166,.65); background: linear-gradient(180deg, rgba(92,43,76,.94), rgba(39,19,41,.96)); }
.touch-special { color: #a5f7ff; border-color: rgba(76,222,246,.75); background: linear-gradient(180deg, rgba(29,87,105,.96), rgba(14,39,57,.97)); }
.touch-throw { color: #ffe6ac; border-color: rgba(245,190,91,.72); background: linear-gradient(180deg, rgba(92,69,34,.96), rgba(42,31,20,.97)); }
.touch-pad-row, .touch-utility-row { display: flex; align-items: center; gap: 5px; }
.touch-left { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; }
.touch-right { display: grid; grid-template-columns: repeat(2, auto); gap: 6px; align-items: center; }

@media (max-width: 760px) {
  .page-shell { width: min(100% - 24px, 1240px); padding-top: 12px; }
  .header-status { font-size: 8px; letter-spacing: .08em; }
  .brand { font-size: 12px; }
  .controls { margin-top: 18px; padding: 13px 12px; }
  .key-row { gap: 10px 13px; }
  .underbar { font-size: 7px; letter-spacing: .08em; }
  .site-footer { font-size: 7px; }
}
@media (max-width: 480px) {
  .header-status { max-width: 130px; text-align: right; line-height: 1.5; }
  .key-row { gap: 8px 10px; }
  .key-group { gap: 3px; }
  .key-label { font-size: 9px; }
}

/* Phone/tablet: touch targets stay large and accept independent multi-touch pointers. */
@media (pointer: coarse), (hover: none) {
  body { overscroll-behavior: none; }
  .touch-controls {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 9px;
    border: 1px solid rgba(89,124,163,.6);
    border-radius: 12px;
    background: linear-gradient(110deg, rgba(11,18,32,.95), rgba(11,15,29,.88));
    box-shadow: 0 6px 22px rgba(0,0,0,.4), inset 0 1px rgba(255,255,255,.06);
    z-index: 5;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
  }
  body[data-game-mode="title"] .touch-controls,
  body[data-game-mode="select"] .touch-controls,
  body[data-game-mode="ko"] .touch-controls,
  body[data-game-mode="result"] .touch-controls { display: none; }
  .controls, .site-footer { display: none; }
}

/* Portrait play remains usable, with the virtual pad directly below the 16:9 arena. */
@media (pointer: coarse) and (orientation: portrait) {
  html, body { min-height: 100%; }
  .page-shell { width: calc(100% - 18px); padding: 9px 0 12px; }
  .site-header { height: 32px; margin-bottom: 8px; }
  .brand-mark { width: 26px; height: 24px; font-size: 10px; }
  .brand { gap: 8px; font-size: 11px; }
  .header-status { font-size: 7px; }
  .game-stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .game-frame { width: 100%; }
  .touch-controls { position: relative; min-height: 122px; width: 100%; }
  .touch-left { gap: 5px; }
  .touch-right { gap: 5px; }
  .underbar { padding-top: 7px; }
}

/* Landscape phone: hide page chrome, preserve 16:9, and overlay compact controls at both ends. */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 600px) {
  html, body { width: 100%; height: 100%; min-height: 0; overflow: hidden; }
  .page-shell { width: 100vw; height: 100svh; margin: 0; padding: 0; }
  .site-header, .site-footer, .underbar, .controls { display: none !important; }
  main, .game-section { width: 100%; height: 100%; margin: 0; }
  .game-section { position: relative; }
  .game-stage {
    position: absolute;
    left: 50%; top: 50%;
    width: min(100vw, calc(100svh * 16 / 9));
    aspect-ratio: 16 / 9;
    transform: translate(-50%, -50%);
    display: block;
  }
  .game-frame { position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: 16 / 9; box-shadow: 0 0 0 1px #26334b; }
  .touch-controls {
    position: absolute;
    inset: 0;
    display: block;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
  }
  .touch-left { position: absolute; left: 2.3%; bottom: 3.2%; gap: 5px; }
  .touch-right { position: absolute; right: 2.3%; bottom: 3.2%; gap: 5px; }
  .touch-pad-row, .touch-utility-row { gap: 4px; }
  .touch-btn { width: clamp(37px, 10svh, 52px); height: clamp(37px, 10svh, 52px); min-width: 37px; min-height: 37px; border-radius: 8px; padding: 3px; background-color: rgba(14,21,37,.84); }
  .touch-move { width: clamp(41px, 11svh, 55px); height: clamp(41px, 11svh, 55px); }
  .touch-utility { width: clamp(38px, 9.5svh, 49px); height: clamp(38px, 9.5svh, 49px); }
  .touch-action { width: clamp(42px, 10.5svh, 54px); height: clamp(42px, 10.5svh, 54px); }
  .touch-glyph { font-size: clamp(13px, 3.7svh, 18px); }
  .touch-label { font-size: clamp(6px, 1.65svh, 8px); }
}
