:root {
  color-scheme: dark;
  --bg: #07060f;
  --ink: #e7f7ff;
  --muted: #93a8bc;
  --cyan: #3dfff2;
  --magenta: #ff4ad2;
  --amber: #ffb020;
  --violet: #d16bff;
  --panel: rgba(8, 7, 18, 0.78);
  --line: rgba(61, 255, 242, 0.45);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

button, .screen { touch-action: manipulation; }

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--bg);
}

#rotate-hint {
  display: none;
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(8, 6, 16, 0.9);
  color: #ffe56a;
  border: 1px solid rgba(255, 229, 106, 0.65);
  font-size: 13px;
  letter-spacing: 0.04em;
  pointer-events: none;
  white-space: nowrap;
}

@media (orientation: portrait) and (max-width: 800px) {
  #rotate-hint { display: block; }
}

#btn-sound,
#btn-pause-live {
  position: fixed;
  z-index: 22;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(8, 8, 20, 0.82);
  color: var(--cyan);
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 8px 12px;
  cursor: pointer;
}

#btn-sound {
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
}

#btn-pause-live {
  display: none;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
}

body[data-mode="fight"] #btn-pause-live { display: block; }

#btn-sound:focus-visible,
#btn-pause-live:focus-visible,
.primary:focus-visible,
.ghost:focus-visible,
.card:focus-visible,
.seg button:focus-visible,
.touch-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 2vh, 28px);
  overflow: auto;
  pointer-events: none;
}

.screen[hidden] { display: none !important; }

#screen-pause,
#screen-result {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.46);
}

.panel {
  pointer-events: auto;
  width: min(980px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: clamp(14px, 2.4vh, 28px) clamp(14px, 3vw, 32px);
  box-shadow: 0 0 40px rgba(80, 0, 120, 0.28), inset 0 0 30px rgba(0, 0, 0, 0.28);
}

.eyebrow {
  margin: 0 0 4px;
  text-align: center;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--magenta);
  font-size: 12px;
  font-weight: 800;
}

.logo {
  margin: 0;
  text-align: center;
  font-size: clamp(40px, 8vw, 92px);
  line-height: 0.92;
  letter-spacing: 0.08em;
  font-weight: 900;
  color: #f4fffe;
  text-shadow:
    0 0 12px rgba(61, 255, 242, 0.85),
    0 0 28px rgba(61, 255, 242, 0.35),
    4px 4px 0 #3a1468;
}

.tag, .credit, .note, .howto p {
  text-align: center;
  color: var(--muted);
}

.tag { margin: 10px 0 0; font-size: clamp(15px, 2vw, 18px); }

.credit {
  margin: 6px 0 0;
  color: var(--amber);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 13px;
}

.row, .diff-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.primary, .ghost, .seg button {
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  min-height: 44px;
}

.primary {
  color: #041416;
  background: var(--cyan);
  border: 2px solid var(--cyan);
  box-shadow: 0 0 18px rgba(61, 255, 242, 0.35);
}

.ghost, .seg button {
  color: var(--ink);
  background: transparent;
  border: 2px solid rgba(180, 230, 255, 0.35);
}

.primary:hover, .ghost:hover, .seg button:hover, .card:hover {
  filter: brightness(1.08);
}

.screen h2 {
  margin: 0 0 8px;
  text-align: center;
  letter-spacing: 0.14em;
  font-size: clamp(22px, 4vw, 34px);
}

.howto {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 22px;
  margin-top: 8px;
}

.howto h3 {
  margin: 8px 0 4px;
  color: var(--cyan);
  letter-spacing: 0.08em;
  font-size: 14px;
}

.howto p { margin: 0 0 6px; text-align: left; line-height: 1.4; }

.keys {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  margin: 0;
  padding: 0;
}

.keys dt {
  color: var(--amber);
  font-weight: 800;
}

.keys dd { margin: 0; color: var(--ink); }

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.card {
  text-align: left;
  color: inherit;
  font: inherit;
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 8px;
  cursor: pointer;
  min-height: 44px;
}

