:root {
  color: #eee7d8;
  background: #141413;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
  text-rendering: geometricPrecision;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(218, 178, 91, 0.1), transparent 260px),
    radial-gradient(circle at 72% 14%, rgba(108, 146, 128, 0.22), transparent 28%),
    #141413;
}

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

button,
select,
input {
  min-height: 40px;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
dialog:focus-visible,
textarea:focus-visible {
  outline: 2px solid #d8b26d;
  outline-offset: 2px;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 34px 0;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 5px;
  color: #d8b26d;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(44px, 7vw, 78px);
  line-height: 0.9;
  letter-spacing: 0;
}

h2 {
  font-size: 13px;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.button.primary {
  color: #171614;
  background: #d8b26d;
}

.button.secondary {
  color: #eee7d8;
  background: #34312b;
  box-shadow: inset 0 0 0 1px #5b5548;
}

.button.text {
  min-height: auto;
  padding: 4px 0;
  color: #d8b26d;
  background: transparent;
}

.arena {
  overflow: hidden;
  border: 1px solid #454138;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 40%),
    #22201d;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 78px;
  padding: 16px 18px;
  border-bottom: 1px solid #454138;
}

.hud > div {
  display: grid;
  gap: 3px;
}

.hud > div:last-child {
  justify-items: end;
  text-align: right;
}

.hud strong {
  color: #fff6e5;
  font-size: 28px;
  line-height: 1;
}

.hud small,
.label {
  color: #aaa08c;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.timer {
  justify-items: center;
  min-width: 124px;
  text-align: center;
}

.timer span {
  color: #86d4b2;
  font-size: 12px;
  font-weight: 900;
}

.stage {
  position: relative;
  overflow: hidden;
  --map-left: 72px;
  --map-right: calc(100% - 72px);
  height: 310px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 34%),
    linear-gradient(180deg, #101210 0%, #171813 70%, #0d0d0b 100%);
}

.stage::after {
  position: absolute;
  right: 0;
  bottom: 58px;
  left: 0;
  height: 5px;
  content: "";
  background: linear-gradient(90deg, transparent, #d8b26d 20%, #6c9280 50%, #d8b26d 80%, transparent);
  opacity: 0.72;
}

.fall-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: none;
  opacity: 0.82;
}

.fall-zone.left {
  left: 0;
  width: var(--map-left);
  background: linear-gradient(90deg, rgba(90, 23, 18, 0.52), transparent);
}

.fall-zone.right {
  left: var(--map-right);
  width: calc(100% - var(--map-right));
  background: linear-gradient(270deg, rgba(90, 23, 18, 0.52), transparent);
}

.fall-zone::after {
  position: absolute;
  top: 0;
  bottom: 58px;
  width: 2px;
  content: "";
  background: linear-gradient(180deg, transparent, rgba(240, 155, 124, 0.72), transparent);
}

.fall-zone.left::after {
  right: 0;
}

.fall-zone.right::after {
  left: 0;
}

.stage-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(216, 178, 109, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(216, 178, 109, 0.055) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, transparent, black 28%, black 86%, transparent);
}

.range-line {
  position: absolute;
  bottom: 46px;
  left: var(--map-left);
  width: calc(var(--map-right) - var(--map-left));
  height: 1px;
  background: repeating-linear-gradient(90deg, rgba(238, 231, 216, 0.38), rgba(238, 231, 216, 0.38) 8px, transparent 8px, transparent 18px);
}

.sprite {
  position: absolute;
  top: 0;
  left: 0;
  width: 120px;
  height: 80px;
  image-rendering: pixelated;
  background-repeat: no-repeat;
  background-size: auto 80px;
  transform-origin: center bottom;
  transition: transform 95ms linear, filter 80ms linear;
  filter: drop-shadow(0 16px 10px rgba(0, 0, 0, 0.48));
}

.sprite[data-flash="true"] {
  filter:
    brightness(1.65)
    drop-shadow(0 0 12px rgba(240, 155, 124, 0.75))
    drop-shadow(0 16px 10px rgba(0, 0, 0, 0.48));
}

.sprite[data-action="evade"] {
  filter:
    saturate(1.18)
    drop-shadow(0 0 10px rgba(108, 146, 128, 0.55))
    drop-shadow(0 16px 10px rgba(0, 0, 0, 0.48));
}

.sprite[data-action="light"],
.sprite[data-action="heavy"] {
  filter:
    saturate(1.1)
    drop-shadow(0 0 12px rgba(216, 178, 109, 0.34))
    drop-shadow(0 16px 10px rgba(0, 0, 0, 0.48));
}

.sprite[data-action="hitstun"] {
  filter:
    brightness(1.55)
    drop-shadow(0 0 12px rgba(240, 155, 124, 0.75))
    drop-shadow(0 16px 10px rgba(0, 0, 0, 0.48));
}

.damage-popup,
.miss-popup {
  position: absolute;
  z-index: 4;
  min-width: 32px;
  pointer-events: none;
  text-align: center;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  transform-origin: center;
  transition: transform 70ms linear, opacity 90ms linear;
}

.damage-popup {
  color: #ff5d4d;
  text-shadow:
    0 2px 0 #4b130f,
    0 0 10px rgba(255, 93, 77, 0.7);
}

.miss-popup {
  color: #f5d28c;
  font-size: 15px;
  text-shadow:
    0 2px 0 #3a2b13,
    0 0 9px rgba(245, 210, 140, 0.62);
}

.damage-popup[data-show="true"],
.miss-popup[data-show="true"] {
  opacity: 1;
}

.clash-effect {
  position: absolute;
  z-index: 5;
  min-width: 84px;
  pointer-events: none;
  color: #fff0b8;
  text-align: center;
  text-shadow:
    0 2px 0 #4a3212,
    0 0 14px rgba(255, 222, 135, 0.85);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  opacity: 0;
  transform-origin: center;
  transition: transform 80ms linear, opacity 100ms linear;
}

.clash-effect::before,
.clash-effect::after {
  position: absolute;
  top: 50%;
  width: 24px;
  height: 2px;
  content: "";
  background: #fff0b8;
  box-shadow: 0 0 10px rgba(255, 222, 135, 0.8);
}

.clash-effect::before {
  right: calc(100% + 6px);
}

.clash-effect::after {
  left: calc(100% + 6px);
}

.clash-effect[data-show="true"] {
  opacity: 1;
}

.meter-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 18px 16px;
}

