@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:ital,wght@1,700&display=swap');

:root {
  --ink: #14261f;
  --forest: #173f32;
  --cream: #f2eddf;
  --paper: #fbf8f0;
  --red: #d84a3a;
  --gold: #d7a83f;
  --line: rgba(20, 38, 31, .18);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--cream); font-family: "DM Sans", sans-serif; }
button, select { font: inherit; }
button, select, input { color: inherit; }

.site-header { height: 76px; padding: 0 clamp(22px, 5vw, 76px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.brand { color: var(--ink); text-decoration: none; text-transform: uppercase; letter-spacing: .12em; font-size: 13px; font-weight: 700; }
.brand span { color: var(--red); }
.rules-link { color: var(--ink); text-underline-offset: 5px; font-size: 13px; font-weight: 600; }

main { overflow: hidden; }
.hero { max-width: 1420px; margin: 0 auto; padding: clamp(64px, 9vw, 120px) clamp(22px, 7vw, 100px) clamp(50px, 7vw, 90px); position: relative; }
.hero::after { content: "♣"; position: absolute; right: 8%; top: 12%; color: rgba(23, 63, 50, .07); font-family: Georgia, serif; font-size: clamp(190px, 25vw, 370px); line-height: 1; transform: rotate(9deg); }
.eyebrow { margin: 0 0 18px; color: var(--red); text-transform: uppercase; letter-spacing: .18em; font-size: 11px; font-weight: 700; }
h1 { position: relative; z-index: 1; max-width: 850px; margin: 0; font-size: clamp(54px, 9vw, 126px); line-height: .84; letter-spacing: -.065em; font-weight: 600; }
h1 em { color: var(--red); font-family: "Playfair Display", Georgia, serif; font-weight: 700; }
.intro { position: relative; z-index: 1; max-width: 500px; margin: 36px 0 0; font-size: clamp(16px, 2vw, 20px); line-height: 1.55; }

.calculator { max-width: 1280px; margin: 0 auto clamp(90px, 12vw, 170px); display: grid; grid-template-columns: 1.08fr .92fr; box-shadow: 0 30px 80px rgba(23, 39, 32, .13); }
.setup-panel, .result-panel { padding: clamp(28px, 5vw, 70px); }
.setup-panel { background: var(--paper); }
.result-panel { min-height: 650px; color: var(--paper); background: var(--forest); display: flex; flex-direction: column; }
.section-heading { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 46px; }
.section-heading > span { width: 32px; padding-top: 4px; border-top: 2px solid var(--red); font-size: 11px; font-weight: 700; }
.section-heading .eyebrow { margin-bottom: 5px; }
h2 { margin: 0; font-size: clamp(27px, 3vw, 42px); line-height: 1.08; letter-spacing: -.04em; }
.light > span { border-color: var(--gold); }
.light .eyebrow { color: var(--gold); }
.light h2 { font-size: clamp(24px, 2.7vw, 35px); }

fieldset { min-width: 0; margin: 0 0 38px; padding: 0; border: 0; }
legend, .field label, .rank-fields label { display: block; margin-bottom: 12px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
legend small { margin-left: 5px; color: rgba(20, 38, 31, .55); text-transform: none; letter-spacing: 0; font-weight: 500; }
.player-options { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line); }
.player-options input { position: absolute; opacity: 0; pointer-events: none; }
.player-options label { min-width: 0; padding: 13px 5px; border-right: 1px solid var(--line); text-align: center; cursor: pointer; font-weight: 600; transition: .15s; }
.player-options label:last-child { border-right: 0; }
.player-options input:checked + label { color: white; background: var(--red); }
.player-options input:focus-visible + label { outline: 3px solid var(--gold); outline-offset: -3px; }
.field { margin-bottom: 28px; }
select { width: 100%; border: 0; border-bottom: 1px solid var(--ink); border-radius: 0; padding: 11px 32px 11px 0; background-color: transparent; cursor: pointer; }
.rank-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 25px; }
.rank-fields .field { min-width: 0; }
.rank-fields .field:last-child:nth-child(odd) { grid-column: 1 / -1; }
.hand-preview { grid-column: 1 / -1; margin: 1px 0 28px; padding: 16px 18px; border-left: 3px solid var(--gold); background: rgba(215, 168, 63, .09); font-size: 14px; }
.hand-preview strong { display: block; margin-top: 3px; font-size: 19px; }
.form-error { min-height: 20px; margin: -8px 0 18px; color: #a52c21; font-size: 13px; }
.run-row { display: flex; gap: 26px; align-items: flex-end; margin-top: 10px; }
.trials-field { width: 45%; margin: 0; }
.run-button { flex: 1; min-height: 54px; padding: 0 19px; border: 0; color: white; background: var(--red); display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-weight: 700; transition: transform .15s, background .15s; }
.run-button:hover { background: #c53d2f; transform: translateY(-2px); }
.run-button:disabled { cursor: wait; opacity: .6; transform: none; }

.result-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.result-state[hidden] { display: none; }
.result-state > p { max-width: 310px; color: rgba(251, 248, 240, .7); line-height: 1.6; }
.card-mark { color: var(--gold); font-family: Georgia, serif; font-size: 100px; line-height: 1; }
.shuffle { height: 90px; display: flex; align-items: center; gap: 7px; }
.shuffle i { display: block; width: 36px; height: 52px; border: 1px solid var(--gold); background: rgba(215,168,63,.1); animation: shuffle 1s infinite alternate ease-in-out; }
.shuffle i:nth-child(2) { animation-delay: -.35s; }
.shuffle i:nth-child(3) { animation-delay: -.7s; }
@keyframes shuffle { to { transform: translateY(-15px) rotate(5deg); } }
.progress-track { width: min(320px, 100%); height: 3px; margin: 18px 0; background: rgba(255,255,255,.15); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--gold); transition: width .15s; }
.cancel-button { border: 0; border-bottom: 1px solid rgba(255,255,255,.4); padding: 5px 0; color: white; background: none; cursor: pointer; }
.complete { justify-content: flex-start; padding-top: 35px; }
.complete .hand-label { margin: 0; color: var(--gold); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; font-weight: 700; }
.probability { margin: 12px 0 0; line-height: 1; }
.probability strong { font-size: clamp(82px, 11vw, 142px); letter-spacing: -.08em; font-weight: 500; }
.probability span { color: var(--gold); font-size: 30px; }
.complete .interval { margin: 10px 0 30px; font-size: 13px; }
.result-stats { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid rgba(255,255,255,.16); border-bottom: 1px solid rgba(255,255,255,.16); }
.result-stats div { padding: 20px 8px; border-right: 1px solid rgba(255,255,255,.16); }
.result-stats div:last-child { border: 0; }
.result-stats strong, .result-stats span { display: block; }
.result-stats strong { color: var(--paper); font-size: 19px; }
.result-stats span { margin-top: 5px; color: rgba(255,255,255,.55); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.complete .result-note { margin: 22px 0 0; font-size: 12px; line-height: 1.5; }

.method { padding: clamp(70px, 10vw, 140px) max(22px, calc((100vw - 1160px) / 2)); color: var(--paper); background: #102d24; display: grid; grid-template-columns: .75fr 1.55fr; gap: 8vw; }
.method > div:first-child h2 { font-size: clamp(38px, 5vw, 70px); }
.method .eyebrow { color: var(--gold); }
.method-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 50px 40px; }
.method article > span { color: var(--gold); font-size: 11px; font-weight: 700; }
.method h3 { margin: 12px 0 10px; font-size: 18px; }
.method article p, .rule-note { margin: 0; color: rgba(251,248,240,.62); font-size: 14px; line-height: 1.65; }
.rule-note { grid-column: 2; margin-top: 30px; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.14); }
footer { min-height: 90px; padding: 25px clamp(22px, 5vw, 76px); display: flex; justify-content: space-between; align-items: center; gap: 20px; font-size: 12px; }
footer span:first-child { font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
footer span:last-child { color: rgba(20,38,31,.6); }

@media (max-width: 900px) {
  .calculator { margin-left: 18px; margin-right: 18px; grid-template-columns: 1fr; }
  .result-panel { min-height: 590px; }
  .method { grid-template-columns: 1fr; }
  .rule-note { grid-column: 1; }
}

@media (max-width: 560px) {
  .site-header { height: 64px; }
  .hero { padding-top: 65px; }
  .calculator { margin-left: 0; margin-right: 0; }
  .setup-panel, .result-panel { padding: 32px 22px; }
  .player-options { grid-template-columns: repeat(4, 1fr); }
  .player-options label:nth-of-type(4) { border-right: 0; }
  .player-options label:nth-of-type(n+5) { border-top: 1px solid var(--line); }
  .rank-fields { grid-template-columns: 1fr; }
  .rank-fields .field:last-child:nth-child(odd), .hand-preview { grid-column: 1; }
  .run-row { align-items: stretch; flex-direction: column; }
  .trials-field { width: 100%; }
  .run-button { flex: none; }
  .method-grid { grid-template-columns: 1fr; gap: 36px; }
  footer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .shuffle i { animation: none; }
}
