:root {
  --bg1: #0d1024;
  --bg2: #1f2f5e;
  --panel: rgba(10, 15, 35, 0.72);
  --text: #eaf2ff;
  --muted: #a9b7df;
  --accent: #7de2ff;
  --accent2: #9c7dff;
  --danger: #ff7f93;
  --success: #72f2a4;
  --gold: #ffd166;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 20%, rgba(156, 125, 255, 0.22), transparent 22%),
    radial-gradient(circle at 80% 10%, rgba(125, 226, 255, 0.18), transparent 18%),
    linear-gradient(180deg, var(--bg2), var(--bg1));
  overflow: hidden;
}

.app {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 18px;
}

.game-shell {
  width: min(100%, 460px);
  display: grid;
  gap: 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow:
    0 14px 40px rgba(0,0,0,0.28),
    inset 0 1px 0 rgba(255,255,255,0.05);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand .title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.back-home {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.back-home:hover {
  color: var(--text);
  text-decoration: underline;
}

.brand .title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand .subtitle {
  font-size: 0.82rem;
  color: var(--muted);
}

.meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  font-size: 0.9rem;
  white-space: nowrap;
}

.pill b {
  color: white;
}

.game-wrap {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow:
    0 24px 70px rgba(0,0,0,0.45),
    0 0 0 1px rgba(255,255,255,0.03) inset;
  background: #0c1020;
  touch-action: none;
  user-select: none;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 7 / 12;
  background: transparent;
}

.legend {
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.5;
}

.legend b {
  color: var(--text);
}

.legend .row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

.s-normal { background: #7de2ff; box-shadow: 0 0 12px #7de2ff; }
.s-moving { background: #9c7dff; box-shadow: 0 0 12px #9c7dff; }
.s-break  { background: #ff7f93; box-shadow: 0 0 12px #ff7f93; }
.s-boost  { background: #ffd166; box-shadow: 0 0 12px #ffd166; }

@media (max-width: 480px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .meta {
    justify-content: flex-start;
  }
}
