/* Ringout. The battle is a canvas; everything here is the frame around it:
   menus, fighter and stage select, results, the manual, touch controls. */

:root {
  color-scheme: dark;
  --ink: #f6f4ff;
  --ink-2: #c3c1d9;
  --ink-3: #8d8aa8;
  --bg: #12142a;
  --panel: rgba(18, 20, 42, 0.94);
  --panel-2: rgba(32, 34, 66, 0.96);
  --line: rgba(255, 255, 255, 0.14);
  --red: #ff4b4b;
  --blue: #3d8bff;
  --gold: #ffd23c;
  --display: "Arial Black", "Segoe UI Black", "Helvetica Neue", Impact, system-ui, sans-serif;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
}

* { box-sizing: border-box; }

html, body, #shell { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body { background: var(--bg); color: var(--ink); }

#shell { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; }

#game { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

[hidden] { display: none !important; }

button, select, input { font: inherit; color: inherit; }

/* ------------------------------------------------------------ screens --- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 5;
}

.panelled {
  background:
    repeating-linear-gradient(-58deg, rgba(255, 255, 255, 0.025) 0 22px, transparent 22px 44px),
    radial-gradient(circle at 20% 0%, #2a2d5c 0%, transparent 55%),
    radial-gradient(circle at 90% 100%, #3a1d3a 0%, transparent 50%),
    var(--bg);
}

.dim { background: rgba(8, 9, 20, 0.6); align-items: center; justify-content: center; }

#loading { align-items: center; justify-content: center; background: var(--bg); z-index: 50; font: italic 900 22px var(--display); letter-spacing: 0.08em; }

/* ------------------------------------------------------------ buttons --- */

