:root {
  color-scheme: dark;
  --bg: #121416;
  --panel: #1b2025;
  --panel-2: #20272e;
  --line: #39414a;
  --text: #f5f1e9;
  --muted: #aeb7c2;
  --wood: #bb7344;
  --wood-deep: #915231;
  --red: #ef5d4f;
  --blue: #52a7ff;
  --gold: #ffd166;
  --green: #66d18f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 30% 8%, rgba(255, 209, 102, 0.12), transparent 34rem),
    linear-gradient(135deg, #101214, #191e23 58%, #111416);
  color: var(--text);
  font-family:
    "Inter", "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

button {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #2a3138;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  min-height: 40px;
  padding: 0 14px;
}

button:hover,
.buttonLink:hover {
  background: #36414b;
}

button:disabled {
  cursor: default;
  opacity: 0.42;
}

button:disabled:hover {
  background: #2a3138;
}

.buttonLink {
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #2a3138;
  color: var(--text);
  display: inline-flex;
  font: inherit;
  min-height: 40px;
  padding: 0 14px;
  text-decoration: none;
}

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

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

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.05;
  margin: 0;
}

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

.editorShell {
  max-width: 1320px;
}

.compactEditorShell {
  max-width: 1440px;
}

.editorTopbar {
  padding: 14px 18px;
}

.editorTopbar h1 {
  font-size: 28px;
}

.editorGrid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 360px;
}

.compactEditorGrid {
  align-items: start;
  grid-template-columns: minmax(680px, 1fr) 420px;
}

