:root {
  color-scheme: light;
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', system-ui, sans-serif;
  color: #2b352e;
  background: #edf6fc;
  --paper: #fffdf6;
  --line: #d9cdb3;
  --muted: #5e6862;
  --orange: #f6b055;
  --orange-edge: #b86523;
  --green: #376e4d;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; line-height: 1.55; }
h1, h2, p { margin: 0; }
button, input { font: inherit; }
a { color: #245977; text-underline-offset: .22em; }
:focus-visible { outline: 2px solid #236689; outline-offset: 3px; }

.top { background: #d3eaf9; border-bottom: 2px solid #a6cbe1; }
.top-inner, .shell { width: min(880px, calc(100% - 32px)); margin-inline: auto; }
.top-inner { min-height: 62px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 9px; color: #254453; font-size: 1.05rem; font-weight: 800; }
.mark {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: #ffbd64; color: #573511; font: 900 1rem/1 system-ui;
  box-shadow: inset 0 3px #ffe4a7, inset 0 -3px #db8d46;
  clip-path: polygon(0 20%, 10% 20%, 10% 10%, 20% 10%, 20% 0, 80% 0, 80% 10%, 90% 10%, 90% 20%, 100% 20%, 100% 80%, 90% 80%, 90% 90%, 80% 90%, 80% 100%, 20% 100%, 20% 90%, 10% 90%, 10% 80%, 0 80%);
}
.page-label { color: #32596a; font-size: .875rem; font-weight: 700; }
.shell { display: grid; gap: 14px; margin-block: 26px 48px; }
.participant { max-width: 610px; }

.hero { display: grid; gap: 8px; justify-items: start; padding: 2px 0 5px; }
.hero h1 { font-size: clamp(1.85rem, 6vw, 2.65rem); line-height: 1.2; letter-spacing: -.06em; }
.intro { color: var(--muted); word-break: keep-all; }
.status {
  display: inline-block; border: 1px solid #90b5ca; border-radius: 5px; padding: 2px 8px;
  background: #e3f1fa; color: #365669; font-size: .875rem; font-weight: 700;
}
.status[data-phase='open'], .status[data-phase='drawn'] { color: #254e37; border-color: #9abf9f; background: #e2f0df; }
.status[data-phase='closed'] { color: #75481c; border-color: #d6ae78; background: #fff0d3; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 2px #e7dbc1; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 12px 0; }
.metrics div { min-width: 0; padding: 0 clamp(9px, 3vw, 18px); }
.metrics div + div { border-left: 1px solid var(--line); }
.metrics span, .metrics strong { display: block; }
.metrics span { color: var(--muted); font-size: .875rem; }
.metrics strong { font-size: 1.15rem; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.panel { padding: clamp(15px, 4vw, 22px); min-width: 0; }
h2 { font-size: 1.2rem; letter-spacing: -.035em; }
.muted { color: var(--muted); margin-top: 5px; }
.muted:empty { display: none; }
.dashboard-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 14px; }

form { display: grid; gap: 8px; margin-top: 14px; }
label { display: block; font-size: .9375rem; font-weight: 700; }
input { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #bfb8a2; border-radius: 5px; background: #fff; color: inherit; }
input::placeholder { color: #6b726b; }
input:disabled { color: #586054; background: #f0eee4; }
#join-form label:not(:first-child) { margin-top: 4px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fields label { margin-bottom: 5px; }
.hint { margin: 0; font-size: .875rem; }
.actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 3px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 7px 12px; border: 1px solid #b0b8a7; border-radius: 6px;
  background: #edf2e7; color: #314738; cursor: pointer; font-weight: 800;
  box-shadow: inset 0 -2px #d5dfce;
}
.button:hover:not(:disabled) { background: #e1ebdb; }
.primary, #close:not(:disabled), #draw:not(:disabled) {
  border-color: var(--orange-edge); background: var(--orange); color: #482b13;
  box-shadow: inset 0 2px #ffddaa, inset 0 -3px #da883e;
}
.primary:hover:not(:disabled), #close:hover:not(:disabled), #draw:hover:not(:disabled) { background: #ffc372; }
.button:active:not(:disabled) { box-shadow: inset 0 2px #61391d30; }
.button:disabled { background: #f1f0e9; color: #697168; border-color: #d3d0c3; box-shadow: none; cursor: default; }

.numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(42px, 1fr)); gap: 5px; margin: 2px 0 4px; }
.number-button {
  min-height: 44px; border: 1px solid #c3b99e; border-radius: 5px;
  background: #f8f2df; color: #453821; cursor: pointer; font-weight: 800;
  font-variant-numeric: tabular-nums; box-shadow: inset 0 -2px #e5d8ba;
}
.number-button:hover { background: #f6e9c6; }
.number-button[aria-pressed='true'] { background: #ffce83; border-color: var(--orange-edge); box-shadow: inset 0 -2px #e2a253; }

.notice { padding: 8px 10px; border-radius: 5px; background: #ffeadf; color: #7e362a; font-size: .9375rem; }
#share-message { margin-top: 9px; background: #e8f2e5; color: #34543d; }
.share-links { padding: 0; margin: 12px 0 8px; list-style: none; display: grid; gap: 6px; }
.share-links li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.share-links a { overflow-wrap: anywhere; font-family: ui-monospace, monospace; font-size: .875rem; }
.copy { min-height: 36px; padding: 4px 9px; flex: none; font-size: .875rem; }
.local-link { font-size: .9rem; }

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin-top: 10px; text-align: left; }
th, td { padding: 8px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
th { color: var(--muted); font-size: .875rem; }
tbody tr:last-child td { border-bottom: 0; }
.tabular { font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 2px 7px; border-radius: 4px; background: #ecebe2; color: #4e5449; font-size: .875rem; font-weight: 700; }
.tag.winner, .winner-number { background: #e1efd8; color: #28523a; }
.tag.duplicate { background: #f8e4dd; color: #813f34; }
.winning-panel { border-color: #8bb181; }
.winning-panel h2 { color: var(--green); }
.winners { display: grid; gap: 6px; padding: 0; margin: 10px 0 0; list-style: none; }
.winners:empty { display: none; }
.winners li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 5px; background: #f0f1e5; overflow-wrap: anywhere; }
.winner-number { min-width: 34px; padding: 2px 6px; border-radius: 4px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }

.confirmed-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.confirmed-list li { min-width: 0; max-width: 100%; padding: 3px 8px; border-radius: 4px; background: #edf2e7; color: #314738; overflow-wrap: anywhere; }

@media (max-width: 680px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .shell { margin-top: 19px; }
  .numbers { grid-template-columns: repeat(auto-fit, minmax(39px, 1fr)); }
}



.reveal-dialog {
  width: min(760px, calc(100% - 20px));
  max-width: none;
  max-height: calc(100dvh - 20px);
  padding: 0;
  overflow: auto;
  border: 2px solid #638192;
  border-radius: 12px;
  background: #182e3c;
  color: #f6f9ff;
  box-shadow: 0 15px 45px #07172477;
}
.reveal-dialog::backdrop { background: #0c202ad9; }
.reveal-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid #405b69; }
.reveal-heading { font-size: 1rem; }
.reveal-hide { min-height: 40px; padding: 5px 9px; border: 1px solid #66818d; border-radius: 5px; color: #eef7fa; background: transparent; cursor: pointer; font-size: .875rem; }
.reveal-hide:hover, .reveal-hide:focus-visible { background: #2f4e5f; outline-color: #b7e2fb; }
.reveal-field {
  position: relative; isolation: isolate; overflow: hidden;
  height: clamp(196px, 58dvh, 500px);
  background: radial-gradient(ellipse at center, #315769 0%, #1c3848 47%, #192e3e 100%);
}
.reveal-field[data-effect='winner'] {
  background: radial-gradient(ellipse at center, #6c6346, #2f4f4e 52%, #192e3e);
}
.reveal-center { position: absolute; inset: 0; display: grid; place-items: center; }
.reveal-number {
  position: relative; display: grid; place-items: center; width: max-content; max-width: 94%;
  font: 900 clamp(4rem, 20vw, 10rem)/.95 system-ui, sans-serif; font-variant-numeric: tabular-nums;
  letter-spacing: -.08em; color: #fff6d3; text-shadow: 0 .055em #b86f33, 0 .085em #402a22;
  animation: reveal-slam calc(.22s / var(--playback-speed, 1)) cubic-bezier(.12,.8,.23,1.23) both;
}
.reveal-number.compact { font-size: clamp(2.55rem, 11vw, 6rem); }
.reveal-number.wide { font-size: clamp(1.5rem, 5.7vw, 3rem); letter-spacing: -.05em; }
.reveal-number[data-effect='winner'] { color: #ffe886; text-shadow: 0 .055em #a9612d, 0 0 .27em #ffd77599; animation: reveal-win calc(.75s / var(--playback-speed, 1)) ease-out both; }
.reveal-number[data-effect='outside'] { color: #cfdae2; text-shadow: 0 .055em #50677a; }
.reveal-half { position: absolute; inset: 0; display: none; }
.reveal-number[data-effect='break'] .reveal-value { visibility: hidden; }
.reveal-number[data-effect='break'] .reveal-half { display: block; }
.reveal-half.left { clip-path: polygon(0 0, 61% 0, 46% 34%, 60% 49%, 42% 71%, 46% 100%, 0 100%); --break-x: -42px; --break-angle: -23deg; }
.reveal-half.right { clip-path: polygon(61% 0, 100% 0, 100% 100%, 46% 100%, 42% 71%, 60% 49%, 46% 34%); --break-x: 46px; --break-angle: 26deg; }
.reveal-number[data-effect='break'] .reveal-half { animation: reveal-break calc(.43s / var(--playback-speed, 1)) cubic-bezier(.12,.63,.42,1) forwards; }
.reveal-chips, .reveal-particles { position: absolute; inset: 0; pointer-events: none; }
.reveal-chip {
  position: absolute; top: var(--y); left: var(--x);
  max-width: 40%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  padding: 5px 10px; border: 1px solid #7daab8; border-radius: 5px;
  background: #eef8f5; color: #224455; font-weight: 800;
  box-shadow: 0 3px #0d2433aa;
  transform: translate(-50%, -50%) rotate(var(--tilt));
  animation: reveal-chip-in calc(.24s / var(--playback-speed, 1)) cubic-bezier(.16,.8,.27,1.18) both;
}
.reveal-field[data-effect='winner'] .reveal-chip { background: #ffe89a; border-color: #dfac54; color: #51381c; }
.reveal-field[data-effect='break'] .reveal-chip { background: #f7dfd9; border-color: #ba8378; color: #703b33; }
.reveal-particle {
  position: absolute; top: 50%; left: 50%; width: 7px; height: 9px;
  opacity: 0; background: var(--color);
  animation: reveal-particle-out calc(.46s / var(--playback-speed, 1)) ease-out both;
}
.reveal-field[data-effect='winner'] .reveal-particle { animation-duration: calc(1.2s / var(--playback-speed, 1)); }
.reveal-caption {
  display: grid; place-items: center; min-height: 52px; padding: 7px 12px;
  text-align: center; font-size: clamp(1rem, 3.5vw, 1.3rem); font-weight: 800;
}
.reveal-field[data-effect='winner'] + .reveal-caption { color: #ffe890; }
.reveal-progress { display: block; width: 100%; height: 5px; border: 0; border-radius: 0; appearance: none; background: #365465; }
.reveal-progress::-webkit-progress-bar { background: #365465; }
.reveal-progress::-webkit-progress-value { background: #f2ba68; }
.reveal-progress::-moz-progress-bar { background: #f2ba68; }

@keyframes reveal-slam {
  from { opacity: .25; transform: translateY(-14px) scale(1.36); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes reveal-chip-in {
  from { opacity: 0; transform: translate(-50%, -50%) rotate(var(--tilt)) scale(1.5); }
  to { opacity: 1; transform: translate(-50%, -50%) rotate(var(--tilt)) scale(1); }
}
@keyframes reveal-break {
  0% { opacity: 1; transform: translate(0, 0); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--break-x), 26px) rotate(var(--break-angle)); }
}
@keyframes reveal-win {
  0%, 100% { transform: scale(1); }
  36% { transform: scale(1.14); }
}
@keyframes reveal-particle-out {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  65% { opacity: .9; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--spin)); }
}

@media (prefers-reduced-motion: reduce) {
  .reveal-number, .reveal-chip, .reveal-number[data-effect='winner'], .reveal-number[data-effect='break'] .reveal-half { animation: none; }
  .reveal-number[data-effect='break'] .reveal-half { visibility: hidden; }
  .reveal-particles { display: none; }
}


.fields select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid #bfb8a2;
  border-radius: 5px;
  background: #fff;
  color: inherit;
  font: inherit;
}
.fields select:disabled { color: #586054; background: #f0eee4; }
.number-entry { display: flex; gap: 7px; }
.number-entry input { min-width: 0; }
.number-entry .button { flex: none; }
.selected-numbers, .pick-results {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.selected-number {
  min-height: 36px;
  padding: 4px 9px;
  border: 1px solid var(--orange-edge);
  border-radius: 5px;
  background: #ffce83;
  color: #482b13;
  cursor: pointer;
}
.pick-results { margin-top: 10px; }
.pick-results li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
}
.reveal-tools { display: flex; align-items: center; gap: 6px; }
.reveal-rate {
  min-height: 40px;
  padding: 4px 5px;
  border: 1px solid #66818d;
  border-radius: 5px;
  background: #203d4d;
  color: #eef7fa;
  font: inherit;
}
.reveal-error { margin: 8px; }
