
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100dvh;
  background: var(--bg-primary);
}

#game-wrapper {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  overflow: hidden;
  background: var(--board-bg);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--board-bg);
}

/* HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
}

#score-display, #best-display {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#score-display {
  align-items: flex-start;
}

#best-display {
  align-items: flex-end;
}

.hud-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hud-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

#best-value {
  color: var(--accent);
}

/* Overlay base */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--overlay-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 20;
  padding: 24px;
  gap: 0;
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Styleguide: overlay card */
.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px 32px;
  max-width: 360px;
  width: 90%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

/* Styleguide: title */
.game-title {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #3B82F6, #8B5CF6, #EC4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  text-align: center;
}

/* Styleguide: description */
.game-desc {
  font-size: 16px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.6;
}

/* Styleguide: hint */
.game-hint {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-align: center;
}

/* Styleguide: over title */
.over-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
}

/* Styleguide: CTA button */
.cta-btn {
  width: 100%;
  max-width: 320px;
  padding: 14px 48px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: filter .15s, transform .15s, box-shadow .15s;
  box-shadow: 0 4px 20px var(--accent-glow);
  letter-spacing: .5px;
}
.cta-btn:hover { filter: brightness(1.1); }
.cta-btn:active { transform: scale(0.97); }

/* Score card */
.score-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 32px;
  text-align: center;
  min-width: 200px;
}

.score-card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.score-card-value {
  font-size: 42px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-card-value.accent {
  color: var(--accent);
}

.score-card-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.01em;
}

.btn:active {
  background: var(--btn-active);
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-size: 17px;
  padding: 16px 48px;
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary:active {
  background: #2563eb;
  border-color: #2563eb;
}

.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Platform legend */
.platform-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 12px;
  height: 6px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-dot.normal { background: #4ade80; }
.legend-dot.moving { background: #60a5fa; }
.legend-dot.breakable { background: #a78060; }

.result-row {
  display: flex;
  gap: 12px;
}

.result-row .score-card {
  margin-bottom: 0;
  flex: 1;
}

/* Pause indicator */
#pause-btn {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
  padding: 4px 12px;
  cursor: pointer;
  z-index: 15;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#pause-btn:active {
  background: var(--btn-active);
}

/* Mobile tilt indicator */
#tilt-indicator {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.5s;
}

#tilt-indicator.visible {
  opacity: 1;
}

#tilt-bar-bg {
  width: 80px;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

#tilt-bar {
  position: absolute;
  top: 0;
  height: 100%;
  width: 4px;
  background: var(--accent);
  border-radius: 2px;
  left: 50%;
  transform: translateX(-50%);
  transition: left 0.05s;
}
