@import url("https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700;800&family=DM+Mono:wght@400;500&display=swap");

:root {
  color-scheme: dark;
  --ink: #eaf8ff;
  --muted: #8ea6bc;
  --cyan: #50f0ff;
  --pink: #ff5d9f;
  --gold: #ffc35b;
  --void: #060711;
  --panel: rgba(12, 16, 33, 0.86);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--void);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% -10%, rgba(76, 23, 108, 0.38), transparent 32rem),
    radial-gradient(circle at 10% 90%, rgba(0, 167, 210, 0.18), transparent 32rem),
    #060711;
  font-family: "DM Mono", ui-monospace, monospace;
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: 20px clamp(16px, 3vw, 44px) 28px;
}

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

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-family: "Barlow Condensed", Impact, sans-serif;
  font-size: clamp(24px, 3vw, 36px);
  font-style: italic;
  font-weight: 800;
  letter-spacing: 0.07em;
  line-height: 1;
  text-decoration: none;
}

.wordmark i {
  width: 18px;
  height: 4px;
  transform: skewX(-28deg);
  background: var(--pink);
  box-shadow: 0 0 12px var(--pink);
}

.wordmark span:last-child {
  color: var(--cyan);
  text-shadow: 0 0 16px rgba(80, 240, 255, 0.52);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #75ff9f;
  box-shadow: 0 0 9px #75ff9f;
  animation: pulse 2s infinite;
}

.icon-button {
  margin-left: 10px;
  padding: 7px 9px;
  border: 1px solid rgba(142, 166, 188, 0.35);
  color: #c9d9e6;
  background: rgba(7, 10, 24, 0.7);
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.04em;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(80, 240, 255, 0.08);
  outline: none;
}

.game-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(115, 214, 255, 0.29);
  background: #080b1a;
  box-shadow: 0 0 0 1px rgba(255, 93, 159, 0.12), 0 22px 60px rgba(0, 0, 0, 0.42);
  aspect-ratio: 16 / 9;
}

.game-stage::before,
.game-stage::after {
  position: absolute;
  z-index: 5;
  width: 15px;
  height: 15px;
  content: "";
  pointer-events: none;
}

.game-stage::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid var(--cyan);
  border-left: 2px solid var(--cyan);
}

.game-stage::after {
  right: -1px;
  bottom: -1px;
  border-right: 2px solid var(--pink);
  border-bottom: 2px solid var(--pink);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.scanlines {
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 4px);
  mix-blend-mode: overlay;
}

.overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at center, rgba(11, 16, 39, 0.5), rgba(4, 5, 15, 0.84));
  transition: opacity 280ms ease, visibility 280ms ease;
}

.overlay.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.intro-card,
.result-card {
  width: min(100%, 600px);
  padding: clamp(24px, 4vw, 50px);
  border: 1px solid rgba(136, 235, 255, 0.34);
  background: linear-gradient(135deg, rgba(13, 20, 45, 0.94), rgba(15, 12, 33, 0.91));
  box-shadow: 0 0 36px rgba(80, 240, 255, 0.1), inset 0 0 42px rgba(255, 93, 159, 0.045);
  text-align: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 10px;
  letter-spacing: 0.2em;
}

.intro-card h1,
.result-card h2 {
  margin: 0;
  font-family: "Barlow Condensed", Impact, sans-serif;
  font-size: clamp(60px, 12vw, 116px);
  font-style: italic;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 0.78;
}

.intro-card h1 span {
  display: block;
  color: #eaf8ff;
}

.intro-card h1 em {
  display: block;
  color: var(--pink);
  font-style: inherit;
  text-shadow: 4px 4px 0 rgba(80, 240, 255, 0.55);
}

.intro-copy {
  max-width: 430px;
  margin: 27px auto 23px;
  color: #b5c9da;
  font-size: clamp(12px, 1.5vw, 14px);
  line-height: 1.8;
}

.primary-button {
  display: inline-flex;
  min-width: min(100%, 260px);
  min-height: 50px;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
  padding: 0 18px 0 22px;
  border: 1px solid var(--cyan);
  color: #04121a;
  background: var(--cyan);
  box-shadow: 4px 4px 0 rgba(255, 93, 159, 0.8), 0 0 18px rgba(80, 240, 255, 0.34);
  cursor: pointer;
  font-family: "Barlow Condensed", Impact, sans-serif;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.05em;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.primary-button b {
  color: #0e5964;
  font-family: "DM Mono", monospace;
  font-size: 12px;
}

.primary-button:hover,
.primary-button:focus-visible {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 rgba(255, 93, 159, 0.9), 0 0 25px rgba(80, 240, 255, 0.45);
  outline: none;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-top: 31px;
}

.control-grid div {
  display: grid;
  min-height: 55px;
  place-items: center;
  align-content: center;
  gap: 5px;
  padding: 6px 4px;
  border: 1px solid rgba(142, 166, 188, 0.18);
  color: var(--muted);
  font-size: 9px;
}

kbd {
  min-width: 20px;
  padding: 2px 4px;
  border: 1px solid rgba(234, 248, 255, 0.35);
  border-bottom-width: 2px;
  border-radius: 2px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  font-family: inherit;
  font-size: 10px;
}

.hint {
  margin: 17px 0 0;
  color: rgba(142, 166, 188, 0.75);
  font-size: 9px;
}

.result-card h2 {
  color: var(--cyan);
  text-shadow: 4px 4px 0 rgba(255, 93, 159, 0.5);
}

.result-card h2.loss {
  color: var(--pink);
  text-shadow: 4px 4px 0 rgba(80, 240, 255, 0.35);
}

.result-card > p:not(.eyebrow) {
  color: #c1d4e2;
  font-size: 13px;
  line-height: 1.7;
}

.result-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin: 20px 0;
}