button {
  cursor: pointer;
  border: 0;
  border-radius: 6px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 2px var(--line);
  font-weight: 700;
  transition: transform 0.08s ease, background 0.12s ease, box-shadow 0.12s ease;
}
button:hover:not(:disabled), button:focus-visible { background: rgba(255, 255, 255, 0.18); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5); outline: none; }
button:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: linear-gradient(180deg, #ff6b5b, #e4303a); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35), 0 4px 0 #8a1622; color: #fff; }
button.primary:hover:not(:disabled), button.primary:focus-visible { background: linear-gradient(180deg, #ff8070, #f03a44); }
button.ghost { background: transparent; box-shadow: none; color: var(--ink-2); }
button.ghost:hover, button.ghost:focus-visible { color: var(--ink); background: rgba(255, 255, 255, 0.08); box-shadow: none; }

/* ---------------------------------------------------------------- title --- */

#title {
  justify-content: space-between;
  padding: max(28px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
  background: linear-gradient(90deg, rgba(10, 11, 26, 0.88) 0%, rgba(10, 11, 26, 0.55) 45%, rgba(10, 11, 26, 0) 70%);
}

.logo { display: flex; flex-direction: column; gap: 6px; transform: skewX(-8deg); transform-origin: left; }
.logo-word {
  font: italic 900 clamp(46px, 9vw, 104px) / 0.86 var(--display);
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 4px 0 #1b1d38, 5px 6px 0 rgba(0, 0, 0, 0.35);
}
.logo-word em { font-style: inherit; color: var(--red); }
.logo-sub { font: italic 900 clamp(10px, 1.5vw, 15px) var(--display); letter-spacing: 0.3em; color: var(--gold); padding-left: 4px; }

.menu { display: flex; flex-direction: column; gap: 10px; width: min(420px, 92vw); }
.menu .big {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 22px;
  text-align: left;
  transform: skewX(-8deg);
  background: rgba(18, 20, 42, 0.82);
  backdrop-filter: blur(4px);
}
.menu .big > * { transform: skewX(8deg); }
.menu .big b { font: italic 900 clamp(18px, 2.4vw, 26px) var(--display); letter-spacing: 0.02em; }
.menu .big span { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.menu .big.primary { background: linear-gradient(180deg, rgba(255, 107, 91, 0.95), rgba(228, 48, 58, 0.95)); }
.menu .big.primary span { color: rgba(255, 255, 255, 0.85); }
.menu .big:hover:not(:disabled), .menu .big:focus-visible { transform: skewX(-8deg) translateX(6px); }

.foot { display: flex; align-items: center; gap: 16px; color: var(--ink-3); font-size: 13px; }

/* ------------------------------------------------------------- bars --- */

.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
  border-bottom: 2px solid var(--line);
  background: rgba(8, 9, 22, 0.55);
}
.bar h2 { margin: 0; font: italic 900 clamp(18px, 2.6vw, 28px) var(--display); letter-spacing: 0.02em; text-transform: uppercase; }
.bar.bottom { margin-top: auto; border-bottom: 0; border-top: 2px solid var(--line); justify-content: flex-end; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.bar .hint { margin-right: auto; color: var(--ink-2); font-size: 14px; }
.bar .rules, .bar .rating { margin-left: auto; color: var(--ink-2); font-size: 13px; font-weight: 700; }
.go { font: italic 900 18px var(--display); padding: 12px 26px; letter-spacing: 0.03em; }

/* ------------------------------------------------------ fighter select --- */

.select-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  padding: 14px 18px;
}
.roster { grid-column: 1; grid-row: 1 / span 2; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; align-content: start; overflow: auto; padding: 2px 12px 2px 8px; }
.card {
  position: relative;
  aspect-ratio: 1 / 1.08;
  padding: 0;
  overflow: hidden;
  border-radius: 8px;
  transform: skewX(-6deg);
  background: linear-gradient(160deg, #2a2e5c, #191b38);
}
.card canvas { position: absolute; inset: 0; width: 100%; height: 100%; transform: skewX(6deg) scale(1.08); image-rendering: pixelated; }
.card .plate {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 4px 8px 5px;
  background: linear-gradient(0deg, rgba(8, 9, 22, 0.95), rgba(8, 9, 22, 0.6));
  font: italic 900 clamp(11px, 1.4vw, 16px) var(--display); text-transform: uppercase; letter-spacing: 0.03em; text-align: left;
}
.card .plate small { display: block; font: 600 10px system-ui, sans-serif; color: var(--ink-3); letter-spacing: 0; text-transform: none; }
.card .stars { position: absolute; top: 5px; right: 8px; font-size: 11px; color: var(--gold); text-shadow: 0 1px 0 #000; transform: skewX(6deg); }
.card.on-p1 { box-shadow: inset 0 0 0 3px var(--red), 0 0 18px rgba(255, 75, 75, 0.45); }
.card.on-cpu { box-shadow: inset 0 0 0 3px var(--blue), 0 0 18px rgba(61, 139, 255, 0.45); }
.card.on-p1.on-cpu { box-shadow: inset 0 0 0 3px var(--red), inset 0 0 0 6px var(--blue); }
.card.random { display: flex; align-items: center; justify-content: center; font: italic 900 42px var(--display); color: var(--ink-3); }

.slots { grid-column: 2; grid-row: 1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.slot { position: relative; padding: 8px; border-radius: 10px; background: var(--panel-2); box-shadow: inset 0 0 0 2px var(--line); cursor: pointer; }
.slot.active { box-shadow: inset 0 0 0 3px #fff; }
.slot.p1 { border-top: 5px solid var(--red); }
.slot.cpu { border-top: 5px solid var(--blue); }
.slot-art { display: block; width: 100%; aspect-ratio: 1; image-rendering: pixelated; border-radius: 6px; background: radial-gradient(circle at 50% 60%, #2f3366, #15172f); }
.slot-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-top: 6px; }
.slot-name b { font: italic 900 clamp(14px, 1.8vw, 20px) var(--display); text-transform: uppercase; }
.slot-name small { width: 100%; color: var(--ink-3); font-size: 12px; }
.tag { font: italic 900 11px var(--display); padding: 2px 6px; border-radius: 4px; background: var(--red); }
.cpu .tag { background: var(--blue); }
.colors { display: flex; gap: 6px; margin-top: 6px; }
.colors button { width: 22px; height: 22px; padding: 0; border-radius: 50%; }
.colors button.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(0, 0, 0, 0.5); }
.level { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.level input { flex: 1; accent-color: var(--blue); }
.level output { font: italic 900 18px var(--display); color: #fff; min-width: 16px; }
.vs { font: italic 900 clamp(20px, 3vw, 34px) var(--display); color: var(--gold); text-shadow: 0 3px 0 #000; }

.moves { grid-column: 2; grid-row: 2; overflow: auto; padding: 10px 14px; border-radius: 10px; background: var(--panel); box-shadow: inset 0 0 0 2px var(--line); font-size: 13px; }
.moves h3 { margin: 0 0 4px; font: italic 900 15px var(--display); text-transform: uppercase; }
.moves p { margin: 0 0 8px; color: var(--ink-2); }
.moves dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; }
.moves dt { font: italic 900 12px var(--display); color: var(--gold); white-space: nowrap; }
.moves dd { margin: 0; }
.moves dd b { display: block; }
.moves dd span { color: var(--ink-3); font-size: 12px; }

/* --------------------------------------------------------- stage select --- */

.stages { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 14px 18px; overflow: auto; align-content: start; }
.stage-card { position: relative; padding: 0; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #1b1d38; }
.stage-card canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.stage-card .plate { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 10px; text-align: left; background: linear-gradient(0deg, rgba(8, 9, 22, 0.95), rgba(8, 9, 22, 0)); }
.stage-card .plate b { display: block; font: italic 900 clamp(13px, 1.6vw, 18px) var(--display); text-transform: uppercase; }
.stage-card .plate span { font-size: 12px; color: var(--ink-2); }
.stage-card.on { box-shadow: inset 0 0 0 3px var(--gold), 0 0 18px rgba(255, 210, 60, 0.35); }
.stage-card.random { display: flex; align-items: center; justify-content: center; font: italic 900 36px var(--display); color: var(--ink-3); }

.rule-row { display: flex; flex-wrap: wrap; gap: 16px; padding: 4px 18px 14px; }
.rule-row label { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink-2); font-size: 14px; }
select { padding: 6px 10px; border-radius: 6px; border: 0; background: var(--panel-2); box-shadow: inset 0 0 0 2px var(--line); color: var(--ink); font-weight: 700; }

/* -------------------------------------------------------------- dialog --- */

.dialog { display: flex; flex-direction: column; gap: 10px; min-width: 260px; padding: 22px; border-radius: 12px; background: var(--panel); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 0 0 2px var(--line); }
.dialog h2 { margin: 0 0 6px; font: italic 900 30px var(--display); text-transform: uppercase; text-align: center; }

/* ------------------------------------------------------------- results --- */

.results-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: center; padding: 18px 24px; }
.winner { text-align: center; }
.winner-art { width: min(320px, 40vh); aspect-ratio: 1; image-rendering: pixelated; border-radius: 50%; background: radial-gradient(circle at 50% 55%, #3a3f7a, #15172f 70%); }
.winner h2 { margin: 6px 0 0; font: italic 900 clamp(26px, 4vw, 44px) var(--display); text-transform: uppercase; }
.winner p { margin: 4px 0 0; color: var(--ink-2); }
.stats { width: 100%; border-collapse: collapse; font-size: 15px; }
.stats th, .stats td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.stats th:first-child, .stats td:first-child { text-align: left; color: var(--ink-2); font-weight: 700; }
.stats thead th { font: italic 900 14px var(--display); text-transform: uppercase; }
.stats .p1 { color: #ffb0a8; }
.stats .p2 { color: #a8c8ff; }

/* ------------------------------------------------------------- how to --- */

.howto-body { flex: 1; min-height: 0; overflow: auto; padding: 16px 22px 30px; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; align-content: start; }
.howto-body section { padding: 14px 16px; border-radius: 10px; background: var(--panel); box-shadow: inset 0 0 0 2px var(--line); }
.howto-body h3 { margin: 0 0 8px; font: italic 900 17px var(--display); text-transform: uppercase; color: var(--gold); }
.howto-body p, .howto-body li { color: var(--ink-2); line-height: 1.5; font-size: 14px; }
.howto-body ul { margin: 0; padding-left: 18px; }
.howto-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
.howto-body td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.howto-body td:first-child { color: var(--ink-2); }
.howto-body td:last-child { font-weight: 700; text-align: right; }
.howto-body kbd { display: inline-block; padding: 1px 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.3); font: 700 12px system-ui, sans-serif; }

/* ------------------------------------------------------------ settings --- */

.settings-body { display: flex; flex-direction: column; gap: 18px; padding: 22px; max-width: 520px; }
.settings-body label { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.settings-body input[type=range] { flex: 1; accent-color: var(--red); }
.settings-body .note { color: var(--ink-3); font-size: 13px; }

/* -------------------------------------------------------------- online --- */

.online-body { flex: 1; min-height: 0; overflow: auto; padding: 16px 22px; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; align-content: start; }
.online-body section { padding: 14px 16px; border-radius: 10px; background: var(--panel); box-shadow: inset 0 0 0 2px var(--line); }
.online-body h3 { margin: 0 0 10px; font: italic 900 16px var(--display); text-transform: uppercase; }
.online-body ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.online-body li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.05); font-size: 14px; }
.online-body li .grow { flex: 1; }
.online-body li.empty { color: var(--ink-3); background: none; }
.online-body li.you { box-shadow: inset 0 0 0 2px var(--gold); }
.online-body form { display: flex; gap: 8px; margin-top: 10px; }
.online-body input[type=text] { flex: 1; padding: 8px 10px; border-radius: 6px; border: 0; background: var(--panel-2); box-shadow: inset 0 0 0 2px var(--line); }
.online-body .notice { grid-column: 1 / -1; padding: 10px 14px; border-radius: 8px; background: rgba(61, 139, 255, 0.15); color: #cfe0ff; }
.online-body .notice.bad { background: rgba(255, 75, 75, 0.15); color: #ffd0cc; }
.online-body li .row-rules { display: block; color: var(--ink-3); font-size: 12px; }
.online-body .note { margin: 10px 0 0; color: var(--ink-3); font-size: 13px; }
.online-body .rule-row { padding: 0 0 12px; gap: 12px; }
button.small { padding: 6px 12px; font-size: 13px; }

/* the duel's own fighter select borrows the CPU one's, and adds a stamp */
.stamp {
  position: absolute; top: 14px; left: 50%;
  transform: translateX(-50%) rotate(-8deg);
  padding: 4px 14px; border-radius: 6px;
  background: var(--gold); color: #1b1d38;
  font: italic 900 clamp(16px, 2.4vw, 26px) var(--display); text-transform: uppercase; letter-spacing: 0.04em;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}
.countdown { min-width: 48px; text-align: center; font: italic 900 22px var(--display); color: var(--ink-2); }
.countdown.soon { color: var(--gold); }
.rating-line { font: italic 900 18px var(--display); color: var(--gold) !important; }

#net { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
#net .net-ping { position: absolute; top: max(8px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); padding: 2px 8px; border-radius: 4px; background: rgba(8, 9, 22, 0.55); color: var(--ink-3); font: 700 11px system-ui, sans-serif; }
#net .net-ping:empty { display: none; }
#net .net-wait {
  position: absolute; left: 50%; top: 26%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 14px 22px; border-radius: 10px; pointer-events: auto;
  background: var(--panel); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), inset 0 0 0 2px var(--line);
}
#net .net-wait b { font: italic 900 18px var(--display); text-transform: uppercase; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { padding: 1px 7px; border-radius: 10px; background: rgba(255, 255, 255, 0.1); font-size: 11px; font-weight: 700; color: var(--ink-2); }

/* --------------------------------------------------------------- touch --- */

#touch { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
#touch .pad-zone { position: absolute; left: 0; top: 30%; bottom: 0; width: 45%; pointer-events: auto; }
#touch .pad-base { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25); left: 110px; bottom: 30px; top: auto; transform: translateY(60px); }
#touch .pad-base.live { transform: none; }
#touch .pad-knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); }
#touch .buttons { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); width: 230px; height: 190px; pointer-events: none; }
#touch .buttons button {
  position: absolute; pointer-events: auto; border-radius: 50%; padding: 0;
  background: rgba(20, 22, 44, 0.55); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  font: italic 900 15px var(--display); color: #fff;
  -webkit-tap-highlight-color: transparent;
}
#touch .buttons button.down { background: rgba(255, 255, 255, 0.35); }
#touch .t-attack { width: 76px; height: 76px; right: 0; bottom: 34px; font-size: 26px !important; background: rgba(228, 48, 58, 0.55) !important; }
#touch .t-special { width: 66px; height: 66px; right: 84px; bottom: 0; font-size: 22px !important; background: rgba(61, 139, 255, 0.5) !important; }
#touch .t-jump { width: 62px; height: 62px; right: 76px; bottom: 84px; }
#touch .t-shield { width: 56px; height: 56px; right: 0; bottom: 122px; font-size: 11px !important; }
#touch .t-grab { width: 50px; height: 50px; right: 152px; bottom: 60px; font-size: 11px !important; }
#touch .t-pause { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); pointer-events: auto; width: 44px; height: 32px; padding: 0; font-size: 12px; background: rgba(20, 22, 44, 0.55); }

#rotate { position: absolute; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: var(--bg); text-align: center; padding: 24px; }
#rotate b { font: italic 900 24px var(--display); }
#rotate span { color: var(--ink-2); }

.toast { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); z-index: 70; padding: 10px 16px; border-radius: 8px; background: var(--panel); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), inset 0 0 0 2px var(--line); font-weight: 700; }

/* ------------------------------------------------------- small screens --- */

@media (max-width: 900px), (max-height: 520px) {
  .select-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 8px 10px; gap: 8px; }
  .roster { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .card { aspect-ratio: 1 / 0.92; }
  .moves { font-size: 12px; }
  .slot { padding: 5px; }
  .level { margin-top: 4px; }
  .stages { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 8px 10px; gap: 8px; }
  .bar { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
  .bar .hint { font-size: 12px; }
  .go { padding: 9px 16px; font-size: 15px; }
  .results-body { padding: 8px 14px; gap: 10px; }
  .stats { font-size: 13px; }
  .stats th, .stats td { padding: 5px 8px; }
  .menu { gap: 6px; }
  .menu .big { padding: 8px 16px; }
}

@media (max-height: 420px) {
  .slot-art { aspect-ratio: 1.5; }
  .moves { display: none; }
  .slots { grid-row: 1 / span 2; }
  .logo-word { font-size: 44px; }
  .menu .big span { display: none; }
}
