:root {
  color-scheme: dark;
  --bg: #10172a;
  --surface: #182238;
  --surface-raised: #202d46;
  --line: rgba(209, 224, 255, .13);
  --muted: #9cabc4;
  --text: #f4f7ff;
  --cyan: #62e2d2;
  --purple: #a894ff;
  --orange: #ffb878;
  --pink: #ff8ea8;
  font-family: "Kanit", "Tahoma", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(ellipse at 8% 8%, rgba(84, 107, 195, .16), transparent 34rem),
    radial-gradient(ellipse at 96% 28%, rgba(28, 173, 166, .10), transparent 30rem),
    var(--bg);
}
button, select, input, textarea { font: inherit; }
button { color: inherit; }
.app-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 60px; }
.topbar { height: 68px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.button { border: 0; border-radius: 12px; padding: 11px 17px; font-weight: 500; cursor: pointer; transition: transform .18s ease, background .18s ease, border-color .18s ease; }
.button:hover:not(:disabled) { transform: translateY(-2px); }
.button:focus-visible, .text-button:focus-visible, .icon-button:focus-visible, .card-button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.button:disabled { opacity: .46; cursor: not-allowed; }
.button-quiet { color: #d7e1f3; background: transparent; border: 1px solid var(--line); }
.button-quiet:hover { background: rgba(255,255,255,.06); }
.button-primary { color: #102129; background: var(--cyan); font-weight: 700; box-shadow: 0 9px 24px rgba(98, 226, 210, .16); }
.button-primary:hover { background: #81eee0; }
.button-wide { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; }
.setup-screen { min-height: 650px; display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(30px, 8vw, 100px); align-items: center; padding: 55px 2vw 80px; }
.hero-copy { max-width: 540px; }
.eyebrow { color: var(--cyan); font: 600 10px "Space Grotesk", sans-serif; letter-spacing: 1.7px; }
.hero-copy h1 { margin: 17px 0 16px; font-size: clamp(42px, 6vw, 68px); font-weight: 600; letter-spacing: -1.6px; line-height: 1.17; }
.hero-copy h1 span { color: var(--cyan); }
.hero-copy p { max-width: 410px; color: #b7c3d8; font-size: 17px; line-height: 1.7; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 28px; }
.hero-chips span { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: #c4d1e4; background: rgba(255,255,255,.025); font-size: 12px; }
.setup-card, .table-card, .play-area, .hand-section { background: linear-gradient(145deg, rgba(32,45,70,.93), rgba(24,34,56,.93)); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 18px 55px rgba(0,0,0,.13); }
.setup-card { padding: 28px; }
.setup-heading { display: flex; gap: 13px; align-items: center; margin-bottom: 24px; }
.step-number { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 13px; color: var(--cyan); background: rgba(98,226,210,.12); font: 700 13px "Space Grotesk", sans-serif; }
.setup-heading h2, .section-heading h2, .dialog-header h2 { margin: 0; font-size: 19px; font-weight: 500; }
.setup-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.setup-card label { display: block; margin: 17px 0 7px; color: #c7d2e4; font-size: 13px; }
.name-input { width: 100%; padding: 12px 13px; color: var(--text); background: #111a2d; border: 1px solid var(--line); border-radius: 10px; }
.name-input::placeholder { color: #6f7d96; }
.setup-card .name-input { margin: 4px 0 20px; }
.privacy-note { margin: 13px 0 0; color: #8291a9; text-align: center; font-size: 11px; }
.hidden { display: none !important; }
.game-screen { padding-top: 15px; }
.game-heading { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; }
.game-heading h1 { margin: 2px 0 0; font-size: 22px; font-weight: 500; }
.status-strip { display: flex; align-items: center; justify-content: space-between; padding: 9px 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(24,34,56,.75); }
.turn-indicator { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.turn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 14px var(--cyan); }
.deck-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.deck-status strong { color: var(--text); font: 600 16px "Space Grotesk", sans-serif; }
.player-strip { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 9px 0 0; }
.player-chip { display: flex; gap: 8px; align-items: center; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; color: #bdc9dc; background: rgba(24,34,56,.5); font-size: 12px; }
.player-chip.active { color: var(--cyan); border-color: rgba(98,226,210,.52); background: rgba(98,226,210,.08); }
.player-chip .shield { color: var(--orange); }
.player-chip strong { display: grid; place-items: center; min-width: 22px; height: 22px; border-radius: 50%; color: #dce5f3; background: rgba(255,255,255,.1); font: 600 11px "Space Grotesk", sans-serif; }
.player-chip::before { content: ""; width: 10px; height: 10px; flex: 0 0 10px; border: 2px solid currentColor; border-radius: 50%; opacity: .8; }
.table-surface {
  position: relative;
  min-height: 225px;
  margin: 0 0 12px;
  padding: 12px 20px 10px;
  overflow: hidden;
  border: 5px solid #392516;
  border-radius: 20px;
  background:
    linear-gradient(90deg, rgba(33,18,10,.23), transparent 16%, transparent 84%, rgba(33,18,10,.25)),
    repeating-linear-gradient(0deg, transparent 0 46px, rgba(47,25,12,.48) 47px 50px, rgba(192,139,82,.12) 51px 52px),
    repeating-linear-gradient(90deg, rgba(255,222,165,.035) 0 3px, transparent 4px 100%),
    linear-gradient(180deg, #805735 0%, #69452b 34%, #765032 67%, #604026 100%);
  box-shadow: inset 0 0 0 1px rgba(255,211,148,.22), inset 0 10px 24px rgba(255,224,174,.08), inset 0 -18px 35px rgba(29,15,7,.28), 0 14px 30px rgba(0,0,0,.25);
}
.table-surface::after { position: absolute; inset: 5px; border: 1px solid rgba(236,190,126,.2); border-radius: 12px; content: ""; pointer-events: none; }
.table-surface-label, .table-note { position: relative; z-index: 1; color: rgba(255,236,206,.75); font-size: 10px; letter-spacing: .8px; text-transform: uppercase; }
.table-surface-label { display: flex; align-items: center; gap: 8px; }
.table-surface .player-chip { padding: 5px 10px; background: rgba(48,31,20,.48); border-color: rgba(244,215,177,.28); color: #f0dfc7; }
.table-surface .player-chip.active { color: #ffe2a6; border-color: rgba(255,220,150,.7); background: rgba(87,58,31,.65); }
.table-surface .player-chip strong { color: #3a2919; background: #e6ca98; }
.surface-dot { width: 6px; height: 6px; border-radius: 50%; background: #d6bd80; box-shadow: 0 0 9px rgba(255,217,126,.65); }
.table-center { display: grid; grid-template-columns: 110px minmax(0,1fr); align-items: center; gap: 20px; width: min(620px, 100%); min-height: 135px; margin: 0 auto; }
.draw-pile-visual { position: relative; width: 92px; height: 115px; margin: 0 auto 15px; }
.card-back { position: absolute; width: 66px; height: 88px; border: 2px solid #d2ae6c; border-radius: 9px; background: repeating-linear-gradient(45deg, #282945 0 5px, #343357 6px 9px); box-shadow: 0 5px 9px rgba(24,12,5,.45); }
.card-back-one { left: 13px; top: 7px; transform: rotate(-12deg); }
.card-back-two { left: 17px; top: 3px; transform: rotate(-5deg); }
.card-back-top { left: 19px; top: 0; display: grid; place-items: center; color: #f0d99c; border-color: #e5c987; background: linear-gradient(145deg, #343454, #25243b); font: 700 15px "Space Grotesk", sans-serif; }
.card-back-top::after { position: absolute; inset: 5px; border: 1px solid rgba(230,205,147,.55); border-radius: 5px; content: ""; }
.pile-caption { position: absolute; top: 94px; left: 0; width: 100%; color: #f8e6c6; text-align: center; text-shadow: 0 1px 3px #301c0e; font-size: 10px; white-space: nowrap; }
.pile-caption strong { display: inline-grid; place-items: center; min-width: 19px; height: 19px; margin-left: 4px; padding: 0 4px; border-radius: 50%; color: #342516; background: #edcc8f; font: 700 10px "Space Grotesk", sans-serif; }
.played-area { min-width: 0; text-align: center; }
.played-label { color: rgba(255,236,206,.7); text-shadow: 0 1px 3px #301c0e; font-size: 10px; }
.played-cards { display: flex; justify-content: center; align-items: center; min-height: 110px; padding: 7px 4px; }
.table-empty { color: rgba(255,234,201,.72); font-size: 13px; }
.played-card { position: relative; width: 105px; height: 140px; flex: 0 0 105px; margin-left: -13px; padding: 0; overflow: hidden; border: 2px solid rgba(241,215,164,.8); border-radius: 10px; color: #f9f2e5; text-align: left; background: #192338; box-shadow: 0 8px 15px rgba(32,16,6,.45); }
.played-card:first-child { margin-left: 0; }
.played-card:nth-child(1) { transform: rotate(-5deg) translateY(3px); }
.played-card:nth-child(2) { z-index: 1; transform: translateY(-2px); }
.played-card:nth-child(3) { transform: rotate(5deg) translateY(3px); }
.played-card[data-kind="dq"] { background: linear-gradient(145deg, #51437c, #292642); }
.played-card[data-kind="support"] { background: linear-gradient(145deg, #805638, #3e2e25); }
.played-card .card-kind { padding: 3px 5px; color: #f4d899; background: rgba(245,214,155,.16); font-size: 8px; }
.played-card .card-title { margin-top: 9px; font-size: 11px; }
.played-card .card-subtitle { display: -webkit-box; overflow: hidden; color: #d8d1c5; font-size: 8px; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.played-card .card-symbol { color: rgba(255,255,255,.14); font-size: 18px; }
.table-note { margin: 0; color: rgba(255,236,206,.58); text-align: center; letter-spacing: 0; text-transform: none; }
.table-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(245px, .75fr); gap: 17px; align-items: stretch; }
.play-area { min-height: 255px; padding: 21px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-heading h2 { margin-top: 4px; }
.section-heading.compact { margin-bottom: 14px; }
.turn-count { color: #7e8ba2; font: 500 11px "Space Grotesk", sans-serif; }
.turn-message { margin: 0 0 12px; color: #aebbd0; font-size: 13px; }
.play-options { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 15px; }
.play-options .button { font-size: 12px; }
.text-button { padding: 0; color: var(--cyan); background: transparent; border: 0; cursor: pointer; font-size: 12px; }
.pair-builder { display: grid; grid-template-columns: minmax(0,1fr) 24px minmax(0,1fr); align-items: center; gap: 10px; margin-top: 14px; }
.pair-select { width: 100%; min-height: 45px; padding: 9px 10px; color: var(--text); background: #111a2d; border: 1px solid var(--line); border-radius: 10px; font-size: 12px; }
.pair-plus { color: var(--cyan); text-align: center; font: 700 18px "Space Grotesk", sans-serif; }
.hint-line { margin: 7px 0 0; color: #8d9cb3; font-size: 11px; }
.submit-pair { margin-top: 11px; }
.table-card { padding: 18px; }
.quick-rules { margin-top: 13px; }
.quick-rules p { margin: 9px 0; color: #bdc9dc; font-size: 12px; line-height: 1.7; }
.hand-section { margin: 0 0 12px; padding: 12px 16px 14px; background: linear-gradient(180deg, rgba(100,67,42,.94), rgba(64,43,30,.97)); border-color: rgba(227,185,126,.24); }
.hand-section .eyebrow { color: #f0ce94; }
.hand-section .hand-count { color: #d7c3a2; }
.hand-count { color: var(--muted); font-size: 12px; }
.hand-grid { display: flex; align-items: flex-end; justify-content: center; gap: 7px; padding: 5px 2px 3px; overflow-x: auto; }
.card-button { position: relative; width: 125px; min-width: 125px; max-width: 125px; height: 167px; flex: 0 0 125px; margin-right: -22px; padding: 0; text-align: left; border: 1px solid rgba(232,212,177,.5); border-radius: 11px; color: var(--text); background: #192338; cursor: default; overflow: hidden; box-shadow: 0 6px 13px rgba(22,12,7,.35); }
.hand-grid .card-button:last-child { margin-right: 0; }
.hand-grid .card-button:hover, .hand-grid .card-button.selected { z-index: 3; }
.card-art { display: block; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.card-button.is-selectable { cursor: pointer; transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.card-button.is-selectable:hover { transform: translateY(-8px); border-color: #f0ce94; background: #29374d; }
.card-button.selected { border-color: #f0ce94; box-shadow: inset 0 0 0 1px #f0ce94, 0 0 18px rgba(240,206,148,.18); transform: translateY(-7px); }
.card-button:disabled { opacity: .78; }
.card-kind { display: inline-flex; padding: 4px 7px; border-radius: 6px; color: var(--cyan); background: rgba(98,226,210,.1); font-size: 9px; line-height: 1.3; }
.card-button[data-kind="dq"] .card-kind { color: var(--purple); background: rgba(168,148,255,.12); }
.card-button[data-kind="support"] .card-kind { color: var(--orange); background: rgba(255,184,120,.12); }
.card-title { display: block; margin-top: 11px; font-size: 14px; font-weight: 500; line-height: 1.35; }
.card-subtitle { display: block; margin-top: 5px; color: #9aabc3; font-size: 10px; line-height: 1.45; }
.card-symbol { position: absolute; right: 10px; top: 8px; color: rgba(255,255,255,.11); font: 700 22px "Space Grotesk", sans-serif; }
.empty-hand { flex: 1 0 100%; color: #e0cfb5; font-size: 13px; }
.rules-dialog, .result-dialog { width: min(540px, calc(100% - 30px)); max-height: 86vh; padding: 24px; color: var(--text); background: #182238; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 24px 80px rgba(0,0,0,.5); }
.rules-dialog::backdrop, .result-dialog::backdrop { background: rgba(4,8,18,.75); backdrop-filter: blur(5px); }
.revealed-cards { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.revealed-card { width: 130px; height: 174px; overflow: hidden; border: 2px solid rgba(241,215,164,.8); border-radius: 10px; box-shadow: 0 8px 18px rgba(0,0,0,.35); }
.revealed-card .card-art { width: 100%; height: 100%; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; }
.dialog-header h2 { margin-top: 4px; font-size: 23px; }
.icon-button { width: 35px; height: 35px; color: #c9d4e5; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 23px; line-height: 1; }
.rules-list { padding-left: 21px; color: #bcc9dc; font-size: 13px; line-height: 1.8; }
.rules-list li { margin: 12px 0; padding-left: 4px; }
.rules-list li::marker { color: var(--cyan); font-weight: 600; }
.rules-list strong { color: var(--text); }
.rules-caveat { margin: 18px 0 0; padding: 11px 13px; color: #e8c99e; background: rgba(255,184,120,.08); border: 1px solid rgba(255,184,120,.2); border-radius: 10px; font-size: 11px; line-height: 1.6; }
.result-dialog { text-align: center; }
.result-content { padding: 15px 7px 5px; }
.result-star { display: block; margin-bottom: 11px; color: var(--cyan); font-size: 40px; }
.result-content h2 { margin: 7px 0; font-size: 28px; }
.result-content p { margin: 8px 0 22px; color: #adbbd1; font-size: 13px; }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 28px, 600px); }
  .setup-screen { min-height: 0; grid-template-columns: 1fr; gap: 25px; padding: 50px 0; }
  .hero-copy { padding: 0 4px; }
  .hero-copy h1 { font-size: clamp(40px, 12vw, 59px); }
  .hero-copy p { font-size: 15px; }
  .setup-card { padding: 22px; }
  .table-layout { grid-template-columns: 1fr; }
  .side-column { display: block; }
  .quick-rules { margin-top: 0; }
  .hand-grid { justify-content: flex-start; }
  .table-surface { min-height: 215px; padding: 12px; }
  .table-center { grid-template-columns: 98px minmax(0,1fr); gap: 9px; min-height: 125px; }
  .played-card { width: 94px; height: 126px; flex-basis: 94px; margin-left: -24px; }
  .played-card:first-child { margin-left: 0; }
  .hand-grid { justify-content: flex-start; }
}
@media (max-width: 460px) {
  .pair-builder { grid-template-columns: 1fr; }
  .pair-plus { display: none; }
  .hand-section { padding: 15px; }
  .play-area { padding: 17px; }
  .hand-grid { gap: 7px; }
  .card-button { width: 118px; min-width: 118px; max-width: 118px; height: 158px; flex: 0 0 118px; }
  .card-title { font-size: 12px; }
  .status-strip { padding: 11px 12px; }
  .turn-indicator { font-size: 12px; }
  .table-surface { min-height: 205px; padding: 12px 10px; }
  .table-center { grid-template-columns: 75px minmax(0,1fr); gap: 5px; min-height: 118px; }
  .draw-pile-visual { transform: scale(.85); transform-origin: center; }
  .played-cards { min-height: 105px; }
  .played-card { width: 82px; height: 110px; flex-basis: 82px; margin-left: -32px; }
}

