:root {
  --bg-top: #f8f1d7;
  --bg-bottom: #e1f0ea;
  --panel: rgba(255, 252, 245, 0.84);
  --panel-border: rgba(62, 76, 53, 0.12);
  --text-main: #1f2a1d;
  --text-muted: #53614e;
  --accent: #d85d33;
  --accent-dark: #9b3b18;
  --accent-soft: #fff1dc;
  --card-soft: rgba(255, 255, 255, 0.62);
  --shadow: 0 18px 45px rgba(47, 58, 42, 0.12);
  --ball-shadow: 0 10px 20px rgba(31, 42, 29, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 32%),
    radial-gradient(circle at 85% 18%, rgba(216, 93, 51, 0.18), transparent 22%),
    linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
}

button,
textarea {
  font: inherit;
}

.app {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.page {
  display: none;
}

.page.is-active {
  display: block;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

h1,
h2,
h3,
p,
ol {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}

h2 {
  font-size: clamp(1.8rem, 3.5vw, 3rem);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.04em;
}

h3 {
  font-size: 1.35rem;
  font-weight: 800;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.home-hero,
.hero,
.board,
.drop-panel,
.play-panel {
  position: relative;
  overflow: hidden;
}

.home-hero,
.hero {
  padding: 34px;
}

.board {
  margin-top: 22px;
  padding: 28px;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.8fr);
  gap: 18px;
  align-items: center;
}

.hero-badge,
.card-tag {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
}

.hero-badge {
  margin-bottom: 14px;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.description {
  max-width: 620px;
  margin-top: 18px;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-muted);
}

.hero-orb {
  display: grid;
  place-items: center;
  width: min(260px, 100%);
  aspect-ratio: 1;
  margin-left: auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0) 35%),
    linear-gradient(145deg, #ffb674, #d85d33 58%, #8f3417);
  box-shadow: inset 0 10px 24px rgba(255, 255, 255, 0.28), 0 24px 40px rgba(129, 53, 20, 0.2);
}

.hero-orb span {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  color: #fffdf9;
  letter-spacing: 0.08em;
}

.game-grid {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.three-up {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.game-card {
  min-height: 260px;
  padding: 26px;
  border-radius: 26px;
  border: 1px solid rgba(73, 89, 63, 0.12);
  background: var(--card-soft);
  box-shadow: var(--shadow);
}

.game-card.featured {
  background:
    radial-gradient(circle at top right, rgba(216, 93, 51, 0.16), transparent 28%),
    rgba(255, 255, 255, 0.72);
}

.game-card.featured.alt {
  background:
    radial-gradient(circle at top right, rgba(61, 141, 177, 0.18), transparent 28%),
    rgba(247, 254, 255, 0.74);
}

.game-card.muted {
  background: rgba(247, 247, 242, 0.72);
}

.card-head {
  margin-bottom: 14px;
}

.card-tag {
  margin-bottom: 12px;
  color: var(--accent-dark);
  background: rgba(216, 93, 51, 0.12);
}

.card-tag.soft {
  color: #4a5a43;
  background: rgba(74, 90, 67, 0.1);
}

.game-card p {
  color: var(--text-muted);
  line-height: 1.8;
}

.primary-button,
.secondary-button,
.back-link {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, opacity 180ms ease;
}

.primary-button {
  margin-top: 24px;
  padding: 16px 24px;
  font-weight: 800;
  color: #fffdf8;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 12px 24px rgba(159, 45, 18, 0.25);
}

.secondary-button {
  padding: 16px 24px;
  font-weight: 700;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 10px 20px rgba(47, 58, 42, 0.08);
}

.primary-button:hover,
.secondary-button:hover,
.back-link:hover {
  transform: translateY(-2px);
}

.primary-button:hover {
  box-shadow: 0 16px 30px rgba(159, 45, 18, 0.32);
}

.back-link {
  padding: 12px 18px;
  font-weight: 700;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 18px rgba(47, 58, 42, 0.08);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.board-header,
.course-header,
.ranking-header,
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.subtext {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.ticket-list {
  display: grid;
  gap: 14px;
}

.ticket {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(85, 98, 70, 0.12);
  opacity: 0;
  transform: translateY(10px);
  animation: rise 420ms ease forwards;
}

.ticket-label {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent-dark);
}

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

.ball {
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 800;
  color: #14210f;
  border: 2px solid rgba(20, 33, 15, 0.08);
  box-shadow: inset 0 3px 8px rgba(255, 255, 255, 0.5);
  background: var(--ball-color, #fffaf0);
}

.ball.range-1 {
  --ball-color: #f6d34d;
}

.ball.range-2 {
  --ball-color: #7ec8ff;
}

.ball.range-3 {
  --ball-color: #ff7f73;
}

.ball.range-4 {
  --ball-color: #a9aeb8;
}

.ball.range-5 {
  --ball-color: #a7e37b;
}

.drop-layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 20px;
}

.drop-panel,
.play-panel {
  padding: 28px;
}

.input-label {
  display: inline-block;
  margin-top: 22px;
  margin-bottom: 10px;
  font-weight: 700;
}

.participant-input {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  padding: 16px 18px;
  border-radius: 22px;
  border: 1px solid rgba(74, 90, 67, 0.18);
  background: rgba(255, 255, 255, 0.76);
  color: var(--text-main);
  line-height: 1.7;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.drop-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.drop-actions .primary-button,
.drop-actions .secondary-button {
  margin-top: 0;
}

.status-text {
  margin-top: 14px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.play-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 18px;
  align-items: start;
}

.course-wrap {
  min-width: 0;
}

.drop-course {
  position: relative;
  min-height: 1460px;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid rgba(74, 90, 67, 0.14);
  background:
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.9), transparent 18%),
    linear-gradient(180deg, rgba(255, 247, 235, 0.98), rgba(245, 250, 242, 0.98) 38%, rgba(235, 246, 250, 0.97));
}

.drop-course::before {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 22px;
  border: 1px dashed rgba(74, 90, 67, 0.16);
}

.pegs-layer,
.lanes-layer,
.obstacles-layer,
.balls-layer,
.finish-lane,
.countdown-overlay {
  position: absolute;
  inset: 0;
}

.drop-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.countdown-overlay {
  display: grid;
  place-items: center;
  font-family: "Noto Sans KR", sans-serif;
  font-size: clamp(5rem, 10vw, 8rem);
  font-weight: 800;
  color: rgba(216, 93, 51, 0.95);
  background: rgba(255, 252, 245, 0.32);
  backdrop-filter: blur(3px);
  z-index: 5;
  transition: opacity 220ms ease;
}

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

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 2px 0;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 6px;
}

.legend-dot.peg {
  background: #96a7a5;
}

.legend-dot.rotor {
  background: #d85d33;
}

.legend-dot.slider {
  background: #3d8db1;
}

.legend-dot.gate {
  background: #7aa355;
}

.peg {
  position: absolute;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  border-radius: 50%;
  background: linear-gradient(145deg, #cfd8d6, #96a7a5);
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.6);
}

.lane-guide {
  position: absolute;
  top: 28px;
  bottom: 40px;
  width: 2px;
  background: linear-gradient(180deg, rgba(216, 93, 51, 0.12), rgba(83, 97, 78, 0.02));
}

.obstacle {
  position: absolute;
}

.obstacle.rail {
  width: 220px;
  height: 12px;
  margin-left: -110px;
  margin-top: -6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(61, 141, 177, 0.15), rgba(61, 141, 177, 0.82), rgba(61, 141, 177, 0.15));
  box-shadow: 0 10px 18px rgba(61, 141, 177, 0.14);
}

.obstacle.rail.alt {
  background: linear-gradient(90deg, rgba(216, 93, 51, 0.15), rgba(216, 93, 51, 0.78), rgba(216, 93, 51, 0.15));
  box-shadow: 0 10px 18px rgba(216, 93, 51, 0.14);
}

.obstacle.rotor {
  width: 84px;
  height: 84px;
  margin-left: -42px;
  margin-top: -42px;
  animation: slow-rotate 9s linear infinite;
}

.obstacle.rotor::before,
.obstacle.rotor::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 78px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(216, 93, 51, 0.92), rgba(140, 47, 22, 0.86));
  transform: translate(-50%, -50%);
  box-shadow: 0 8px 16px rgba(140, 47, 22, 0.18);
}