.editorPreviewPanel,
.timelinePanel {
  background: rgba(27, 32, 37, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 16px;
}

.editorPreviewPanel canvas {
  aspect-ratio: 4 / 3;
  background: #121416;
  max-height: 56vh;
  object-fit: contain;
}

.editorStatus {
  color: var(--muted);
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 10px;
}

.editorStatus span {
  background: #11161a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  font-size: 12px;
  padding: 7px 8px;
  text-align: center;
}

.editorPanel {
  align-self: start;
}

.compactEditorPanel {
  max-height: calc(100vh - 128px);
  overflow: auto;
  padding: 14px;
}

.editorControlGrid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.editorControlGrid .jumpTools {
  grid-column: 1 / -1;
}

.editorControlGrid .flipField {
  align-self: end;
  margin-bottom: 12px;
}

.editorTabs {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
}

.editorTabs button.active {
  background: rgba(102, 209, 143, 0.18);
  border-color: rgba(102, 209, 143, 0.62);
  color: #dff8e9;
}

.editorPage[hidden] {
  display: none;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

.field small {
  color: rgba(220, 232, 242, 0.62);
  font-size: 11px;
}

.field select,
.field input[type="number"] {
  background: #11161a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  min-height: 40px;
  padding: 0 12px;
  width: 100%;
}

.field input[type="range"] {
  accent-color: var(--green);
  width: 100%;
}

.fpsControl {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.fpsControl strong {
  color: var(--green);
  font-size: 13px;
  white-space: nowrap;
}

.toggleField {
  align-items: center;
  color: var(--muted);
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.toggleField input {
  accent-color: var(--green);
  height: 18px;
  width: 18px;
}

.releasePointTools {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 2px;
  padding-top: 14px;
}

.shadowTools,
.staminaTools,
.hoopTools {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 2px;
  padding-top: 14px;
}

.staminaTools,
.hoopTools {
  margin-top: 10px;
}

.referenceTools {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 2px;
  padding-top: 14px;
}

.editorButtons {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
}

.editorExport {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 12px;
}

.editorExport summary {
  align-items: center;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  font-size: 13px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.editorExport textarea {
  background: #11161a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #dce8f2;
  font: 12px/1.45 Consolas, "Cascadia Mono", monospace;
  height: 180px;
  padding: 12px;
  resize: vertical;
  width: 100%;
}

.timelinePanel {
  margin-top: 16px;
}

.compactTimelinePanel {
  margin-top: 12px;
  padding: 12px;
}

.timeline {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(17, minmax(52px, 1fr));
  overflow-x: auto;
}

.frameCell {
  align-items: center;
  background: #151a1f;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-rows: 64px 42px auto;
  justify-items: center;
  min-height: 132px;
  padding: 6px;
  position: relative;
}

.frameCell.active {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(102, 209, 143, 0.25);
}

.frameCell.release {
  border-color: var(--gold);
}

.frameCell.move {
  box-shadow: inset 0 0 0 2px rgba(199, 146, 234, 0.28);
}

.frameCell.excluded {
  opacity: 0.42;
}

.frameCell.excluded img {
  filter: grayscale(1);
}

.frameCell.excluded::after {
  background: rgba(239, 93, 79, 0.9);
  border-radius: 999px;
  color: #fff;
  content: "剔除";
  font-size: 11px;
  font-weight: 800;
  padding: 2px 5px;
  position: absolute;
  right: 6px;
  bottom: 6px;
}

.frameCell.release::before {
  background: var(--gold);
  border-radius: 999px;
  color: #1c1606;
  content: "出手";
  font-size: 11px;
  font-weight: 800;
  left: 6px;
  padding: 2px 5px;
  position: absolute;
  top: 6px;
}

.frameCell.bounce {
  border-color: var(--blue);
}

.frameCell.bounce::after {
  background: var(--blue);
  border-radius: 999px;
  color: #061421;
  content: "落地";
  font-size: 11px;
  font-weight: 800;
  padding: 2px 5px;
  position: absolute;
  right: 6px;
  top: 6px;
}

.frameCell img {
  height: 64px;
  object-fit: contain;
  width: 100%;
}

.frameCell img.flipped {
  transform: scaleX(-1);
}

.frameCell i {
  align-self: end;
  background: linear-gradient(180deg, var(--green), rgba(102, 209, 143, 0.25));
  border-radius: 999px 999px 0 0;
  display: block;
  width: 12px;
}

.frameCell span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
}

.stage {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 320px;
}

canvas {
  aspect-ratio: 16 / 9;
  background: #16120f;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  display: block;
  width: 100%;
}

.panel {
  background: rgba(27, 32, 37, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 16px;
}

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

.score > div {
  background: var(--panel-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px;
}

.team {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.team.red {
  color: var(--red);
}

.team.blue {
  color: var(--blue);
}

.score strong {
  font-size: 36px;
  line-height: 1;
}

.score strong.scorePop {
  animation: scorePop 0.55s ease-out;
}

@keyframes scorePop {
  0% {
    color: var(--gold);
    transform: scale(1);
  }
  38% {
    color: #fff4bf;
    text-shadow: 0 0 20px rgba(255, 209, 102, 0.75);
    transform: scale(1.42);
  }
  100% {
    transform: scale(1);
  }
}

.meterBlock {
  margin-top: 16px;
}

.meterTop {
  color: var(--muted);
  display: flex;
  font-size: 13px;
  justify-content: space-between;
  margin-bottom: 7px;
}

.meter {
  background: #11161a;
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  position: relative;
}

.meter b,
.meter i {
  bottom: 0;
  display: block;
  left: 0;
  position: absolute;
  top: 0;
}

.meter b {
  background: linear-gradient(90deg, #e95b4e, #ffd166 60%, #66d18f);
  width: 0%;
}

.meter .sweet {
  background: rgba(255, 255, 255, 0.22);
  left: 50%;
  width: 20%;
  z-index: 1;
}

.meter.clock b {
  background: var(--blue);
  width: 100%;
}

.log {
  background: #11161a;
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  color: #f7e6ba;
  line-height: 1.5;
  margin-top: 16px;
  min-height: 74px;
  padding: 12px;
}

.help {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  margin-top: 16px;
  padding-top: 14px;
}

.help h2 {
  color: var(--text);
  font-size: 16px;
  margin: 0 0 8px;
}

.help p {
  margin: 7px 0;
}

@media (max-width: 980px) {
  .stage {
    grid-template-columns: 1fr;
  }

  .editorGrid {
    grid-template-columns: 1fr;
  }

  .compactEditorGrid {
    grid-template-columns: 1fr;
  }

  .panel {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compactEditorPanel {
    display: block;
    max-height: none;
  }

  .score,
  .help {
    grid-column: 1 / -1;
  }

  .meterBlock,
  .log {
    margin-top: 0;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 20px, 1240px);
    padding-top: 12px;
  }

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

  .actions {
    justify-content: stretch;
  }

  .actions button,
  .actions .buttonLink {
    flex: 1;
  }

  .panel {
    grid-template-columns: 1fr;
  }

  .editorStatus {
    grid-template-columns: 1fr 1fr;
  }

  .timeline {
    grid-template-columns: repeat(17, 68px);
  }
}