.result-stats span {
  min-width: 112px;
  padding: 11px 8px;
  border: 1px solid rgba(142, 166, 188, 0.22);
  color: var(--muted);
  font-size: 9px;
}

.result-stats b {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-family: "Barlow Condensed", Impact, sans-serif;
  font-size: 23px;
}

.toast {
  position: absolute;
  z-index: 6;
  top: 66%;
  left: 50%;
  margin: 0;
  transform: translate(-50%, 10px);
  color: var(--gold);
  opacity: 0;
  font-family: "Barlow Condensed", Impact, sans-serif;
  font-size: clamp(18px, 3vw, 28px);
  font-style: italic;
  font-weight: 800;
  letter-spacing: 0.07em;
  pointer-events: none;
  text-shadow: 0 0 16px rgba(255, 195, 91, 0.6);
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 22px;
  padding: 12px 2px 0;
  color: #7891a8;
  font-size: 10px;
  line-height: 1.6;
}

.legend p {
  margin: 0;
}

.legend strong {
  color: #cce0ef;
  font-weight: 500;
}

.legend-mark {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  transform: rotate(45deg);
}

.cyan { background: var(--cyan); }
.pink { background: var(--pink); }
.gold { background: var(--gold); }

.touch-controls {
  display: none;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 2px 0;
  user-select: none;
}

.touch-cluster {
  display: flex;
  align-items: center;
  gap: 7px;
}

.touch-controls button {
  width: 47px;
  height: 47px;
  border: 1px solid rgba(174, 221, 245, 0.35);
  border-radius: 50%;
  color: #ddecf5;
  background: rgba(15, 22, 42, 0.85);
  box-shadow: inset 0 0 15px rgba(80, 240, 255, 0.06);
  touch-action: none;
}

.touch-controls button:active,
.touch-controls button.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(80, 240, 255, 0.17);
}

.touch-controls .punch { border-color: rgba(80, 240, 255, 0.6); }
.touch-controls .kick { border-color: rgba(255, 93, 159, 0.65); }
.touch-controls .block { border-color: rgba(255, 195, 91, 0.55); }
.touch-controls .uppercut { border-color: rgba(184, 126, 255, 0.72); }
.touch-controls .sweep { border-color: rgba(255, 139, 82, 0.7); }

.touch-cluster.attacks {
  display: grid;
  grid-template-columns: repeat(3, 47px);
  gap: 7px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.38; transform: scale(0.7); }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px 10px 20px;
  }

  .topbar {
    min-height: 28px;
    margin-bottom: 10px;
  }

  .topbar-actions {
    gap: 5px;
    font-size: 8px;
  }

  .status-copy {
    display: none;
  }

  .icon-button {
    margin-left: 3px;
    padding: 5px 6px;
    font-size: 8px;
  }

  .intro-card,
  .result-card {
    padding: 24px 17px;
  }

  .intro-copy {
    margin: 18px auto;
    font-size: 11px;
    line-height: 1.6;
  }

  .control-grid {
    gap: 3px;
    margin-top: 24px;
  }

  .control-grid div {
    min-height: 44px;
    font-size: 8px;
  }

  .hint {
    font-size: 8px;
  }

  .legend {
    font-size: 8px;
  }

  .touch-controls {
    display: flex;
  }

  .touch-cluster.attacks {
    grid-template-columns: repeat(3, 43px);
    gap: 5px;
  }

  .overlay {
    position: fixed;
    z-index: 100;
    overflow-y: auto;
    align-items: center;
    padding: 20px 14px;
    background: rgba(4, 5, 15, 0.9);
  }

  .result-stats {
    gap: 6px;
  }

  .result-stats span {
    min-width: 92px;
    padding: 8px 5px;
  }
}

@media (max-width: 420px) {
  .topbar-actions .status-dot {
    display: none;
  }

  .intro-card h1,
  .result-card h2 {
    font-size: 54px;
  }

  .primary-button {
    min-height: 44px;
    font-size: 18px;
  }

  .touch-controls button {
    width: 43px;
    height: 43px;
  }

  .touch-controls {
    gap: 10px;
  }
}
