/* © 2026 18cores, LLC. All rights reserved. */
/* A green felt card table, cream cards, amber for anything to notice. Text never under 13px, 15px in play. */
@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 400; font-display: swap; src: url('./fonts/atkinson-400.woff2') format('woff2'); }
@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 700; font-display: swap; src: url('./fonts/atkinson-700.woff2') format('woff2'); }

:root {
  --felt: #0f3d2e; --felt-dark: #0a2b20; --felt-mid: #0b3226; --felt-light: #124634; --line: #1d5a45; --line-strong: #3f7a63;
  --ink: #f3efe2; --muted: #b9cfc4; --amber: #ffc14d; --amber-ink: #2a1d00;
  --card: #fbf8ef; --card-edge: #cfc6b0; --card-ink: #1a1a1a; --card-red: #b3122e; --back: #8f3a33;
  --font: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif;
  --suit: 'Segoe UI Symbol', 'Apple Symbols', 'DejaVu Sans', 'Noto Sans Symbols 2', sans-serif;
  /* Card sizes: your cards fill a phone's width four across; the shared piles eight across. */
  /* and shrink on a short screen, so the whole table fits without scrolling. */
  --cw: clamp(46px, min(calc((100vw - 68px) / 4.5), calc((100dvh - 440px) / 4.2)), 96px); --ch: calc(var(--cw) * 1.4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--felt); color: var(--ink); font-family: var(--font); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
/* Exactly one screen tall: the table never scrolls; long work piles squeeze their fan into the room left. */
.app { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom, 0px); }

.header { display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px)); background: var(--felt-dark); border-bottom: 1px solid var(--line); }
.back-link { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 6px 0 0; color: var(--amber); font-weight: 700; font-size: 16px; text-decoration: none; }
.back-link svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.brand { flex: 1; min-width: 0; margin: 0; text-align: center; font-size: clamp(15px, 4.4vw, 20px); font-weight: 700; letter-spacing: .05em; white-space: nowrap; }
@media (min-width: 900px) { .brand { letter-spacing: .08em; } }
.header-right { display: flex; gap: 8px; }
.icon-button { display: inline-flex; align-items: center; gap: 6px; min-width: 44px; min-height: 44px; padding: 0 10px; justify-content: center; border-radius: 22px; border: 2px solid var(--line-strong); background: transparent; cursor: pointer; font-weight: 700; font-size: 15px; }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-button[aria-pressed="true"] .waves { display: none; }
.wide-only { display: none; }
/* A short phone: the other players' boxes lose their score line and ticks to leave room for your cards. */
@media (max-width: 899px) and (max-height: 720px) { .other .ticks, .other .other-score { display: none; } .other { padding: 6px 8px; } }
@media (max-width: 380px) { .wide-label { display: none; } .panel { padding: 18px 14px; } }