.stamina-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.meter-row > div {
  display: grid;
  gap: 6px;
}

.meter-row span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #aaa08c;
  font-size: 11px;
  font-weight: 900;
}

.meter-row b {
  color: #eee7d8;
  font: inherit;
}

.meter {
  overflow: hidden;
  height: 7px;
  border-radius: 999px;
  background: #11100e;
}

.meter i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6c9280, #d8b26d);
  transition: width 120ms linear;
}

.stamina-meter i {
  background: linear-gradient(90deg, #6c9280, #d8b26d);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(240px, 0.7fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.side-panel,
.ladder-panel,
.log-panel {
  min-width: 0;
  border: 1px solid #454138;
  border-radius: 8px;
  background: #1e1c19;
}

.panel-heading,
.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
}

.panel-heading span {
  color: #aaa08c;
  font-size: 12px;
  font-weight: 800;
}

input {
  width: 100%;
  border: 1px solid #454138;
  border-radius: 6px;
  padding: 8px 10px;
  color: #eee7d8;
  background: #11100e;
}

textarea {
  display: block;
  width: calc(100% - 32px);
  min-height: 292px;
  margin: 0 16px 12px;
  border: 1px solid #38342d;
  border-radius: 6px;
  padding: 14px;
  resize: vertical;
  color: #eee7d8;
  background: #11100e;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.code-error {
  min-height: 20px;
  padding: 0 0 14px;
  color: #f09b7c;
  font-size: 13px;
}

.side-panel,
.ladder-panel,
.log-panel {
  padding: 14px 16px 16px;
}

.opponent-readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #38342d;
  padding-bottom: 12px;
  color: #aaa08c;
  font-size: 12px;
  font-weight: 800;
}

.ladder-status {
  min-height: 38px;
  border-bottom: 1px solid #38342d;
  padding: 10px 0 12px;
  color: #d9d0bd;
  font-size: 13px;
  line-height: 1.4;
}

.opponent-readout strong {
  color: #eee7d8;
  font-size: 13px;
}

.leaderboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 8px;
}

.leaderboard {
  display: grid;
  gap: 6px;
  max-height: 284px;
  overflow: auto;
  margin: 0;
  padding: 0 0 12px;
  border-bottom: 1px solid #38342d;
  list-style: none;
}

.leaderboard li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-left: 3px solid #6c9280;
  padding: 7px 9px;
  color: #d9d0bd;
  background: #141310;
  font-size: 12px;
}

.leaderboard strong {
  color: #fff6e5;
  font-size: 12px;
}

.side-panel label {
  display: block;
  margin-bottom: 7px;
}

select {
  width: 100%;
  border: 1px solid #454138;
  border-radius: 6px;
  padding: 8px 10px;
  color: #eee7d8;
  background: #11100e;
}

.log-head {
  padding: 18px 0 8px;
}

.log-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.battle-log {
  display: grid;
  gap: 7px;
  max-height: 284px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.character-dialog {
  width: min(760px, calc(100vw - 32px));
  border: 1px solid #5b5548;
  border-radius: 8px;
  padding: 0;
  color: #eee7d8;
  background: #1e1c19;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.character-dialog::backdrop {
  background: rgba(11, 10, 9, 0.72);
}

.character-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.character-form label {
  color: #aaa08c;
  font-size: 12px;
  font-weight: 800;
}

.modal-code-head {
  padding: 8px 0 0;
}

.character-form textarea {
  width: 100%;
  min-height: 360px;
  margin: 0;
}

.battle-log li {
  border-left: 3px solid #5b5548;
  padding: 8px 10px;
  color: #d9d0bd;
  background: #141310;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.35;
}

.battle-log li[data-type="hit"] {
  border-color: #d8b26d;
  color: #fff6e5;
}

.battle-log li[data-type="evade"] {
  border-color: #6c9280;
}

.battle-log li[data-type="clash"] {
  border-color: #aaa08c;
}

.battle-log li[data-type="result"] {
  border-color: #f09b7c;
}

@media (max-width: 860px) {
  .shell {
    width: min(100% - 24px, 1180px);
    padding: 24px 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: stretch;
  }

  .top-actions button {
    flex: 1 1 140px;
  }

  .hud {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .hud > div,
  .hud > div:last-child {
    justify-items: start;
    text-align: left;
  }

  .timer {
    justify-items: start;
  }

  .stage {
    height: 260px;
  }

  .damage-popup {
    font-size: 18px;
  }

  .miss-popup {
    font-size: 13px;
  }

  .clash-effect {
    font-size: 15px;
  }

  .meter-row,
  .workspace {
    grid-template-columns: 1fr;
  }
}