.obstacle.rotor::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.obstacle.rotor .obstacle-core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.96), rgba(216, 93, 51, 0.82));
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.5);
}

.obstacle.slider {
  width: 128px;
  height: 18px;
  margin-left: -64px;
  margin-top: -9px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(61, 141, 177, 0.3), rgba(61, 141, 177, 0.86), rgba(61, 141, 177, 0.3));
  box-shadow: 0 10px 16px rgba(61, 141, 177, 0.15);
  animation: slide-guard 6.6s ease-in-out infinite alternate;
  animation-delay: var(--delay, 0s);
}

.obstacle.slider::before,
.obstacle.slider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-50%);
}

.obstacle.slider::before {
  left: 10px;
}

.obstacle.slider::after {
  right: 10px;
}

.obstacle.bumper {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.82);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.92), rgba(216, 93, 51, 0.68));
  box-shadow: 0 10px 16px rgba(216, 93, 51, 0.18);
}

.obstacle.gate {
  width: 66px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(74, 90, 67, 0.24), rgba(74, 90, 67, 0.52), rgba(74, 90, 67, 0.24));
}

.obstacle.ring {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 6px solid rgba(61, 141, 177, 0.45);
  background: transparent;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.36);
}

.obstacle.spark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(241, 181, 66, 0.42));
  box-shadow: 0 0 18px rgba(241, 181, 66, 0.3);
}

.finish-slot {
  position: absolute;
  bottom: 16px;
  width: 34px;
  height: 18px;
  margin-left: -17px;
  border-radius: 999px;
  background: rgba(83, 97, 78, 0.12);
}

