:root {
  font-family: "Trebuchet MS", "Noto Sans KR", sans-serif;
  color-scheme: light;
  --ink: #202a3b;
  --muted: #6e7480;
  --line: #e8e0d2;
  --accent: #e4583d;
  --accent-hover: #c94731;
  --bg-page: #f7f4ed;
  --bg-glow: #fffdf7;
  --bg-panel: #fffdf9;
  --bg-ticket: #f8f5ee;
  --line-ticket: #eee6d8;
  --button-ink: #fffdf9;

  color: var(--ink);
  background: var(--bg-page);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef1f7;
  /* Secondary text sits at 12-14px across the stats page, where the old #9aa2b4
     (5.5:1 on a ticket) read as washed out; this lifts it to ~6.9:1. */
  --muted: #aeb6c4;
  --line: #363c4c;
  --accent: #ff7452;
  --accent-hover: #ff8c6c;
  --bg-page: #1a1d27;
  --bg-glow: #232838;
  --bg-panel: #20242f;
  --bg-ticket: #262b38;
  --line-ticket: #333947;
  --button-ink: #1a1d27;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  margin: 0;
  padding: 42px 20px 64px;
  background: radial-gradient(circle at 10% 10%, var(--bg-glow) 0, transparent 30%), var(--bg-page);
  transition: background 200ms ease, color 200ms ease;
}

