:root {
  --felt: #17604e;
  --felt-dark: #0e4236;
  --cream: #fffaf0;
  --ink: #18312b;
  --gold: #f3c969;
  --blue: #bfe5ef;
  --shadow: 0 5px 14px rgba(0, 20, 14, .28);
  --card-width: 176px;
  --card-height: 256px;
  --destination-card-height: 118px;
  --card-radius: .75rem;
  --card-exposed-height: 58px;
  --board-gap: 12px;
  font-family: Inter, ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: #fff; background: linear-gradient(90deg,#2b160b 0 12px,#b88a35 12px 15px,transparent 15px calc(100% - 15px),#b88a35 calc(100% - 15px) calc(100% - 12px),#2b160b calc(100% - 12px)), radial-gradient(circle at 50% -10%, #23816a, var(--felt) 45%, var(--felt-dark)); }
button, select { font: inherit; }
button { cursor: pointer; }
.topbar { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: 1rem clamp(1rem, 4vw, 3rem); background: rgba(5, 39, 31, .72); border-bottom: 1px solid rgba(255,255,255,.14); }
h1 { margin: 0; font-size: clamp(1.7rem, 4vw, 2.5rem); letter-spacing: -.04em; }
.tagline { margin: .2rem 0 0; opacity: .75; }
.controls { display: flex; align-items: end; flex-wrap: wrap; gap: .55rem; }
.controls label { display: grid; gap: .2rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.controls button, select, .modal button, .main-menu-screen button { border: 0; border-radius: .55rem; padding: .62rem .8rem; color: var(--ink); background: var(--cream); box-shadow: 0 2px 5px rgba(0,0,0,.18); }
.controls button:hover, .modal button:hover { background: var(--gold); }
main { width: min(1180px, 100%); margin: auto; padding: 1rem clamp(.65rem, 3vw, 2rem) 3rem; }
.status { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.status div { padding: .75rem 1rem; border-radius: .75rem; background: rgba(3, 38, 30, .55); border: 1px solid rgba(255,255,255,.12); }
.status span { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; opacity: .72; }
.status strong { font-size: 1.2rem; }
.status .lifetime-score { border-color: rgba(243, 201, 105, .65); background: rgba(70, 48, 5, .42); }
.status .lifetime-stats { grid-column: span 2; }
.status .lifetime-stats strong { font-size: .95rem; line-height: 1.35; }
.status .deal-status strong { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 1rem; letter-spacing: .04em; }
.deal-form { grid-column: span 2; display: grid; grid-template-columns: 1fr auto; gap: .3rem; align-content: center; padding: .55rem .7rem; border-radius: .75rem; background: rgba(3, 38, 30, .55); border: 1px solid rgba(255,255,255,.12); }
.deal-form label { grid-column: 1 / -1; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; opacity: .72; }
.deal-form input, .deal-form button { min-width: 0; border: 0; border-radius: .4rem; padding: .45rem .55rem; }
.deal-form button { color: var(--ink); background: var(--gold); }
.message { min-height: 1.4rem; margin: .7rem 0; color: #fff4c7; }
.game-dashboard { display:flex;justify-content:space-between;gap:.75rem;align-items:stretch;margin-bottom:.8rem;padding:.55rem;border:2px solid #b58a38;border-radius:.85rem;background:linear-gradient(#4b2e18,#2d190e);box-shadow:inset 0 0 0 2px rgba(221,177,83,.25),var(--shadow) }
.toolbar-left,.toolbar-right{display:flex;align-items:stretch;gap:.55rem}.toolbar-right{margin-left:auto;justify-content:flex-end}
.treasury-hoard { display: flex; align-items: center; gap: .8rem; min-height: 84px; text-align: left; background: linear-gradient(135deg, #fff2c9, #dcbf78) !important; }
.treasury-hoard span:last-child { display: grid; gap: .25rem; }.treasury-hoard strong { font-size: .88rem; overflow-wrap: anywhere; }
.chest-art { position: relative; width: 100px; height: 58px; flex: 0 0 100px; border: 4px solid #402414; border-radius: 42px 42px 10px 10px; background: repeating-linear-gradient(90deg,#7a431e 0 18px,#9f622b 18px 36px); box-shadow: inset 0 -19px #5b321a, 0 5px 0 #d0a52c; }
.chest-art::before { content:""; position:absolute; left:44px; top:22px; width:15px; height:20px; border-radius:3px; background:#e5ba38; box-shadow:0 0 0 3px #664914; }
.chest-art::after { content:""; position:absolute; left:5px; right:5px; bottom:-8px; height:12px; border-radius:50%; background:radial-gradient(circle,#f2c94c 0 3px,transparent 4px) 0 0/13px 10px, radial-gradient(circle,#b87333 0 3px,transparent 4px) 5px 3px/14px 11px; opacity:.25; }
.treasury-hoard.stage-coins .chest-art::after { opacity:.7; }.treasury-hoard.stage-gems .chest-art::after,.treasury-hoard.stage-hoard .chest-art::after { opacity:1; background:radial-gradient(circle,#ef4444 0 3px,transparent 4px) 0 0/17px 11px,radial-gradient(circle,#3b82f6 0 3px,transparent 4px) 7px 2px/19px 13px,radial-gradient(circle,#f2c94c 0 3px,transparent 4px) 3px 0/13px 10px; }
.hand-score-panel { min-width:112px;display:grid;place-content:center;padding:.45rem .75rem;border:1px solid #d7b15d;border-radius:.65rem;color:#fff;text-align:center;background:#173f35;cursor:pointer }.hand-score-panel span{font-size:.7rem;text-transform:uppercase;letter-spacing:.1em}.hand-score-panel strong{font-size:2rem;color:#ffe69b}
.stats-button{display:grid;place-content:center;min-width:92px;border:1px solid #d7b15d!important;background:#f8e8bb!important}.stats-button span{text-transform:uppercase;font-size:.7rem;letter-spacing:.1em}.stats-button strong{font-size:.8rem}
.recovery-actions { margin-left:auto;display:grid;grid-template-columns:1fr 1fr;gap:.5rem}.recovery-actions button{min-width:95px;border:1px solid #d7b15d;border-radius:.55rem;color:#2c2111;background:#fff4d6;font-weight:800}.recovery-actions small{display:flex;justify-content:center;align-items:center;gap:.25rem}.recovery-actions img,.unlock-cost img{width:18px;height:18px}
.sr-only{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}
h2 { margin: .65rem 0 .55rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .12em; opacity: .8; }
.destinations { display:grid;grid-template-columns:repeat(6,var(--card-width));align-items:start;gap:var(--board-gap);padding-bottom:.5rem }
.destination { position: relative; min-height: 138px; border: 2px dashed rgba(255,255,255,.38); border-radius: .8rem; background: rgba(0, 30, 22, .22); }
.destination.locked { display: grid; place-content: center; text-align: center; border-style: solid; background: rgba(5,20,17,.46); color: #ffe7a3; }
.destination.locked b { display: block; font-size: 1.5rem; }
.destination.empty::after { content: "Category"; position: absolute; inset: 0; display: grid; place-content: center; opacity: .4; }
.destination .card { position:absolute;left:50%;top:6px;transform:translateX(-50%);height:var(--destination-card-height);box-shadow:0 3px 8px rgba(0,20,14,.24) }
.destination .card-header { padding:.15rem .25rem;font-size:.66rem;line-height:1 }
.destination .card-body { font-size: .78rem; }
.destination .card small { display: none; }
.destination .definition-button { flex-basis: 1.2rem; width: 1.2rem; height: 1.2rem; font-size: .66rem; }
.play-area { display:grid;grid-template-columns:repeat(6,var(--card-width));align-items:start;gap:var(--board-gap);margin-top:1rem;padding-bottom:1rem }.draw-area{grid-column:1}.tableau-area{grid-column:2/7;min-width:0}.draw-row{display:flex;flex-direction:column;align-items:flex-start;gap:.75rem}
.stock, .card { width:var(--card-width);height:var(--card-height);border-radius:var(--card-radius);border:2px solid rgba(30,30,30,.16);box-shadow:var(--shadow) }
.stock { display: grid; place-content: center; color: white; background: repeating-linear-gradient(45deg, #153d61, #153d61 8px, #1d527e 8px, #1d527e 16px); border: 5px double rgba(255,255,255,.75); }
.stock span { font-weight: 900; font-size: 1.5rem; }
.stock small { margin-top: .35rem; }
.stock:disabled { filter: grayscale(1); cursor: default; opacity: .4; }
.waste { position:relative;width:var(--card-width);min-width:var(--card-width);min-height:calc(var(--card-height) + var(--card-exposed-height) * 2) }
.waste .card { position: absolute; left: 0; top: 0; }
.waste .card:nth-child(2) { left:0;top:var(--card-exposed-height) }
.waste .card:nth-child(3) { left:0;top:calc(var(--card-exposed-height) * 2) }
.card { display: flex; flex-direction: column; overflow: hidden; padding: 0; color: var(--ink); background: var(--cream); user-select: none; touch-action: manipulation; }
.card-header { display:flex;flex:0 0 var(--card-exposed-height);min-height:var(--card-exposed-height);max-height:var(--card-exposed-height);align-items:center;justify-content:center;gap:.35rem;width:100%;padding:.3rem .45rem;color:#102b25;background:#e8f4e9;border-bottom:2px solid rgba(18,57,46,.22);font-size:.9rem;font-weight:850;line-height:1.15;overflow:hidden;overflow-wrap:normal;word-break:normal;text-align:center }
.card-header > span{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.card-header > span { min-width: 0; flex: 1 1 auto; }
.definition-button { flex: 0 0 1.45rem; width: 1.45rem; height: 1.45rem; padding: 0; border: 1px solid rgba(16,43,37,.35); border-radius: 50%; color: #173f35; background: rgba(255,255,255,.85); font-size: .78rem; font-weight: 900; line-height: 1; cursor: help; }
.category-counter { flex: 0 0 auto; min-width: 2rem; padding: .22rem .25rem; color: #fff; background: #60440b; border-radius: .35rem; box-shadow: 0 1px 2px rgba(0,0,0,.2); font-size: .72rem; line-height: 1; text-align: center; }
.card-body { display: flex; flex: 1; align-items: center; justify-content: center; min-height: 0; padding: .35rem; overflow-wrap: anywhere; font-size: clamp(.78rem, 1.3vw, 1.05rem); font-weight: 750; line-height: 1.05; text-align: center; }
.card small { flex: 0 0 auto; padding: 0 .25rem .25rem; font-size: .55rem; text-transform: uppercase; letter-spacing: .06em; opacity: .68; text-align: center; }
.card-thumbnail { width: 26px; height: 26px; flex: 0 0 26px; object-fit: cover; border-radius: .2rem; }
.card-body .card-thumbnail { width: 46px; height: 46px; flex-basis: 46px; }
.card.category { background: linear-gradient(145deg, #fffaf0, #e7d5ac); border-color: #8c6b34; box-shadow: inset 0 0 0 2px rgba(142,101,38,.22), var(--shadow); }
.card.category .card-header { background: #f7cf6f; border-bottom-color: rgba(95, 62, 4, .3); }
.card.category .card-body { font-size: .82rem; letter-spacing: .06em; }
.card.category.difficulty-yellow, .card.category.difficulty-green, .card.category.difficulty-blue, .card.category.difficulty-purple { color:#2d281d; background:linear-gradient(145deg,#fffaf0,#e7d5ac); border-color:#8c6b34; }
.card.category.difficulty-yellow .card-header { color: #322407; background: #f7d85f; }
.card.category.difficulty-green { color: #102c1b; background: linear-gradient(145deg, #bce9b8, #62bd78); border-color: #287343; }
.card.category.difficulty-green .card-header { color: #102c1b; background: #82cf8d; }
.card.category.difficulty-blue { color: #102b3b; background: linear-gradient(145deg, #bfe8f7, #63b6dc); border-color: #28749a; }
.card.category.difficulty-blue .card-header { color: #102b3b; background: #80c9e8; }
.card.category.difficulty-purple { color: #2b1536; background: linear-gradient(145deg, #e1c5f0, #ad74ca); border-color: #70428a; }
.card.category.difficulty-purple .card-header { color: #2b1536; background: #c497db; }
.card.category .card-header, .card.category.difficulty-yellow .card-header, .card.category.difficulty-green .card-header, .card.category.difficulty-blue .card-header, .card.category.difficulty-purple .card-header { color:#2d281d; background:#dfcca2; border-bottom-color:rgba(95,62,4,.25); }
.card.face-down { color: transparent; background: repeating-linear-gradient(135deg, #742f43, #742f43 8px, #98405a 8px, #98405a 16px); border: 5px double #f2c7a9; }
.card.category.face-down { color: transparent; background: repeating-linear-gradient(135deg, #742f43, #742f43 8px, #98405a 8px, #98405a 16px); border-color: #f2c7a9; }
.card.selected { outline: 4px solid #fff08e; transform: translateY(-7px); }
.card.valid-target, .destination.valid-target { outline: 3px solid #9affc5; }
.tableau { display:grid;grid-template-columns:repeat(5,var(--card-width));gap:var(--board-gap) }
.column { position:relative;min-height:340px;border-radius:.8rem;background:rgba(0,35,27,.2);border:0 }
.tableau-placeholder { min-height:340px;border-radius:.8rem;background:rgba(0,35,27,.08);outline:1px dashed rgba(255,255,255,.08);pointer-events:none;user-select:none }
.column.empty::after { content: "Empty"; position: absolute; inset: 1rem; display: grid; place-content: center; border: 2px dashed rgba(255,255,255,.25); border-radius: .7rem; opacity: .5; }
.column .card { position:absolute;left:0;transform:none;width:var(--card-width) }
.column .card.selected { transform:translateY(-7px) }
.drag-stack-ghost { position: fixed; left: -1000px; top: -1000px; width: 104px; min-height: 0; z-index: 100; background: transparent; border: 0; }
.help { margin-top: 1.4rem; padding: .8rem 1rem; background: rgba(0,25,20,.34); border-radius: .7rem; }
.help summary { cursor: pointer; font-weight: 700; }
.help p, .help li { line-height: 1.45; color: rgba(255,255,255,.84); }
.modal { position: fixed; inset: 0; display: grid; place-content: center; padding: 1rem; background: rgba(0,15,12,.75); z-index: 20; }
.modal.hidden { display: none; }
.modal-card { min-width: min(360px, 90vw); padding: 2rem; color: var(--ink); background: var(--cream); border-radius: 1rem; text-align: center; box-shadow: var(--shadow); }
.modal-card h2 { color: var(--ink); opacity: 1; font-size: 1.5rem; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.hidden { display: none !important; }
.main-menu-screen { min-height: calc(100vh - 89px); display: grid; place-items: center; padding: 2rem 1rem; }
.main-menu-card { width: min(620px, 94vw); padding: 2rem; color: var(--ink); background: var(--cream); border-radius: 1rem; text-align: center; box-shadow: var(--shadow); }
.main-menu-card h2 { margin: 0; color: var(--ink); opacity: 1; font-size: clamp(2rem, 7vw, 3.2rem); }
.main-menu-card h3 { margin: 1.4rem 0 .7rem; }
.menu-kicker { text-transform: uppercase; letter-spacing: .12em; font-weight: 800; }
.game-selector { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.game-selector button { border: 2px solid transparent; font-weight: 800; }
.game-selector button[aria-pressed="true"] { border-color: #9e7520; background: var(--gold); }
.game-selector small { display: block; margin-top: .2rem; font-weight: 500; }
.menu-settings { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; text-align: left; }
.menu-settings label { display: grid; gap: .3rem; font-weight: 750; }
.menu-settings .content-library-setting { grid-column:1 / -1; }
.content-library-setting small { color:#65552f; font-weight:600; }
.menu-deal-form { display: grid; grid-template-columns: 1fr auto; gap: .4rem; margin: 1rem auto 0; text-align: left; }
.menu-deal-form label { grid-column: 1 / -1; font-weight: 750; }
.menu-deal-form input { min-width: 0; padding: .6rem; border: 1px solid #8d8062; border-radius: .45rem; }
.menu-note { min-height: 1.25rem; color: #65552f; font-size: .88rem; }
.move-feedback { position:sticky; bottom:0; z-index:8; display:grid; grid-template-columns:1fr auto; gap:1rem; align-items:center; margin-top:1rem; padding:.65rem .9rem; border:1px solid rgba(239,202,113,.55); border-radius:.7rem; background:rgba(15,44,36,.94); box-shadow:0 -3px 12px rgba(0,0,0,.25); }.move-feedback span{display:block;font-size:.65rem;text-transform:uppercase;opacity:.7}.move-feedback details{max-width:420px}.move-feedback ol{max-height:180px;overflow:auto;margin:.5rem 0 0;padding-left:1.5rem;font-size:.82rem}
.floating-message { position:fixed; left:50%; top:42%; z-index:17; transform:translate(-50%,-50%); padding:.75rem 1rem; border:2px solid #ffd976; border-radius:.7rem; color:#281b08; background:#fff5d4; box-shadow:0 8px 30px rgba(0,0,0,.4); pointer-events:none; animation:float-feedback 1.8s ease forwards; }
@keyframes float-feedback { 0%{opacity:0;transform:translate(-50%,-35%)} 15%,75%{opacity:1;transform:translate(-50%,-50%)} 100%{opacity:0;transform:translate(-50%,-65%)} }
.card.flip-reveal { animation:card-flip .26s ease; backface-visibility:hidden; transform-style:preserve-3d; } @keyframes card-flip { 0%{transform:rotateY(90deg)} 100%{transform:rotateY(0)} }
.destination.complete-effect { animation:complete-glow .65s ease; } @keyframes complete-glow { 0%,100%{box-shadow:none} 35%{box-shadow:0 0 30px 12px #ffd85a;transform:scale(1.03)} }
.treasury-card{position:relative;width:min(620px,94vw)}.dialog-close{position:absolute;right:.7rem;top:.6rem}.denomination-list{display:grid;grid-template-columns:repeat(3,1fr);gap:.5rem;text-align:left}.denomination{display:grid;grid-template-columns:30px 1fr;align-items:center;padding:.5rem;border-radius:.5rem;background:#f1e4c5}.currency-icon{width:24px;height:24px;border-radius:50%;background:#b87333;box-shadow:inset 0 0 0 3px rgba(255,255,255,.3)}.denomination:nth-child(2) .currency-icon{background:#b8c2cc}.denomination:nth-child(3) .currency-icon{background:#e2b93b}.denomination:nth-child(n+4) .currency-icon{border-radius:5px;transform:rotate(45deg);background:#c54444}.denomination:nth-child(5) .currency-icon{background:#8b5bc1}.denomination:nth-child(6) .currency-icon{background:#36a269}.denomination:nth-child(7) .currency-icon{background:#397bc1}.denomination:nth-child(8) .currency-icon{background:#d72e45}.denomination:nth-child(9) .currency-icon{background:#dff8ff}.debt{color:#991b1b;font-weight:800}
.stats-card{position:relative;width:min(650px,94vw)}.stats-card .status{color:#fff;grid-template-columns:repeat(2,1fr);text-align:left}.stats-card .lifetime-stats{grid-column:1/-1}
.hand-log-card{position:relative;width:min(650px,94vw);max-height:85vh;overflow:auto}.hand-log-score strong{font-size:2rem}.hand-log-card ol{display:flex;flex-direction:column;gap:.45rem;margin:1rem 0 0;padding-left:2rem;text-align:left}.hand-log-card li{padding:.45rem .6rem;border-radius:.4rem;background:#f1e4c5}
@media (prefers-reduced-motion: reduce) { .card.flip-reveal,.destination.complete-effect,.floating-message{animation:none!important} }
.definition-panel { position: fixed; right: 1rem; bottom: 1rem; z-index: 18; width: min(390px, calc(100vw - 2rem)); max-height: min(70vh, 620px); overflow: auto; padding: 1rem 1.15rem; color: var(--ink); background: var(--cream); border: 2px solid #c79a35; border-radius: 1rem; box-shadow: 0 10px 35px rgba(0,0,0,.4); }
.definition-panel.hidden { display: none; }
.definition-panel h2 { margin: 0 2rem .25rem 0; color: var(--ink); opacity: 1; font-size: 1.4rem; text-transform: none; letter-spacing: normal; }
.definition-panel ol { margin: .6rem 0; padding-left: 1.35rem; }
.definition-panel li { margin: .45rem 0; line-height: 1.35; }
.definition-close { position: absolute; right: .65rem; top: .55rem; width: 2rem; height: 2rem; border: 0; border-radius: 50%; color: var(--ink); background: #ead8aa; font-size: 1.3rem; }
.definition-part { margin: 0; color: #5e665f; font-style: italic; }
.definition-notes { padding: .55rem; background: #f2e8cf; border-radius: .45rem; line-height: 1.35; }
.definition-example { margin: .35rem 0; color: #41524d; font-style: italic; }

@media (max-width: 760px) {
  .game-dashboard{flex-wrap:wrap}.toolbar-left{flex:1 1 100%}.toolbar-right{margin-left:0;flex:1 1 100%;flex-wrap:wrap;justify-content:flex-end}.treasury-hoard{width:100%}.hand-score-panel,.stats-button{flex:1}.recovery-actions{margin-left:0;flex:1 1 100%}.denomination-list{grid-template-columns:1fr 1fr}.move-feedback{position:static;grid-template-columns:1fr}
  .topbar { align-items: flex-start; flex-direction: column; }
  .status { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1199px) {
  .destinations,.play-area{overflow-x:auto}
}

@media (max-width: 430px) {
  .controls { width: 100%; }
  .controls label { flex: 1; }
  .controls select { width: 100%; }
  .destinations { gap: .35rem; }
  .destination { min-height: 112px; }
  .column { min-height: 300px; }
  .card-header { padding-inline: .18rem; font-size: .68rem; }
  .category-counter { min-width: 1.7rem; padding-inline: .16rem; font-size: .68rem; }
  .card-body { padding: .25rem; font-size: .78rem; }
  .definition-panel { right: .45rem; bottom: .45rem; width: calc(100vw - .9rem); max-height: 48vh; padding: .85rem 1rem; }
}
