:root {
  --bg: #eceef6;
  --panel: #ffffff;
  --line: #d9dce8;
  --ink: #1b2030;
  --muted: #67708a;
  --accent: #5b4bd6;
  --accent-dark: #493bc0;
  --accent-soft: #ece9fd;
}

* { box-sizing: border-box; }

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

body {
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.app {
  width: 100%;
  max-width: 960px;
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 11px;
  min-height: 100%;
}

.title {
  font-size: 21px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.title::before {
  content: "";
  width: 8px;
  height: 21px;
  border-radius: 4px;
  background: var(--accent);
}

.stage {
  position: relative;
  width: 100%;
  flex: 0 0 auto;
  aspect-ratio: 16 / 9;
  max-height: 58vh;
  min-height: 0;
  background: #0e1219;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid #232a3c;
  box-shadow: 0 12px 28px rgba(28, 34, 60, 0.18);
}

.stage video {
  display: none;
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.status {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
  min-height: 20px;
  padding-left: 2px;
}

.status.error { color: #cf3b46; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 3px 10px rgba(28, 34, 60, 0.07);
}

.btn {
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.btn:hover:not(:disabled) {
  border-color: #b7bdd4;
  background: #f7f8fc;
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(91, 75, 214, 0.3);
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn:disabled {
  opacity: .45;
  cursor: default;
  box-shadow: none;
}

.picker {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
}

.picker select {
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.picker select:hover { border-color: #b7bdd4; }

.notice {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 18px;
  text-align: center;
  background: rgba(10, 14, 20, 0.74);
  color: #fff;
}

.game-overlay[hidden] { display: none; }

.overlay-message {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.55;
  max-width: 24em;
}

.hint {
  margin: 0;
  padding: 12px 16px 12px 30px;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--ink);
  background: var(--accent-soft);
  border-radius: 14px;
}

.hint b { color: var(--accent-dark); }

@media (max-height: 560px) {
  .app { gap: 8px; padding: 10px 12px 14px; }
  .title { font-size: 17px; }
  .title::before { height: 17px; }
  .notice { display: none; }
  .hint { font-size: 12px; line-height: 1.6; padding: 8px 12px 8px 26px; }
  .stage { max-height: 52vh; }
  .controls { padding: 9px; gap: 8px; }
}
