:root {
  --line: #d8dbe2;
  --panel: #ffffff;
  --ink: #1b1d21;
  --muted: #5a6270;
  --accent: #2f6df6;
  --pen: #22d3ee;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: #eef1f6;
  color: var(--ink);
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, -apple-system, sans-serif;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 980px;
  margin: 0 auto;
  padding: 10px 12px;
  gap: 8px;
}

.top h1 { font-size: 17px; margin: 0; }
.notice { margin: 3px 0 0; font-size: 12px; color: var(--muted); }

.stage-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  position: relative;
  background: #0b0d12;
  border-radius: 14px;
  overflow: hidden;
}

.stage video,
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stage video { object-fit: contain; }

.stage.mirrored video,
.stage.mirrored canvas { transform: scaleX(-1); }

.stage-msg {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 94%;
  margin: 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(12, 15, 22, 0.72);
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  white-space: nowrap;
}

.result {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 190px;
  padding: 10px 16px 12px;
  border-radius: 12px;
  background: rgba(12, 15, 22, 0.84);
  color: #fff;
  text-align: center;
}

.result-title { margin: 0; font-size: 12px; color: #b9c2d6; }
.result-score { margin: 4px 0 3px; font-size: 26px; font-weight: 700; }
.result-detail { margin: 0; font-size: 12px; line-height: 1.45; color: #d7dcea; }

.timer {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(12, 15, 22, 0.75);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  z-index: 10;
}
.timer.warning {
  background: rgba(220, 38, 38, 0.85);
}

.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(12, 15, 22, 0.75);
  color: #fff;
  pointer-events: none;
  z-index: 10;
}

.hud[hidden] { display: none; }

.hud-score {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hud-shape {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #d7dcea;
}

.hud-progress {
  font-variant-numeric: tabular-nums;
  color: #9fb0d0;
}

.ranking-status {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: #b9c2d6;
}

.controls {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

button {
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field.check { color: var(--ink); }

.colors {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--c, #888);
}

.swatch.active {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 2px #fff;
}

select {
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.status {
  margin: 0 0 0 auto;
  font-size: 12.5px;
  line-height: 1.5;
  text-align: right;
  color: var(--muted);
}

@media (max-width: 520px) {
  .app { padding: 8px; }
  .top h1 { font-size: 16px; }
  button { padding: 7px 12px; }
  .result { min-width: 160px; }
  .result-score { font-size: 22px; }
  .hud { padding: 6px 10px; }
  .hud-score { font-size: 16px; }
  .stage-msg { font-size: 10.5px; }
}
