:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #11151c;
  color: #f2f4f7;
  --line: #343e4d;
  --muted: #b5c0cd;
  --lime: #dbf78a;
  --blue: #82d8ff;
  --red: #ff836f;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
body { margin: 0 }
button, select, input { font: inherit; color: inherit }
button, select {
  min-height: 42px; border: 1px solid var(--line); border-radius: 8px;
  background: #202833; padding: 6px 10px; cursor: pointer;
}
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px }
button:disabled { opacity: .48; cursor: default }
.shell {
  width: min(100%, 530px); margin: auto; padding: 11px 12px 12px;
  padding-top: max(11px, env(safe-area-inset-top)); padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.header, .matchbar, .panel-top, .match-status, .hud-line, .settings-actions {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.header { margin-bottom: 10px }
h1, h2, h3, p { margin: 0 }
h1 { font-size: 24px; letter-spacing: .06em; line-height: 1.1 }
.header p { margin-top: 3px; font-size: 12px; color: var(--muted) }
.header p span { margin-left: 5px; color: var(--lime) }
.small-button { font-size: 14px }
#match { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none }
.matchbar { margin-bottom: 6px }
#strategy { font-size: 14px; min-height: 35px }
#timer { font-size: 19px; letter-spacing: .06em; font-weight: 750; font-variant-numeric: tabular-nums }
.hud {
  padding: 6px 10px; background: #1a212b;
  border: 1px solid var(--line); border-radius: 9px;
}
.hud-line { height: 21px; font-size: 13px }
.hud-line b { font-size: 13px; letter-spacing: .07em }
.hud-line span { font-variant-numeric: tabular-nums }
.hud-row { display: grid; grid-template-columns: 57px minmax(0,1fr) 56px; align-items: center; gap: 6px; min-height: 18px }
.bar-label, .hud-row output { font-size: 13px; color: #d7e0e9; white-space: nowrap }
.hud-row output { text-align: right; font-variant-numeric: tabular-nums }
.track { height: 7px; background: #343d49; border-radius: 2px; overflow: hidden }
.fill { display: block; height: 100%; transform-origin: left; background: var(--bar); border-radius: 2px }
.hp { --bar: #a8ef9c }
.cpu-hud .hp { --bar: var(--red) }
.stamina { --bar: var(--blue) }
.charge-bar { --bar: #ffd07b }
.at-max .fill { background: #ffe8a2; box-shadow: 0 0 8px #ffd07b }
.at-max output { color: #ffe8a2; font-weight: bold }
.match-status { min-height: 28px; font-size: 12px; color: var(--muted) }
#player-status { color: #e9f1fb; font-weight: 750 }
.controls, .utility { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px }
.controls { touch-action: none }
.action {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: none; min-height: 70px; padding: 7px 2px;
  background: #172b36; border: 1px solid #37647b; box-shadow: inset 0 -3px #0004;
}
.action b, .action span { display: block }
.action b { font-size: 18px }
.action span { font-size: 12px; margin-top: 2px; opacity: .83 }
.guard { color: #beeaff }
.punch, .accent, #primary { background: var(--lime); color: #1b2513; border-color: var(--lime); font-weight: 800 }
.charge { background: #322919; color: #ffe1a0; border-color: #735c34 }
.action[aria-pressed=true] { outline: 2px solid currentColor; outline-offset: -4px; filter: brightness(1.24) }
.controls[data-locked=true] .action { opacity: .65 }
.utility { margin-top: 7px }
.utility button { font-size: 13px; padding-inline: 2px }
.ring {
  position: relative; isolation: isolate; height: 270px; height: clamp(202px, 37svh, 355px);
  overflow: hidden; background: radial-gradient(ellipse at 50% 30%,#424960,#181e32 55%,#101522 85%);
  border: 1px solid #505b71; border-radius: 9px; margin: 7px 0; touch-action: none;
}
.mat { position:absolute; inset:56% -12% -18%; background:radial-gradient(ellipse at 50% 20%, #677890, #2d3c54 74%); border-top:3px solid #9ba8b9; transform:perspective(300px) rotateX(27deg); transform-origin:top }
.lights { position:absolute; width:90%; left:5%; height:26%; background:radial-gradient(ellipse at 14% 12%,#f4f1dbcf 1%,#adc8fa44 8%,transparent 24%),radial-gradient(ellipse at 86% 12%,#f4f1dbcf 1%,#adc8fa44 8%,transparent 24%) }
.ropes { position:absolute; inset:35% 0 auto; height:23%; display:flex; flex-direction:column; justify-content:space-between }
.ropes i { height:4px; background:#b64f55; border-top:1px solid #ff8a86; box-shadow:0 2px #121726 }
.ropes i:nth-child(2) { background: #b1bfd2; border-color:#e5eaf2 }
.cpu-status, .event {
  position:absolute; z-index:5; left:50%; transform:translateX(-50%); width:max-content;
  max-width:95%; background:#111723ed; border:1px solid #6a7589; padding:4px 9px;
  border-radius:5px; font-size:12px; font-weight:750; text-align:center;
}
.cpu-status { top:7px }
.event { bottom:8px; min-height:25px; color:#fff4d5; pointer-events:none }
.event:empty { display:none }
.boxer-position { position:absolute; inset:13% 18% 4%; display:grid; justify-items:center }
.boxer {
  position:relative; width:100%; max-width:280px; height:100%;
  transform-origin:50% 82%; transition:filter .1s;
}
.boxer > *, .hands > * { position:absolute }
.shadow { width:62%; height:11%; bottom:5%; left:19%; background:#13192999; border-radius:50%; filter:blur(3px) }
.legs { width:43%; left:28.5%; top:69%; bottom:8%; background:linear-gradient(96deg,#25273a 42%,#111525 43% 57%,#343044 58%); border-radius:10% 10% 25% 25% }
.torso { width:56%; left:22%; top:34%; height:42%; background:linear-gradient(100deg,#87392f,#d28565 31%,#e89a76 52%,#a25b47 75%,#642b30); border:2px solid #512a30; border-radius:36% 36% 29% 29% }
.belt { left:25%; width:50%; top:68%; height:11%; border:2px solid #272131; background:linear-gradient(#f79666 0 22%,#57344b 23%); border-radius:10px }
.neck { top:27%; left:40%; width:20%; height:18%; background:#a4513e; border-radius:30% }
.head { top:4%; left:34%; width:32%; height:34%; border:2px solid #572f32; border-radius:43% 43% 46% 46%; background:linear-gradient(110deg,#9e5140,#e69169 40%,#c87558); box-shadow:inset -5px -4px #813d345e }
.head i { position:absolute; display:block }
.hair { top:-3%; left:-4%; width:108%; height:29%; border-radius:70% 65% 26% 38%; background:#251f2a; transform:rotate(-7deg) }
.brow { width:22%; height:7%; top:43%; background:#3b232d; border-radius:5px }
.brow.left { left:18%; transform:rotate(13deg) }
.brow.right { right:18%; transform:rotate(-13deg) }
.nose { width:11%; height:18%; top:47%; left:45%; border-radius:50%; box-shadow:2px 2px #814239 }
.mouth { background:#6a3637; width:24%; height:5%; top:76%; left:39%; border-radius:50% }
.arm { top:37%; height:38%; width:17%; background:linear-gradient(120deg,#b96950,#8b463b); border-radius:40%; border:2px solid #562a30 }
.arm.left { left:16%; transform:rotate(14deg) }
.arm.right { right:16%; transform:rotate(-14deg) }
.glove {
  --glove: #c63d51; --shine: #ff9c82; --shade: #661f3b;
  width:26%; height:35%; border-radius:51% 47% 28% 30%; border:2px solid var(--shade);
  background:radial-gradient(ellipse at 36% 24%,var(--shine),var(--glove) 42%,var(--shade) 97%);
  box-shadow:inset -5px -5px #13091f45, 0 4px 8px #0005;
  transform-origin:50% 70%;
}
.glove::before { content:""; position:absolute; inset:41% -11% 18% 71%; border-radius:30% 60% 47% 35%; border:2px solid var(--shade); background:var(--glove); box-shadow:inset -3px -3px #0003 }
.glove i { position:absolute; bottom:0; left:11%; right:10%; height:17%; border-radius:3px; background:#202532; border-top:2px solid #ffffff3f }
.enemy { top:41%; transform:translate(var(--x,0),var(--y,0)) rotate(var(--rot)) scale(var(--scale,1)) }
.enemy.left { left:13%; --rot:14deg }
.enemy.right { right:13%; --rot:-14deg }
.glove.right::before { transform:scaleX(-1); inset:41% 71% 18% -11% }
.boxer[data-pose=guard] .enemy { --y:-45%; --scale:1.08 }
.boxer[data-pose=guard] .enemy.left { --x:38% }
.boxer[data-pose=guard] .enemy.right { --x:-38% }
.boxer[data-pose=charge] .enemy, .boxer[data-pose=open] .enemy { --y:48% }
.boxer[data-pose=charge] { transform:translateY(5%) scale(.96); filter:drop-shadow(0 0 7px #ffd16b7a) }
.boxer[data-pose=open] { filter:grayscale(.78); transform:rotate(-7deg) translateY(6%) }
.boxer[data-fatigue=true]:not([data-pose=punch]):not([data-pose=open]) { filter:saturate(.43); animation:breathe .72s infinite alternate ease-in-out }
.boxer[data-pose=ko] { transform:translateY(43%) rotate(20deg); filter:grayscale(.9) }
@keyframes breathe { to { translate:0 4px } }
.hands { position:absolute; inset:0; pointer-events:none }
.own { --glove:#236fac; --shine:#b4ecff; --shade:#153254; width:30%; height:39%; bottom:-13%; transform:translate(var(--x,0),var(--y,0)) rotate(var(--rot)) scale(var(--scale,1)); }
.own.left { left:3%; --rot:25deg }
.own.right { right:3%; --rot:-25deg }
.hands[data-pose=guard] .own { --y:-52%; --scale:1.14 }
.hands[data-pose=guard] .own.left { --x:48% }
.hands[data-pose=guard] .own.right { --x:-48% }
.hands[data-pose=charge] .own { --y:55% }
.hands[data-pose=open] .own, .hands[data-pose=ko] .own { --y:58%; filter:grayscale(1) }
.hands[data-swing=true] .own.right {
  --x:calc(var(--reach) * -88%); --y:calc(var(--reach) * -128%); --scale:calc(1 + var(--reach) * .16); --rot:calc(-25deg - var(--reach) * 31deg);
}
.boxer[data-swing=true] .enemy.right {
  z-index:4; --x:calc(var(--reach) * -103%); --y:calc(var(--reach) * 15%); --scale:calc(1 + var(--reach) * 1.3);
}
.boxer[data-flash=hit] { rotate:-8deg }
.boxer[data-flash=block], .hands[data-flash=block] { filter:drop-shadow(0 0 8px #83e2ff) }
.boxer[data-flash=break], .hands[data-flash=break] { filter:drop-shadow(0 0 10px #ffd171) }
.ring[data-flash=hit] { box-shadow:inset 0 0 35px #f65d62; border-color:#ff9c9c }
.ring[data-flash=break] { box-shadow:inset 0 0 35px #f8bf66; border-color:#ffd796 }
.ring[data-flash=tired] { border-color:#a7c6de }
.overlay { position:absolute; z-index:8; inset:0; display:grid; place-content:center; justify-items:center; gap:15px; background:#101522c9 }
.overlay strong { font-size:26px; letter-spacing:.08em }
#primary { padding-inline:25px; min-height:49px }
.panel { border:1px solid var(--line); border-radius:10px; background:#1a212b; padding:13px }
.panel-top { margin-bottom:12px }
h2 { font-size:19px }
h3 { font-size:16px; margin:16px 0 7px }
.muted { font-size:13px; color:var(--muted); line-height:1.5 }
fieldset { border:1px solid var(--line); border-radius:8px; margin:13px 0; padding:5px 10px 8px; min-width:0 }
legend { font-weight:750; font-size:14px; padding:0 5px; color:var(--lime) }
.field { display:grid; grid-template-columns:minmax(0,1fr) 100px; align-items:center; gap:8px; padding:6px 0; border-bottom:1px solid #2d3744; font-size:13px }
.field:last-child { border-bottom:0 }
.field input { min-width:0; width:100%; min-height:39px; background:#111720; border:1px solid #526074; border-radius:6px; padding:5px 7px; font-size:16px }
.field small { display:block; color:var(--muted); margin-top:2px }
.curve-preview { font-size:13px; color:#ffe1a0; margin:10px 0 }
.settings-actions { display:grid; grid-template-columns:1fr 1fr }
.settings-actions .accent { grid-column:1 / -1 }
#save-status { margin-top:8px; font-size:13px; color:var(--lime) }
table { width:100%; border-collapse:collapse; font-size:14px }
th, td { text-align:left; border-bottom:1px solid var(--line); padding:7px 5px }
td { font-variant-numeric:tabular-nums }
.log { margin:0; padding:0; list-style:none; max-height:300px; overflow:auto }
.log li { padding:7px 0; border-bottom:1px solid var(--line); font-size:13px }
.log time { color:var(--muted); display:inline-block; min-width:55px; font-variant-numeric:tabular-nums }
details { padding:9px 2px; border-bottom:1px solid var(--line); font-size:13px }
summary { cursor:pointer }
details p { margin:6px 0 }
.sr { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap }
@media (max-height:700px) {
  .header { margin-bottom:5px }
  .ring { height:clamp(165px, 32svh, 228px) }
  .action { min-height:59px }
}
@media (prefers-reduced-motion: reduce) {
  .boxer { animation:none !important; transition:none }
}
@media (max-height:590px) {
  .ring { height:clamp(125px, 25svh, 165px) }
  .action { min-height:54px }
}
