:root {
  --bg: rgba(10, 10, 12, 0.65);
  --panel: rgba(0, 0, 0, 0.45);
  --text: #f3f4f6;
  --muted: rgba(243, 244, 246, 0.75);
  --line: rgba(255, 255, 255, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
}

.bk-image {
  background-image: url("images/background.jpg");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

.app {
  min-height: 100%;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: linear-gradient(
    rgba(0, 0, 0, 0.45),
    rgba(0, 0, 0, 0.55)
  );
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.2px;
}

.sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.hud {
  min-width: 200px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.hud-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  padding: 4px 0;
}

.hud-row .k {
  color: var(--muted);
}

.stage {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  align-items: start;
}

.canvas-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.25);
  box-shadow: var(--shadow);
  overflow: hidden;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 1 / 1;
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.55);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-title {
  font-weight: 600;
  font-size: 14px;
}

.loading-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.help {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.help h2 {
  margin: 0 0 10px;
  font-size: 14px;
}

.help ul {
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--muted);
  font-size: 13px;
}

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
}

.tip {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.5);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.05s ease, background 0.2s ease;
}

.btn:hover {
  background: rgba(0, 0, 0, 0.62);
}

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

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
}

.footer {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 0;
}

.dot {
  opacity: 0.7;
}

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

  .hud {
    min-width: unset;
  }
}

@media (max-width: 520px) {
  .app {
    padding: 14px;
  }

  .header {
    flex-direction: column;
  }
}