.scorebar { display: flex; justify-content: space-between; padding: 8px 16px; font-size: 14px; font-weight: 700; letter-spacing: .06em; color: var(--muted); background: var(--felt-mid); }
.scorebar b { color: var(--ink); font-size: 16px; }
.label { font-size: 13px; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.label.accent { color: var(--amber); }
.helper-tag { margin-left: 8px; padding: 1px 6px; border-radius: 4px; background: var(--amber); color: var(--amber-ink); font-size: 13px; letter-spacing: .06em; }
.note { margin: 2px 0 0 !important; font-size: 15px !important; color: var(--muted) !important; }

.table { position: relative; flex: 1; display: grid; grid-template-areas: 'others' 'middle' 'mine'; grid-template-rows: auto auto 1fr; min-height: 0; }
.others { grid-area: others; display: grid; grid-template-columns: repeat(var(--others, 3), minmax(0, 1fr)); gap: 8px; padding: 10px 16px 4px; }
.middle { grid-area: middle; padding: 8px 16px 6px; }
.mine { grid-area: mine; display: flex; flex-direction: column; gap: 10px; padding: 10px 16px 12px; background: var(--felt-light); border-top: 2px solid var(--line); min-height: 0; }

/* Another player: the card they're trying to get rid of, their name, how many are left. */
.other { display: grid; gap: 5px; padding: 7px 8px; border-radius: 8px; background: var(--felt-mid); border: 2px solid var(--line); }
.other.close { border-color: var(--amber); }
.other-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.other-name { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.other-left { font-size: 15px; font-weight: 700; }
.other.close .other-left { color: var(--amber); }
.other-score { font-size: 13px; color: var(--muted); }
.other .card { --cw: 30px; flex: none; }
.ticks { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 2px; }
.ticks i { height: 8px; border-radius: 2px; background: #2a5a49; }
.ticks i.on { background: #e3eadf; }
.close .ticks i.on, .my-pile .ticks i.on { background: var(--amber); }

/* The shared piles: room for every ace on the table. */
.shared { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; margin-top: 6px; padding: 8px; background: var(--felt-mid); border-radius: 10px; border: 1px solid var(--line); }
.slot { position: relative; aspect-ratio: 5 / 7; border-radius: 5px; border: 1.5px dashed #2f6b55; padding: 0; background: transparent; }
.shared .card { --cw: 100%; width: 100%; height: auto; aspect-ratio: 5 / 7; }
.shared .card .corner { font-size: clamp(12px, 3.4vw, 22px); }
.shared .card .pip { font-size: clamp(16px, 5vw, 34px); }
.slot.flash, .shared .card.flash { animation: flash .7s ease-out; }
.shared .who { position: absolute; left: 50%; bottom: -4px; transform: translate(-50%, 100%); font-size: 13px; font-weight: 700; color: var(--amber); white-space: nowrap; pointer-events: none; z-index: 2; }
@keyframes flash { from { box-shadow: 0 0 0 4px var(--amber), 0 0 18px var(--amber); } to { box-shadow: 0 0 0 0 transparent; } }

/* Cards. */
.card { position: relative; width: var(--cw); height: var(--ch); border-radius: calc(var(--cw) * .1); background: var(--card); border: 1px solid var(--card-edge); color: var(--card-ink); box-shadow: 0 2px 4px rgba(0, 0, 0, .35); padding: 0; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; }
.card.red { color: var(--card-red); }
.card .corner { position: absolute; left: 6%; top: 4%; display: flex; flex-direction: column; align-items: center; line-height: 1; font-weight: 700; font-size: calc(var(--cw) * .3); }
.card .corner .s { font-family: var(--suit); font-size: .8em; margin-top: 1px; }
.card .pip { position: absolute; right: 8%; bottom: 6%; line-height: 1; font-family: var(--suit); font-size: calc(var(--cw) * .48); }
.card.back { background: repeating-linear-gradient(45deg, #9b443c 0 6px, var(--back) 6px 12px); border: 2px solid var(--ink); }
.card.mini { width: 30px; height: 42px; border-radius: 4px; cursor: default; box-shadow: none; }
.card.mini .corner { font-size: 13px; }
.card.mini .pip { font-size: 16px; }
.card.mini.out { background: transparent; border: 1.5px dashed var(--amber); color: var(--amber); font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.card.selected { outline: 3px solid var(--amber); outline-offset: 0; box-shadow: 0 0 0 5px var(--felt), 0 8px 16px rgba(0, 0, 0, .5); transform: translateY(-6px); z-index: 5; }
.target { outline: 3px solid var(--amber) !important; box-shadow: 0 0 14px var(--amber) !important; }
.slot.target { border-style: solid; border-color: var(--amber); }
.card.shake { animation: shake .4s; }
@keyframes shake { 20% { translate: -6px 0; } 40% { translate: 6px 0; } 60% { translate: -4px 0; } 80% { translate: 3px 0; } }
.card.landed { animation: land .25s ease-out; }
@keyframes land { from { scale: 1.12; } to { scale: 1; } }

/* Yours. */
.mine-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.my-pile { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.my-pile .ticks { grid-template-columns: repeat(13, 5px); }
.pile-stack { position: relative; width: calc(var(--cw) + 6px); height: calc(var(--ch) + 6px); }
.pile-stack .card { position: absolute; left: 0; top: 0; }
.pile-stack .under { left: 6px; top: 6px; cursor: default; }
.pile-stack .under2 { left: 3px; top: 3px; cursor: default; }
.count { position: absolute; right: -14px; top: -12px; z-index: 6; min-width: 36px; height: 36px; padding: 0 6px; border-radius: 18px; background: var(--amber); color: var(--amber-ink); font-size: 19px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 3px solid var(--felt-light); pointer-events: none; }
.count.empty { background: var(--ink); }
.stock-area { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.stock-row { display: flex; align-items: flex-end; gap: 10px; }
.stock { display: flex; align-items: center; justify-content: center; color: var(--ink); font-size: 15px; font-weight: 700; }
.stock.empty { background: transparent; border: 2px dashed var(--line-strong); color: var(--muted); font-size: 13px; }
.waste { position: relative; width: calc(var(--cw) * 1.6); height: var(--ch); }
.waste .card { position: absolute; top: 0; }
.work { flex: 1 1 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; min-height: var(--ch); }
.work-pile { position: relative; min-height: var(--ch); }
.work-pile .card { position: absolute; left: 0; top: calc(var(--i) * var(--fan, 26px)); }
.work-pile .space { width: var(--cw); height: var(--ch); border-radius: calc(var(--cw) * .1); border: 2px dashed var(--line-strong); display: flex; align-items: center; justify-content: center; text-align: center; font-size: 13px; color: var(--muted); padding: 0; background: transparent; }
.work-pile .space.target { color: var(--amber); font-weight: 700; }
.hint { position: relative; z-index: 0; margin: 0; min-height: 22px; font-size: 15px; line-height: 1.4; text-align: center; color: #e3eadf; }

.banner { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); padding: 14px 22px; border-radius: 12px; background: rgba(5, 20, 14, .92); border: 2px solid var(--amber); color: var(--ink); font-size: 20px; font-weight: 700; text-align: center; pointer-events: none; opacity: 0; transition: opacity .2s; z-index: 20; max-width: calc(100% - 32px); }
.banner.show { opacity: 1; }
.banner small { display: block; font-size: 15px; font-weight: 400; color: var(--muted); margin-top: 4px; }

/* The ghost card while dragging. */
.drag { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 50; }
.drag .card { position: absolute; left: 0; box-shadow: 0 12px 24px rgba(0, 0, 0, .55); }

/* Title and score screens. */
/* Centred by the panel's own margin, so a panel taller than the screen still scrolls from its top. */
.overlay { position: fixed; inset: 0; z-index: 30; display: flex; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); background: rgba(6, 26, 19, .86); overflow-y: auto; }
.panel { width: min(560px, 100%); display: grid; gap: 16px; padding: 24px; border-radius: 14px; background: var(--felt-dark); border: 2px solid var(--line); margin: auto; }
.panel h2 { margin: 0; font-size: clamp(28px, 7vw, 38px); line-height: 1.1; text-wrap: balance; }
.panel p { margin: 0; font-size: 17px; line-height: 1.5; color: #e3eadf; }
.choices { display: grid; gap: 12px; }
fieldset { margin: 0; padding: 0; border: 0; display: grid; gap: 6px; }
legend { padding: 0; margin-bottom: 6px; font-size: 14px; font-weight: 700; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.segmented { display: flex; gap: 8px; flex-wrap: wrap; }
#choose-speed { flex-wrap: nowrap; gap: 6px; }
#choose-speed button { padding: 0 4px; flex: 1 1 0; min-width: 0; font-size: 16px; }
.segmented button { flex: 1 1 auto; min-height: 48px; padding: 0 14px; border-radius: 10px; border: 2px solid var(--line-strong); background: transparent; font-size: 17px; font-weight: 700; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.primary-button { min-height: 56px; border: 0; border-radius: 12px; background: var(--amber); color: var(--amber-ink); font-size: 22px; font-weight: 700; cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 0 22px; }
.text-link { justify-self: center; min-height: 44px; border: 0; background: none; color: var(--amber); font-size: 17px; font-weight: 700; cursor: pointer; }
.how summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-size: 17px; font-weight: 700; color: var(--ink); }
#how-steps ul { margin: 0; padding-left: 20px; display: grid; gap: 10px; font-size: 17px; line-height: 1.45; color: #e3eadf; }
.how ul { margin: 4px 0 0; padding-left: 20px; display: grid; gap: 8px; font-size: 16px; line-height: 1.45; color: #e3eadf; }
.score-table-wrap { overflow-x: auto; }
.score-table { width: 100%; border-collapse: collapse; font-size: 16px; }
.score-table th { font-size: 13px; font-weight: 700; letter-spacing: .04em; color: var(--muted); text-align: right; padding: 6px; }
.score-table th:first-child, .score-table td:first-child { text-align: left; }
.score-table td { padding: 10px 6px; text-align: right; border-top: 1px solid var(--line); }
.score-table tr.me td { color: var(--amber); font-weight: 700; }
.score-table td.minus { color: #ff9b8a; }

/* A computer: the other players down the left, the middle above your cards. */
@media (min-width: 900px) and (min-height: 600px) {
  :root { --cw: 92px; }
  .wide-only { display: inline; }
  .table { grid-template-areas: 'others middle' 'others mine'; grid-template-columns: 240px 1fr; grid-template-rows: auto 1fr; gap: 0 24px; padding: 18px 24px 0; }
  .others { grid-template-columns: 1fr; align-content: start; gap: 12px; padding: 0; }
  .other { padding: 12px 14px; }
  .other .card.mini { width: 46px; height: 64px; }
  .other .card.mini .corner { font-size: 18px; } .other .card.mini .pip { font-size: 24px; }
  .other-name { font-size: 19px; } .other-left { font-size: 24px; } .other-score { font-size: 15px; }
  .ticks i { height: 10px; }
  .middle { padding: 0 0 16px; }
  /* As many to a row as fit, smaller than your own cards: on a wide screen all sixteen in one row. */
  .shared { grid-template-columns: repeat(auto-fill, 64px); justify-content: center; gap: 10px; padding: 12px; }
  .shared .card .corner { font-size: 18px; } .shared .card .pip { font-size: 26px; }
  .mine { flex-direction: row; flex-wrap: wrap; align-items: flex-start; align-content: flex-start; gap: 16px 28px; padding: 16px 20px; border: 2px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; }
  .mine-top { display: contents; }
  .my-pile { order: 1; }
  .mine > .label { display: none; }
  .work { order: 2; flex: 1 1 460px; align-self: stretch; min-height: var(--ch); }
  .stock-area { order: 3; }
  .hint { order: -1; flex-basis: 100%; text-align: left; }   /* Above your cards, where the piles never reach. */
  .scorebar { justify-content: center; gap: 32px; font-size: 15px; }
}

/* A small phone: the four speeds two to a row (after the rules above, so it wins). */
@media (max-width: 380px) { #choose-speed { flex-wrap: wrap; } #choose-speed button { flex: 1 1 40%; font-size: 16px; } }

.how-foot { display: grid; gap: 12px; }
/* How to play on a wide screen: a wide popup, the steps in two columns, so it fits without scrolling. */
@media (min-width: 900px) {
  #how-screen .panel { width: min(1040px, 100%); gap: 14px; padding: 28px 32px; }
  #how-steps ul { display: block; columns: 2; column-gap: 40px; padding-left: 20px; }
  #how-steps li { break-inside: avoid; margin-bottom: 12px; }
  #how-screen .primary-button { min-width: 320px; }
  .how-foot { display: flex; align-items: center; gap: 24px; }
}
