/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --text: #0d0d0d;
  --muted: #737373;
  --hint: #b8b8b8;
  --border: #ebebeb;
  --accent: #0d0d0d;
  --accent-hover: #2d2d2d;
  --chip-bg: #f3f3f3;
  --success: #16a34a;
  --r: 14px;
  --ease: cubic-bezier(0.65, 0, 0.35, 1);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Flow container ───────────────────────────────────────── */
.flow {
  position: relative;
  width: 100%;
  height: 100svh;
  overflow: hidden;
}

/* ── Screens ──────────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: translateY(100%);
  transition: transform 0.58s var(--ease);
  will-change: transform;
}

.screen.is-active   { transform: translateY(0); }
.screen.is-exited   { transform: translateY(-100%); }

/* Centered screens (intro, age, thanks) */
.screen--center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  overflow-y: auto;
}

.screen-inner {
  width: 100%;
  max-width: 520px;
}

/* ── Typography ───────────────────────────────────────────── */
.kicker {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}

h1 {
  font-size: clamp(48px, 10vw, 80px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 24px;
}

.intro-body {
  font-size: 18px;
  line-height: 1.65;
  color: var(--muted);
  margin-bottom: 40px;
  max-width: 420px;
}

.step-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hint);
  margin-bottom: 16px;
}

.q-title {
  font-size: clamp(28px, 6vw, 48px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 36px;
}

.q-title--sm {
  font-size: clamp(22px, 4vw, 32px);
  margin-bottom: 12px;
}

/* ── Button ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 15px 32px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease, opacity 0.15s ease, box-shadow 0.15s ease;
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.btn:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 2px 8px rgba(0,0,0,0.18); }
.btn:active:not(:disabled) { transform: scale(0.96); box-shadow: none; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn--full { width: 100%; justify-content: center; }

.arrow {
  display: inline-block;
  transition: transform 0.2s ease;
  font-style: normal;
}
.btn:hover .arrow { transform: translateY(3px); }

.btn-skip {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--hint);
  cursor: pointer;
  padding: 12px 8px;
  letter-spacing: 0.01em;
  transition: color 0.15s ease;
}
.btn-skip:hover { color: var(--muted); }

.btn-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

/* ── Drum picker ──────────────────────────────────────────── */
.drum-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 44px;
}

.drum {
  position: relative;
  width: 90px;
  height: 220px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  outline: none;
}
.drum:active { cursor: grabbing; }

.drum-scene {
  position: absolute;
  inset: 0;
  perspective: 600px;
}

.drum-item {
  position: absolute;
  left: 0; right: 0;
  height: 44px;
  top: 50%;
  margin-top: -22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  pointer-events: none;
  will-change: transform, opacity;
}

.drum-selector {
  position: absolute;
  top: calc(50% - 22px);
  left: -4px; right: -4px;
  height: 44px;
  border-top: 1.5px solid var(--border);
  border-bottom: 1.5px solid var(--border);
  pointer-events: none;
  z-index: 2;
}

.drum-fade {
  position: absolute;
  left: 0; right: 0;
  height: 104px;
  pointer-events: none;
  z-index: 1;
}
.drum-fade--top {
  top: 0;
  background: linear-gradient(to bottom, var(--bg) 10%, transparent 100%);
}
.drum-fade--bottom {
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 10%, transparent 100%);
}

.age-unit {
  font-size: 22px;
  font-weight: 500;
  color: var(--muted);
}

/* ── Ranking screen ───────────────────────────────────────── */
.screen--ranking {
  display: flex;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
}

.ranking-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  height: 100%;
  overflow: hidden;
}

.ranking-top {
  flex-shrink: 0;
  padding: 36px 28px 16px;
}

.ranking-hint {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--chip-bg);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--text);
}

.ranking-list {
  list-style: none;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 28px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  counter-reset: rank;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.ranking-bottom {
  flex-shrink: 0;
  padding: 16px 28px 32px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.privacy {
  font-size: 12px;
  color: var(--hint);
  margin-top: 10px;
  line-height: 1.5;
}

/* ── Dialect item ─────────────────────────────────────────── */
.d-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  user-select: none;
  -webkit-user-select: none;
  counter-increment: rank;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.d-item:hover { border-color: #d0d0d0; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }

.d-placeholder {
  flex: 0 0 auto;
  border-radius: 18px;
  background: transparent;
  pointer-events: none;
}

body.is-reordering,
body.is-reordering * {
  cursor: grabbing !important;
}

.d-item.is-dragging {
  cursor: grabbing !important;
  box-shadow: 0 12px 36px rgba(0,0,0,0.14);
  border-color: #d0d0d0;
  pointer-events: none;
  transition: box-shadow 0.15s, border-color 0.15s;
  will-change: transform;
}

.d-item.is-settling {
  pointer-events: none;
  will-change: transform;
}

.d-rank {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.d-rank::before { content: counter(rank); }
.d-item.is-dragging .d-rank::before { content: var(--drag-rank); }

.d-info {
  flex: 1 1 auto;
  min-width: 0;
}

.d-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.d-region {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.d-play {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--chip-bg);
  color: var(--text);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.12s;
  touch-action: manipulation;
}
.d-play:hover { background: #e8e8e8; }
.d-play:active { transform: scale(0.91); }
.d-play.is-playing { background: var(--accent); color: #fff; }
.d-play svg { width: 15px; height: 15px; }

.d-grip {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--hint);
  cursor: grab;
  touch-action: none;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.d-grip:hover { color: var(--muted); background: var(--chip-bg); }
.d-grip:active { cursor: grabbing; }
.d-grip svg { width: 18px; height: 18px; }

/* ── Thanks screen ────────────────────────────────────────── */
.screen-inner--thanks { text-align: center; }

.check-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

.check-svg {
  width: 72px;
  height: 72px;
}

.check-circle {
  stroke: var(--success);
  stroke-width: 2.5;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
}
.check-path {
  stroke: var(--success);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
}

.run-check .check-circle {
  animation: draw-stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.run-check .check-path {
  animation: draw-stroke 0.4s cubic-bezier(0.65, 0, 0.45, 1) 0.5s forwards;
}

@keyframes draw-stroke { to { stroke-dashoffset: 0; } }

.thanks-title {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.thanks-sub {
  font-size: 17px;
  color: var(--muted);
  margin-bottom: 8px;
}

.thanks-close {
  font-size: 14px;
  color: var(--hint);
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1a1a1a;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 1000;
  max-width: calc(100vw - 48px);
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  h1 { font-size: 44px; }
  .intro-body { font-size: 16px; }
  .ranking-top { padding: 24px 16px 12px; }
  .ranking-list { padding: 8px 16px; }
  .ranking-bottom { padding: 12px 16px 28px; }
  .d-name { font-size: 14px; }
  .age-input { width: 160px; }
}