main {
  width: min(100%, 940px);
  margin: 0 auto;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.3rem, 7vw, 5rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.description {
  max-width: 300px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  text-align: right;
}

.panel {
  padding: 24px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(91, 72, 42, 0.08);
  transition: background 200ms ease, border-color 200ms ease;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#themeToggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--ink);
  font-size: 1.2rem;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

#themeToggle:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

#themeToggle:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

h2 {
  margin: 0;
  font-size: 1.1rem;
}

#drawButton {
  padding: 12px 18px;
  color: var(--button-ink);
  font: inherit;
  font-weight: 700;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

#drawButton:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

#drawButton:focus-visible {
  outline: 3px solid #f3b36b;
  outline-offset: 3px;
}

.results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.ticket {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 10px;
  animation: reveal 420ms both;
  transition: background 200ms ease, border-color 200ms ease;
}

.ticket:last-child {
  grid-column: 1 / -1;
}

.ticket.confirmed {
  border-color: var(--accent);
}

.ticket-top {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 14px;
}

.ticket-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.ticket.confirmed .ticket-label {
  color: var(--accent);
}

.ticket-confirm {
  align-self: flex-start;
  padding: 6px 12px;
  color: var(--muted);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  background: var(--bg-panel);
  border: 1px solid var(--line-ticket);
  border-radius: 6px;
  cursor: pointer;
  transition: all 160ms ease;
}

.ticket-confirm:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.ticket.confirmed .ticket-confirm {
  color: var(--button-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.ticket.confirmed .ticket-confirm:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--button-ink);
}

.balls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ball {
  display: grid;
  place-items: center;
  width: 36px;
  aspect-ratio: 1;
  color: #fff;
  font-size: 0.84rem;
  font-weight: 700;
  border-radius: 50%;
}

.ball.yellow { background: #e4ad32; }
.ball.blue { background: #4b83c5; }
.ball.red { background: #db5b52; }
.ball.gray { background: #89919c; }
.ball.green { background: #4d9b72; }

.plus {
  color: #a49a8b;
  font-size: 1rem;
  font-weight: 700;
}

.bonus-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.draw-info {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.contact-panel {
  margin-top: 24px;
}

.intro-panel {
  padding: 18px 24px;
}

.intro-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.intro-text strong {
  color: var(--ink);
}

.draw-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Segmented pair: one pill, a divider between the halves, no doubled border. */
.game-count {
  display: flex;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 8px;
  overflow: hidden;
}

.game-count-option {
  padding: 8px 12px;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  background: none;
  border: 0;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease;
}

.game-count-option + .game-count-option {
  border-left: 1px solid var(--line-ticket);
}

.game-count-option:hover:not(.selected) {
  color: var(--ink);
}

.game-count-option.selected {
  color: var(--button-ink);
  background: var(--accent);
}

.panel-note {
  margin: 14px 0 0;
  padding-top: 14px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
  border-top: 1px dashed var(--line);
}

.policy-panel {
  line-height: 1.75;
}

.policy-panel h3 {
  margin: 24px 0 8px;
  font-size: 1rem;
}

.policy-panel h3:first-of-type {
  margin-top: 8px;
}

.policy-panel p,
.policy-panel ul {
  margin: 0 0 10px;
  color: var(--muted);
}

.policy-panel ul {
  padding-left: 20px;
}

.policy-panel a {
  color: var(--accent);
}

.policy-updated {
  margin-top: 24px;
  font-size: 0.82rem;
}

.policy-back {
  margin-top: 8px;
}

.site-footer {
  margin-top: 32px;
  padding-top: 24px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  border-top: 1px solid var(--line);
}

.footer-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin: 12px 0;
}

.footer-nav a {
  color: var(--muted);
  text-decoration: underline;
}

.footer-nav a:hover,
.footer-nav a:focus-visible {
  color: var(--accent);
}

.footer-copyright {
  margin: 0;
}

.ad-slot {
  margin: 24px 0;
  padding: 16px;
  text-align: center;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: background 200ms ease, border-color 200ms ease;
}

.ad-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.contact-intro {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.6;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.field input,
.field textarea {
  padding: 12px 14px;
  color: var(--ink);
  font: inherit;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 8px;
  transition: border-color 160ms ease, background 200ms ease;
}

.field textarea {
  min-height: 84px;
  resize: vertical;
  font-family: inherit;
}

.field textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.field input:focus-visible,
.field textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

#contactSubmit {
  margin-top: 18px;
  padding: 12px 18px;
  color: var(--button-ink);
  font: inherit;
  font-weight: 700;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

#contactSubmit:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

#contactSubmit:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.contact-status {
  margin: 14px 0 0;
  font-size: 0.88rem;
}

.contact-status.success { color: #4d9b72; }
.contact-status.error { color: #db5b52; }

.checker-panel {
  margin-top: 24px;
}

.checker-round-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

#checkerPrev,
#checkerNext,
#checkerLatest {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--ink);
  font-size: 1rem;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease;
}

#checkerPrev:hover:not(:disabled),
#checkerNext:hover:not(:disabled),
#checkerLatest:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-2px);
}

#checkerPrev:disabled,
#checkerNext:disabled,
#checkerLatest:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  transform: none;
}

/* Wider than the arrow squares because it carries a word, not a chevron. */
#checkerLatest {
  width: auto;
  padding: 0 12px;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
}

#checkerRoundInput {
  width: 60px;
  padding: 0;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-align: right;
  background: none;
  border: 0;
}

#checkerRoundInput:focus-visible {
  outline: none;
}

.checker-round-field {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 8px;
  transition: border-color 160ms ease;
}

.checker-round-field:focus-within {
  border-color: var(--accent);
}

.checker-round-unit {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.checker-draw {
  margin-top: 20px;
  animation: reveal 420ms both;
}

.checker-draw-info {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.checker-no-entry {
  margin: 20px 0 0;
  padding: 18px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
  text-align: center;
  background: var(--bg-ticket);
  border: 1px dashed var(--line-ticket);
  border-radius: 10px;
}

.checker-compare {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px dashed var(--line);
  animation: reveal 420ms both;
}

.checker-compare-title {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.checker-compare-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checker-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 10px;
}

.checker-row.confirmed {
  border-color: var(--accent);
}

.checker-row-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.checker-row.confirmed .checker-row-label {
  color: var(--accent);
}

.checker-rank {
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  text-align: right;
}

.checker-rank.hit { color: var(--accent); }
.checker-rank.miss { color: var(--muted); font-weight: 400; }

.ball.matched {
  box-shadow: 0 0 0 3px var(--accent);
}

.stats-summary-panel {
  padding: 18px 24px;
}

.stats-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.stats-summary strong {
  color: var(--ink);
}

.stats-panel {
  margin-top: 24px;
}

.checker-go-pending {
  margin-top: 12px;
}

.record-panel {
  margin-top: 24px;
}

.record-ranks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.record-rank {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 999px;
}

.record-rank.hit {
  border-color: var(--accent);
}

.record-rank-name {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
}

.record-rank.hit .record-rank-name {
  color: var(--accent);
}

.record-rank-count {
  color: var(--muted);
  font-size: 0.8rem;
}

/* The single number that turned five matches into a 2등. Dashed so it reads as
   a different kind of hit than the six solid matched balls beside it. */
.ball.bonus-hit {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

.dist-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.dist-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  align-items: center;
  gap: 12px;
}

.dist-label {
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
}

.dist-track {
  height: 10px;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 999px;
  overflow: hidden;
}

.dist-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.dist-value {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.figure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.figure {
  padding: 16px;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 10px;
}

.figure-value {
  margin: 0;
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 700;
}

.figure-label {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.prose {
  margin-top: 24px;
}

.prose p:not(.panel-note) {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.prose > p:first-of-type {
  margin-top: 18px;
}

.prose h3 {
  margin: 26px 0 0;
  color: var(--ink);
  font-size: 0.95rem;
}

.prose strong {
  color: var(--ink);
  font-weight: 700;
}

.prose .panel-note {
  margin-top: 26px;
}

.stats-intro {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.table-toggle {
  padding: 8px 14px;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 8px;
  cursor: pointer;
  transition: all 160ms ease;
}

.table-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.chart-scroll {
  margin-top: 20px;
  overflow-x: auto;
}

.chart-wrap {
  position: relative;
  min-width: 620px;
}

#freqChart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-bar {
  fill: var(--accent);
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-baseline {
  stroke: var(--muted);
  stroke-width: 1;
}

.chart-average {
  stroke: var(--ink);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  opacity: 0.55;
}

.chart-average-label,
.chart-axis-label {
  fill: var(--muted);
  font-family: inherit;
  font-size: 12px;
}

.chart-average-label {
  font-weight: 700;
}

/* Backing plate so the average label stays readable where it crosses bars. */
.chart-average-label-bg {
  fill: var(--bg-panel);
}

.chart-hit {
  fill: transparent;
  cursor: pointer;
}

.chart-hit:hover {
  fill: var(--ink);
  fill-opacity: 0.06;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  padding: 8px 12px;
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: nowrap;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transform: translate(-50%, calc(-100% - 10px));
  pointer-events: none;
}

.chart-tooltip-sub {
  color: var(--muted);
}

.stats-table-wrap {
  max-height: 360px;
  margin-top: 20px;
  overflow: auto;
  border: 1px solid var(--line-ticket);
  border-radius: 10px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.stats-table th,
.stats-table td {
  padding: 10px 14px;
  text-align: right;
  border-bottom: 1px solid var(--line-ticket);
}

.stats-table thead th {
  position: sticky;
  top: 0;
  color: var(--muted);
  font-size: 0.78rem;
  background: var(--bg-ticket);
}

.stats-table tbody th {
  color: var(--ink);
  font-weight: 700;
  text-align: left;
}

.stats-table tbody td {
  color: var(--muted);
}

.stats-table tbody tr:last-child th,
.stats-table tbody tr:last-child td {
  border-bottom: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.stats-card {
  padding: 16px;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 10px;
}

.stats-card-title {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.82rem;
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stats-panel > .stats-list {
  margin-top: 4px;
}

.stats-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stats-list-text {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.tax-panel {
  margin-top: 24px;
}

.tax-intro {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.tax-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

#taxAmount {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  color: var(--ink);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: right;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 8px;
  transition: border-color 160ms ease;
}

#taxAmount:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.tax-unit {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
}

.tax-amount-words {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: right;
}

.tax-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.tax-preset {
  padding: 8px 12px;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 999px;
  cursor: pointer;
  transition: all 160ms ease;
}

.tax-preset:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.tax-result {
  margin-top: 20px;
  padding: 18px;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 10px;
  animation: reveal 420ms both;
}

.tax-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}

.tax-row-label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.tax-row-label small {
  font-size: 0.76rem;
  font-weight: 400;
}

.tax-row-value {
  font-size: 0.95rem;
  font-weight: 700;
  text-align: right;
}

.tax-row-value.minus {
  color: #db5b52;
}

.tax-row.total {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.tax-row.total .tax-row-label {
  color: var(--ink);
  font-size: 0.95rem;
}

.tax-row.total .tax-row-value {
  color: var(--accent);
  font-size: 1.35rem;
}

.menu-panel {
  margin-top: 24px;
}

.menu-intro {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.6;
}

.wheel-wrap {
  position: relative;
  width: min(100%, 340px);
  margin: 0 auto;
}

.wheel {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 50%;
  filter: drop-shadow(0 10px 24px rgba(91, 72, 42, 0.18));
}

.wheel-slice {
  stroke: #fffdf9;
  stroke-width: 2;
}

.wheel-label {
  fill: #202a3b;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
}

.wheel-hub {
  fill: var(--bg-panel);
  stroke: var(--line);
  stroke-width: 2;
}

/* 12시 방향에서 판을 가리키는 바늘. 판만 돌고 바늘은 고정된다. */
.wheel-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-top: 24px solid var(--accent);
  transform: translateX(-50%);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
  z-index: 1;
}

.wheel-actions {
  display: flex;
  justify-content: center;
  margin-top: 22px;
}

.spin-button {
  padding: 13px 30px;
  color: var(--button-ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.spin-button:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

.spin-button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.menu-result {
  margin-top: 20px;
  padding-top: 20px;
  text-align: center;
  border-top: 1px dashed var(--line);
}

.menu-result-text {
  margin: 0;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 700;
}

.share-button {
  margin-top: 20px;
  padding: 12px 18px;
  color: var(--button-ink);
  font: inherit;
  font-weight: 700;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.share-button:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}


@media (max-width: 520px) {
  body {
    padding: 28px 14px 40px;
  }

  .hero,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .draw-controls {
    width: 100%;
    justify-content: space-between;
  }

  .description {
    text-align: left;
  }

  .panel {
    padding: 18px;
  }

  .results {
    grid-template-columns: 1fr;
  }

  .ticket:last-child {
    grid-column: auto;
  }

  #drawButton {
    width: 100%;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  #contactSubmit {
    width: 100%;
  }

  .spin-button {
    width: 100%;
  }

  .checker-round-controls {
    width: 100%;
  }

  .checker-round-field {
    flex: 1;
    justify-content: center;
  }

  .checker-row {
    grid-template-columns: 1fr;
    justify-items: start;
    gap: 8px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  /* Three columns will not fit a phone, so the bar drops to its own row under
     the label and the figures it describes. */
  .dist-row {
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
  }

  .dist-label {
    grid-column: 1;
    grid-row: 1;
  }

  .dist-value {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
  }

  .dist-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .table-toggle {
    width: 100%;
  }

  .checker-rank {
    text-align: left;
  }
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Touch devices need roughly 44px of finger-sized target; a mouse does not, so
   this widens controls only where a coarse pointer is actually in use. */
@media (pointer: coarse) {
  .ticket-confirm,
  .tax-preset,
  .table-toggle,
  .share-button,
  .spin-button,
  #drawButton,
  #contactSubmit,
  .game-count-option {
    min-height: 44px;
  }

  #checkerPrev,
  #checkerNext {
    width: 44px;
    height: 44px;
  }

  #checkerLatest {
    height: 44px;
  }

  /* Centre the field so the number input can fill its full height, making the
     whole box tappable rather than just the 18px of text. */
  .checker-round-field {
    align-items: center;
    padding-top: 0;
    padding-bottom: 0;
  }

  #checkerRoundInput {
    min-height: 44px;
  }

  .footer-nav {
    gap: 4px 16px;
  }

  .footer-nav a {
    display: inline-block;
    padding: 13px 4px;
  }
}

/* Celebration ------------------------------------------------------------- */

.celebration {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  padding: 22px 18px;
  text-align: center;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 14px;
}

.celebration-emoji {
  display: block;
  font-size: 2.4rem;
  line-height: 1;
}

.celebration-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--rank-ink, var(--ink));
}

.celebration-text {
  margin: 0;
  max-width: 34ch;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Each rank gets its own accent and its own entrance motion. */
.celebration.rank-1 { --rank: #d19a00; --rank-ink: #b07f00; --rank-rgb: 255, 201, 60; }
.celebration.rank-2 { --rank: #8d97a8; --rank-ink: #6d7787; --rank-rgb: 160, 172, 190; }
.celebration.rank-3 { --rank: #c07f4a; --rank-ink: #a2673a; --rank-rgb: 208, 145, 96; }
.celebration.rank-4 { --rank: #3f9fbf; --rank-ink: #2f89a8; --rank-rgb: 76, 179, 212; }
.celebration.rank-5 { --rank: #5aa74c; --rank-ink: #4a9440; --rank-rgb: 123, 200, 108; }

:root[data-theme="dark"] .celebration.rank-1 { --rank: #ffd75e; --rank-ink: #ffd75e; }
:root[data-theme="dark"] .celebration.rank-2 { --rank: #c4ccd8; --rank-ink: #c4ccd8; }
:root[data-theme="dark"] .celebration.rank-3 { --rank: #e0a473; --rank-ink: #e0a473; }
:root[data-theme="dark"] .celebration.rank-4 { --rank: #6fc8e4; --rank-ink: #6fc8e4; }
:root[data-theme="dark"] .celebration.rank-5 { --rank: #96d888; --rank-ink: #96d888; }

.celebration.rank-1,
.celebration.rank-2,
.celebration.rank-3,
.celebration.rank-4,
.celebration.rank-5 {
  border-color: var(--rank);
  background:
    linear-gradient(160deg, rgba(var(--rank-rgb), 0.2), transparent 68%),
    var(--bg-ticket);
}

.celebration.rank-1 {
  animation:
    celebrate-jackpot 900ms cubic-bezier(0.2, 0.9, 0.25, 1.2) both,
    rank-glow 1.8s ease-in-out 900ms infinite;
}

.celebration.rank-2 {
  animation:
    celebrate-burst 760ms cubic-bezier(0.2, 0.9, 0.25, 1.15) both,
    rank-glow 2.4s ease-in-out 760ms infinite;
}

.celebration.rank-3 { animation: celebrate-sparkle 760ms ease-out both; }
.celebration.rank-4 { animation: celebrate-bounce 720ms cubic-bezier(0.3, 0.8, 0.4, 1) both; }
.celebration.rank-5 { animation: celebrate-pop 560ms cubic-bezier(0.2, 0.9, 0.3, 1.15) both; }

.celebration.rank-miss {
  animation: celebrate-sigh 1s ease-out both;
  border-style: dashed;
}

.celebration.rank-1 .celebration-emoji { animation: emoji-cheer 1.4s ease-in-out 800ms infinite; }
.celebration.rank-2 .celebration-emoji { animation: emoji-cheer 2s ease-in-out 800ms infinite; }
.celebration.rank-3 .celebration-emoji { animation: emoji-twinkle 1.8s ease-in-out 700ms infinite; }
.celebration.rank-4 .celebration-emoji { animation: emoji-hop 1.6s ease-in-out 700ms infinite; }
.celebration.rank-5 .celebration-emoji { animation: emoji-sway 2.6s ease-in-out 600ms infinite; }
.celebration.rank-miss .celebration-emoji { animation: emoji-droop 2.6s ease-in-out infinite; }

/* Rows replay a lighter version of the same motion, one after another. */
.checker-row.rank-1 { animation: row-jackpot 760ms cubic-bezier(0.2, 0.9, 0.25, 1.2) var(--row-delay, 0ms) both; }
.checker-row.rank-2 { animation: celebrate-burst 700ms cubic-bezier(0.2, 0.9, 0.25, 1.15) var(--row-delay, 0ms) both; }
.checker-row.rank-3 { animation: celebrate-sparkle 700ms ease-out var(--row-delay, 0ms) both; }
.checker-row.rank-4 { animation: celebrate-bounce 660ms cubic-bezier(0.3, 0.8, 0.4, 1) var(--row-delay, 0ms) both; }
.checker-row.rank-5 { animation: celebrate-pop 520ms cubic-bezier(0.2, 0.9, 0.3, 1.15) var(--row-delay, 0ms) both; }
.checker-row.rank-miss { animation: celebrate-sigh 900ms ease-out var(--row-delay, 0ms) both; }

.checker-row.rank-1 { border-color: #d19a00; box-shadow: 0 0 0 1px #d19a00 inset; }
.checker-row.rank-2 { border-color: #8d97a8; }
.checker-row.rank-3 { border-color: #c07f4a; }
.checker-row.rank-4 { border-color: #3f9fbf; }
.checker-row.rank-5 { border-color: #5aa74c; }

:root[data-theme="dark"] .checker-row.rank-1 { border-color: #ffd75e; box-shadow: 0 0 0 1px #ffd75e inset; }
:root[data-theme="dark"] .checker-row.rank-2 { border-color: #c4ccd8; }
:root[data-theme="dark"] .checker-row.rank-3 { border-color: #e0a473; }
:root[data-theme="dark"] .checker-row.rank-4 { border-color: #6fc8e4; }
:root[data-theme="dark"] .checker-row.rank-5 { border-color: #96d888; }

@keyframes celebrate-jackpot {
  0% { opacity: 0; transform: scale(0.32) rotate(-14deg); }
  40% { opacity: 1; transform: scale(1.16) rotate(7deg); }
  60% { transform: scale(0.95) rotate(-4deg); }
  80% { transform: scale(1.05) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes row-jackpot {
  0% { opacity: 0; transform: scale(0.9) rotate(-2deg); }
  45% { opacity: 1; transform: scale(1.04) rotate(1.2deg); }
  70% { transform: scale(0.99) rotate(-0.6deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes celebrate-burst {
  0% { opacity: 0; transform: scale(0.6); }
  45% { opacity: 1; transform: scale(1.1); }
  60% { transform: scale(1) translateX(-7px); }
  73% { transform: translateX(7px); }
  86% { transform: translateX(-3px); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes celebrate-sparkle {
  0% { opacity: 0; transform: translateY(14px) scale(0.94); filter: brightness(1); }
  40% { opacity: 1; transform: translateY(-5px) scale(1.03); filter: brightness(1.4); }
  60% { filter: brightness(1); }
  76% { filter: brightness(1.25); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: brightness(1); }
}

@keyframes celebrate-bounce {
  0% { opacity: 0; transform: translateY(-24px); }
  45% { opacity: 1; transform: translateY(0); }
  60% { transform: translateY(-11px); }
  76% { transform: translateY(0); }
  88% { transform: translateY(-4px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes celebrate-pop {
  0% { opacity: 0; transform: scale(0.86); }
  55% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}

/* A little side-to-side "aw..." that settles a touch lower than it started. */
@keyframes celebrate-sigh {
  0% { opacity: 0; transform: translateY(-6px); }
  30% { opacity: 1; transform: translateX(-6px); }
  45% { transform: translateX(6px); }
  60% { transform: translateX(-3px); }
  74% { transform: translateX(0); }
  100% { opacity: 1; transform: translateY(4px); }
}

@keyframes rank-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--rank-rgb), 0); }
  50% { box-shadow: 0 0 26px 3px rgba(var(--rank-rgb), 0.5); }
}

@keyframes emoji-cheer {
  0%, 100% { transform: rotate(-10deg) scale(1); }
  50% { transform: rotate(10deg) scale(1.16); }
}

@keyframes emoji-twinkle {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.12); filter: brightness(1.35); }
}

@keyframes emoji-hop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

@keyframes emoji-sway {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}

@keyframes emoji-droop {
  0%, 100% { transform: rotate(0) translateY(0); }
  50% { transform: rotate(-9deg) translateY(4px); }
}

/* Confetti ---------------------------------------------------------------- */

.effect-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 60;
}

.confetti {
  position: absolute;
  top: -28px;
  width: 9px;
  border-radius: 2px;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.confetti.emoji {
  width: auto;
  background: none;
  font-size: 1.3rem;
  line-height: 1;
}

@keyframes confetti-fall {
  0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0); }
  100% { opacity: 0; transform: translate3d(var(--drift, 0), 108vh, 0) rotate(var(--spin, 360deg)); }
}

@media (prefers-reduced-motion: reduce) {
  .celebration,
  .celebration-emoji,
  .checker-row[class*="rank-"],
  .confetti {
    animation: none;
  }
}