.finish-slot.single {
  left: 50%;
  width: 72px;
  height: 72px;
  margin-left: -36px;
  bottom: 10px;
  border-radius: 26px 26px 18px 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(233, 241, 236, 0.88)),
    rgba(83, 97, 78, 0.12);
  border: 3px solid rgba(83, 97, 78, 0.28);
  box-shadow: inset 0 -10px 16px rgba(83, 97, 78, 0.16), 0 14px 22px rgba(31, 42, 29, 0.12);
}

.finish-slot.single::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 10px;
  width: 34px;
  height: 12px;
  margin-left: -17px;
  border-radius: 999px;
  background: rgba(83, 97, 78, 0.18);
}

.runner-ball {
  position: absolute;
  left: 0;
  top: 0;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.9rem;
  color: #fffdf9;
  box-shadow: var(--ball-shadow);
  text-align: center;
  padding: 6px;
  line-height: 1.15;
  z-index: 2;
}

.runner-ball.is-blocked {
  animation: blocked-bump 420ms ease;
}

.runner-ball.is-colliding {
  animation: collide-bump 360ms ease;
}

.runner-ball.is-finishing {
  animation: finish-pop 420ms ease;
}

.runner-ball span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ranking-panel,
.history-panel {
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(74, 90, 67, 0.12);
}

.ranking-panel {
  padding: 22px;
  min-height: 1460px;
  display: flex;
  flex-direction: column;
}

.ranking-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.ranking-item,
.history-item {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(74, 90, 67, 0.1);
}

.ranking-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  opacity: 0;
  transform: translateX(8px);
  animation: slide-in 260ms ease forwards;
}

.rank-badge {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  font-weight: 800;
  color: #fffdf9;
}

.rank-name {
  font-weight: 700;
}

.rank-meta {
  margin-top: 4px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.feed-panel {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(74, 90, 67, 0.12);
}

.history-header.compact {
  margin-bottom: 12px;
}

.event-feed {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}

.event-feed li {
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(74, 90, 67, 0.1);
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--text-muted);
  animation: slide-in 220ms ease forwards;
}

.event-feed .feed-time {
  display: inline-block;
  min-width: 48px;
  margin-right: 8px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--accent-dark);
}

.event-feed b {
  color: var(--text-main);
}

.empty-card {
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed rgba(74, 90, 67, 0.18);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.45);
  line-height: 1.7;
}

.history-panel {
  margin-top: 18px;
  padding: 22px;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-item {
  padding: 14px 16px;
}

.history-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent-dark);
}

.history-order {
  margin-top: 8px;
  color: var(--text-main);
  line-height: 1.7;
}

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slide-in {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slow-rotate {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes slide-guard {
  from {
    transform: translate(-36px, -50%);
  }

  to {
    transform: translate(36px, -50%);
  }
}

@keyframes blocked-bump {
  0% {
    filter: brightness(1);
    box-shadow: var(--ball-shadow);
  }

  25% {
    filter: brightness(1.14);
    box-shadow: 0 0 0 6px rgba(216, 93, 51, 0.2), var(--ball-shadow);
  }

  55% {
    box-shadow: 0 0 0 10px rgba(216, 93, 51, 0.12), var(--ball-shadow);
  }

  100% {
    filter: brightness(1);
    box-shadow: var(--ball-shadow);
  }
}

@keyframes collide-bump {
  0% {
    filter: saturate(1);
    box-shadow: var(--ball-shadow);
  }

  30% {
    filter: saturate(1.22);
    box-shadow: 0 0 0 6px rgba(61, 141, 177, 0.22), var(--ball-shadow);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(61, 141, 177, 0.12), var(--ball-shadow);
  }

  100% {
    filter: saturate(1);
    box-shadow: var(--ball-shadow);
  }
}

@keyframes finish-pop {
  0% {
    filter: brightness(1);
    box-shadow: var(--ball-shadow);
  }

  45% {
    filter: brightness(1.18);
    box-shadow: 0 0 0 8px rgba(127, 214, 109, 0.22), var(--ball-shadow);
  }

  100% {
    filter: brightness(1);
    box-shadow: var(--ball-shadow);
  }
}

@media (max-width: 1080px) {
  .three-up,
  .drop-layout,
  .play-stage {
    grid-template-columns: 1fr;
  }

  .ranking-panel {
    min-height: auto;
  }
}

@media (max-width: 820px) {
  .home-hero {
    grid-template-columns: 1fr;
  }

  .hero-orb {
    margin: 8px 0 0;
  }

  .topbar,
  .board-header,
  .course-header,
  .ranking-header,
  .history-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .app {
    width: min(100% - 20px, 720px);
    padding: 18px 0 28px;
  }

  .panel,
  .drop-course {
    border-radius: 22px;
  }

  .home-hero,
  .hero,
  .board,
  .game-card,
  .drop-panel,
  .play-panel,
  .history-panel,
  .ranking-panel {
    padding: 22px;
  }

  .ticket {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .numbers {
    gap: 8px;
  }

  .ball,
  .runner-ball {
    width: 46px;
    height: 46px;
  }

  .drop-actions {
    flex-direction: column;
  }

  .drop-course {
    min-height: 1120px;
  }
}