.card.on {
  border-color: var(--card, var(--cyan));
  box-shadow: 0 0 18px color-mix(in srgb, var(--card, var(--cyan)) 45%, transparent);
}

.card canvas {
  width: 100%;
  height: auto;
  display: block;
  background: radial-gradient(circle at 50% 70%, rgba(61, 255, 242, 0.08), transparent 70%);
  border-radius: 10px;
}

.card h3 {
  margin: 6px 0 0;
  letter-spacing: 0.12em;
  font-size: 18px;
}

.card .role { margin: 0; color: var(--card, var(--cyan)); font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.card .moves, .card .blurb { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.35; }

.bars { margin-top: 6px; display: grid; gap: 3px; }
.bars span { display: flex; align-items: center; gap: 6px; font-size: 10px; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.bars i {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  font-style: normal;
}
.bars i::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--n) * 100%);
  border-radius: inherit;
  background: var(--card, var(--cyan));
}

.seg { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.seg button.on {
  border-color: var(--amber);
  color: #1a1204;
  background: var(--amber);
}

.note { font-size: 13px; margin: 10px 0 0; }

#result-title {
  font-size: clamp(36px, 7vw, 72px);
  margin: 0;
  text-align: center;
  letter-spacing: 0.08em;
  text-shadow: 0 0 18px rgba(61, 255, 242, 0.45);
}

#result-sub { text-align: center; color: var(--muted); margin: 8px 0 0; }

#touch { display: none; position: fixed; inset: 0; z-index: 8; pointer-events: none; }

@media (pointer: coarse), (max-width: 1100px) {
  body[data-mode="fight"] #touch { display: block; }
}

.stick {
  pointer-events: auto;
  position: absolute;
  left: max(12px, 2vw);
  bottom: max(12px, 2vh);
  width: min(30vw, 148px);
  height: min(30vw, 148px);
  border-radius: 50%;
  border: 2px solid rgba(61, 255, 242, 0.55);
  background: rgba(8, 16, 28, 0.45);
  box-shadow: inset 0 0 20px rgba(61, 255, 242, 0.12);
}

.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46%;
  height: 46%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 35%, #f4fffe, #14998c 70%);
  box-shadow: 0 0 12px rgba(61, 255, 242, 0.65);
}

.pad {
  pointer-events: none;
  position: absolute;
  right: max(12px, 2vw);
  bottom: max(12px, 2vh);
  width: min(46vw, 230px);
  height: min(42vw, 210px);
}

.touch-btn {
  pointer-events: auto;
  position: absolute;
  width: min(18vw, 74px);
  height: min(18vw, 74px);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(10, 8, 22, 0.62);
  color: white;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.touch-btn.is-down {
  background: rgba(61, 255, 242, 0.28);
  border-color: var(--cyan);
}

.touch-btn[data-act="jump"] { left: 50%; top: 0; transform: translateX(-50%); border-color: rgba(61, 255, 242, 0.7); }
.touch-btn[data-act="attack"] { left: 0; top: 38%; border-color: rgba(255, 176, 32, 0.75); }
.touch-btn[data-act="special"] { right: 0; top: 38%; border-color: rgba(209, 107, 255, 0.8); }
.touch-btn[data-act="shield"] { left: 50%; bottom: 0; transform: translateX(-50%); border-color: rgba(255, 74, 210, 0.7); }

@media (max-width: 640px) and (orientation: portrait) {
  .cards { grid-template-columns: 1fr; }
  .howto { grid-template-columns: 1fr; }
}

@media (max-height: 430px) {
  .logo { font-size: 34px; }
  .panel { padding: 8px 12px; }
  .blurb { display: none; }
  .card h3 { font-size: 15px; margin-top: 2px; }
  .bars { display: none; }
  .row, .diff-row { margin-top: 8px; }
  .primary, .ghost, .seg button { padding: 8px 12px; min-height: 36px; }
  .howto p { font-size: 13px; }
}
