:root {
  --goon-ink: #17283d;
  --goon-paper: #fffaf0;
  --goon-felt: #183d42;
  --goon-orange: #e97824;
  --goon-purple: #7251a6;
  --goon-brown: #8a5a3b;
  --goon-grey: #737b85;
  --goon-accent: #e6ad32;
}

.goon-shell { width: min(100%, 68rem); }
.goon-shell .game-stage { place-items: stretch; touch-action: manipulation; }
.goon-app { width: 100%; min-height: 0; display: grid; place-items: center; }
.goon-app > [hidden] { display: none !important; }
.start-card, .queue-card {
  width: min(100%, 34rem);
  padding: clamp(1.25rem, 4vw, 2.25rem);
  border: 2px solid var(--goon-ink);
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 12px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px), 0 12px);
  background: var(--panel);
  box-shadow: 8px 9px 0 #dcd1c0;
  text-align: left;
}
.start-card h2, .queue-card h2, .rules-dialog h2, .hue-dialog h2 {
  margin: .2rem 0 .8rem;
  color: var(--goon-ink);
  font: 900 clamp(2rem, 8vw, 3.1rem)/.92 "Avenir Next", Avenir, "Segoe UI", sans-serif;
  letter-spacing: -.06em;
  text-transform: lowercase;
}
.start-card > p:not(.eyebrow), .queue-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.55; }
.eyebrow { margin: 0 0 .7rem; color: var(--goon-purple); font-size: .69rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.start-actions, .queue-actions { display: flex; gap: .65rem; }
.start-actions .action-button, .queue-actions .action-button { flex: 1; }
.no-account { margin: 1rem 0 0; font-size: .78rem; }
.mini-rack { height: 4.7rem; margin-bottom: 1rem; display: flex; align-items: end; }
.mini-rack .goon-card { width: 3.25rem; height: 4.5rem; margin-right: -.65rem; transform: rotate(-10deg); }
.mini-rack .goon-card:nth-child(2) { transform: translateY(-.2rem) rotate(-3deg); }
.mini-rack .goon-card:nth-child(3) { transform: translateY(-.15rem) rotate(5deg); }
.mini-rack .goon-card:nth-child(4) { transform: rotate(12deg); }
.queue-card { text-align: center; }
.search-mark {
  position: relative; width: 7rem; aspect-ratio: 1; margin: 0 auto 1rem;
  display: grid; place-items: center;
  border: 2px dashed #88a9aa; border-radius: 50%;
  animation: search-spin 7s linear infinite;
}
.search-mark i { position: absolute; width: 1.25rem; aspect-ratio: 1; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.search-mark i:nth-child(1) { top: -.2rem; background: var(--goon-orange); }
.search-mark i:nth-child(2) { right: -.2rem; background: var(--goon-purple); }
.search-mark i:nth-child(3) { bottom: -.2rem; background: var(--goon-brown); }
.search-mark i:nth-child(4) { left: -.2rem; background: var(--goon-grey); }
.search-mark b { color: var(--goon-ink); font: 950 2.6rem/1 "Avenir Next", sans-serif; }
@keyframes search-spin { to { transform: rotate(360deg); } }

.goon-scorebar { grid-template-columns: repeat(4, 1fr); }
.goon-scorebar .metric { text-align: center; }
.goon-scorebar .metric-value { display: block; }
.table-wrap { width: 100%; height: 100%; min-width: 0; min-height: 0; display: grid; grid-template-rows: auto 4px minmax(0, 1fr) auto auto auto; gap: .36rem; }
.turn-banner { min-height: 1.4rem; color: var(--goon-felt); font-size: .83rem; font-weight: 850; text-align: center; }
.turn-meter { height: 4px; overflow: hidden; border-radius: 10px; background: #d8d0c3; }
.turn-meter span { display: block; width: 100%; height: 100%; transform-origin: left; background: var(--goon-accent); transition: transform .1s linear, background .2s ease; }
.goon-table {
  position: relative; width: 100%; min-width: 0; min-height: 17rem; overflow: hidden;
  border: 3px solid #0c2c30; border-radius: min(7vw, 34px);
  background:
    radial-gradient(circle at 50% 44%, rgba(255,255,255,.085), transparent 34%),
    repeating-radial-gradient(circle at 50% 44%, transparent 0 20px, rgba(255,255,255,.018) 21px 23px),
    var(--goon-felt);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.05), 5px 6px 0 rgba(23,40,61,.15);
}
.goon-table::after { content: ""; position: absolute; inset: 16%; pointer-events: none; border: 1px solid rgba(255,255,255,.09); clip-path: polygon(14% 0,86% 0,100% 14%,100% 86%,86% 100%,14% 100%,0 86%,0 14%); }
.player-seat {
  position: absolute; z-index: 5; min-width: 6rem;
  display: flex; flex-direction: column; align-items: center;
  color: white; text-align: center;
}
.player-seat.partner { top: .5rem; left: 50%; translate: -50% 0; }
.player-seat.left { left: .5rem; top: 49%; translate: 0 -50%; }
.player-seat.right { right: .5rem; top: 49%; translate: 0 -50%; }
.player-seat.you { bottom: .5rem; left: 50%; translate: -50% 0; }
.seat-name { max-width: 6.8rem; display: inline-flex; align-items: center; flex-direction: column; gap: .12rem; font-size: clamp(.52rem, 2.4vw, .58rem); font-weight: 900; }
.seat-player-name { max-width: 100%; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-avatar { width: 1.7rem; height: 1.7rem; flex: none; border: 1px solid rgba(255,255,255,.75); border-radius: 50%; object-fit: cover; transition: width .25s ease, height .25s ease; }
.seat-meta {
  min-height: 1.2rem; margin-top: .15rem; padding: .14rem .38rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .25rem;
  border-radius: 99px; background: rgba(0,0,0,.25); color: #e1eeee;
  font-size: .57rem; font-weight: 750; white-space: nowrap;
}
.player-seat.active .seat-name { color: #ffe08b; text-shadow: 0 0 14px rgba(255,224,139,.72); }
.player-seat.active .seat-avatar { width: 2.15rem; height: 2.15rem; animation: active-seat-pulse 2.4s ease-in-out infinite; }
@keyframes active-seat-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,224,139,.15); }
  50% { transform: scale(1.12); box-shadow: 0 0 0 .28rem rgba(255,224,139,.22); }
}
.dealer-dot { display: inline-grid; place-items: center; width: 1rem; height: 1rem; border-radius: 50%; background: var(--goon-accent); color: var(--goon-ink); font-size: .55rem; font-style: normal; font-weight: 950; }
.route-mark {
  position: absolute; z-index: 3; top: 3rem; left: 50%; translate: -50% 0;
  width: 2.1rem; height: 1.25rem; opacity: .78;
  border: 2px dotted #d8eeee; border-top-color: transparent; border-radius: 50%;
}
.route-mark::after { content: ""; position: absolute; right: -.16rem; bottom: -.18rem; width: .45rem; aspect-ratio: 1; background: #d8eeee; clip-path: polygon(0 0,100% 50%,0 100%); }
.route-mark.reverse { scale: -1 1; }
.pile-zone { position: absolute; z-index: 4; top: 50%; left: 50%; translate: -50% -50%; display: flex; align-items: center; gap: clamp(.55rem, 3vw, 1.15rem); }
.draw-pile, .discard-slot .goon-card { width: clamp(3.55rem, 10vw, 4.8rem); }
.draw-pile { border: 0; font: inherit; cursor: pointer; }
.draw-pile:disabled { cursor: default; filter: grayscale(.15); }
.draw-pile small { position: absolute; right: .25rem; bottom: .2rem; min-width: 1.2rem; padding: .08rem .25rem; border-radius: 99px; background: var(--goon-paper); color: var(--goon-ink); font-size: .55rem; }
.hue-chip {
  position: absolute; z-index: 4; top: calc(50% - 4rem); left: 50%; translate: -50% 0;
  padding: .2rem .55rem; border: 1px solid rgba(255,255,255,.25); border-radius: 99px;
  background: rgba(5,29,31,.72); color: white; font-size: .56rem; font-weight: 900; letter-spacing: .05em; text-transform: uppercase;
}
.hue-chip::before { content: ""; width: .52rem; height: .52rem; margin-right: .32rem; display: inline-block; border-radius: 50%; background: var(--active-hue); vertical-align: -.02rem; }

.goon-card {
  --card-hue: var(--goon-ink);
  position: relative; aspect-ratio: .69; overflow: hidden; flex: none;
  padding: 0; border: 2px solid var(--goon-ink);
  clip-path: polygon(10% 0,90% 0,100% 8%,100% 92%,90% 100%,10% 100%,0 92%,0 8%);
  background:
    linear-gradient(145deg, rgba(255,255,255,.2) 0 17%, transparent 17% 80%, rgba(0,0,0,.08) 80%),
    var(--card-hue);
  color: var(--goon-paper);
  box-shadow: 3px 4px 0 rgba(0,0,0,.22);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}
.goon-card.color-c { --card-hue: var(--goon-orange); }
.goon-card.color-t { --card-hue: var(--goon-purple); }
.goon-card.color-g { --card-hue: var(--goon-brown); }
.goon-card.color-v { --card-hue: var(--goon-grey); }
.goon-card.color-prism {
  background:
    linear-gradient(145deg, rgba(255,255,255,.18) 0 16%, transparent 16% 82%, rgba(0,0,0,.12) 82%),
    conic-gradient(from 45deg, var(--goon-orange) 0 25%, var(--goon-purple) 0 50%, var(--goon-brown) 0 75%, var(--goon-grey) 0);
}
.card-back {
  display: grid; place-items: center;
  background:
    linear-gradient(45deg, transparent 42%, rgba(255,255,255,.12) 43% 48%, transparent 49% 92%, rgba(255,255,255,.12) 93%),
    linear-gradient(-45deg, #17283d 0 46%, #29415d 47% 53%, #17283d 54%);
}
.card-back > span { width: 58%; aspect-ratio: 1; display: grid; place-items: center; border: 2px solid var(--goon-accent); rotate: 45deg; color: white; font-size: 1.65rem; font-weight: 950; }
.card-back > span::first-letter { rotate: -45deg; }
.card-corner { position: absolute; z-index: 2; left: .22em; top: .24em; display: grid; justify-items: center; color: currentColor; font-size: .62em; font-weight: 950; line-height: .95; text-shadow: 0 1px 1px rgba(0,0,0,.22); }
.card-corner.bottom { left: auto; top: auto; right: .22em; bottom: .24em; rotate: 180deg; }
.corner-dot { width: .42em; aspect-ratio: 1; margin-top: .12em; border: 1px solid currentColor; border-radius: 50%; background: rgba(255,255,255,.3); }
.card-center {
  position: absolute; inset: 20% 13%; display: grid; place-items: center;
  border: 2px solid currentColor;
  clip-path: polygon(50% 0,100% 25%,100% 75%,50% 100%,0 75%,0 25%);
  background: rgba(255,250,240,.9); color: var(--goon-ink);
}
.number-mark { font-size: 2.15em; font-weight: 950; line-height: 1; }
.action-mark { position: relative; width: 68%; aspect-ratio: 1; display: block; }
.mark-block { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 8%; }
.mark-block::before, .mark-block::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, var(--goon-ink) 0 22%, transparent 22% 37%); }
.mark-block::after { background: repeating-linear-gradient(90deg, transparent 0 25%, var(--goon-ink) 25% 35%, transparent 35% 65%); opacity: .8; }
.mark-spin { border: .12em solid var(--goon-ink); border-right-color: transparent; border-radius: 50%; }
.mark-spin::before, .mark-spin::after { content: ""; position: absolute; width: 25%; aspect-ratio: 1; border-radius: 50%; background: var(--goon-ink); }
.mark-spin::before { top: 8%; right: 4%; }
.mark-spin::after { bottom: 8%; left: 4%; }
.mark-haul2::before, .mark-haul2::after {
  content: ""; position: absolute; width: 50%; height: 56%; top: 20%;
  border: .12em solid var(--goon-ink); border-radius: 42% 42% 20% 20%;
  background: repeating-linear-gradient(135deg, transparent 0 18%, rgba(23,40,61,.22) 19% 25%);
}
.mark-haul2::before { left: 1%; rotate: -8deg; }
.mark-haul2::after { right: 1%; rotate: 8deg; }
.mark-prism { rotate: 45deg; background: conic-gradient(var(--goon-orange) 0 25%, var(--goon-purple) 0 50%, var(--goon-brown) 0 75%, var(--goon-grey) 0); box-shadow: inset 0 0 0 .12em var(--goon-ink); }
.mark-prism::after { content: ""; position: absolute; inset: 28%; background: var(--goon-paper); }
.mark-prism4::before { content: "+4"; position: absolute; z-index: 2; inset: 0; display: grid; place-items: center; color: var(--goon-ink); font-size: 1.1em; font-weight: 950; }
.action-caption { position: absolute; left: 50%; bottom: 5%; translate: -50% 0; font-size: .38em; font-weight: 950; letter-spacing: .06em; text-transform: uppercase; }

.hand { width: 100%; min-width: 0; min-height: clamp(5rem, 18vw, 7.2rem); display: flex; align-items: end; justify-content: center; padding: 0 .15rem .15rem; }
.hand-card { width: clamp(3.25rem, 9vw, 4.8rem); margin: 0; font-size: clamp(.92rem, 3vw, 1.28rem); transition: filter .15s ease, box-shadow .15s ease, transform .15s ease; }
.hand-card + .hand-card { margin-left: clamp(-2.75rem, -4.7vw, -1.7rem); }
.hand-card:not(:disabled) { cursor: pointer; }
.hand-card:not(:disabled):hover { z-index: 30; box-shadow: 3px 6px 0 rgba(23,40,61,.3); transform: translateY(-6px); }
.hand-card:not(:disabled):focus-visible { z-index: 40; outline: 3px solid var(--goon-accent); outline-offset: 2px; }
.hand-card:disabled { filter: saturate(.55) brightness(.9); }
.hand-card.drawn { z-index: 20; outline: 3px solid var(--goon-paper); outline-offset: -5px; transform: translateY(-5px); }
.table-actions { min-height: 2.8rem; display: flex; align-items: center; justify-content: center; gap: .5rem; }
.table-actions .action-button { min-height: 2.5rem; padding: .45rem .75rem; font-size: .74rem; }
.call-toggle {
  justify-self: center; min-height: 2rem; padding: .34rem .7rem;
  border: 2px solid var(--goon-orange); clip-path: polygon(8px 0,calc(100% - 8px) 0,100% 8px,100% calc(100% - 8px),calc(100% - 8px) 100%,8px 100%,0 calc(100% - 8px),0 8px);
  background: var(--goon-paper); color: var(--goon-ink); font: 900 .68rem/1 inherit; cursor: pointer;
}
.call-toggle[aria-pressed="true"] { background: var(--goon-orange); color: white; animation: call-pulse .8s ease-in-out infinite alternate; }
@keyframes call-pulse { to { transform: scale(1.05); } }

.rules-dialog, .hue-dialog {
  width: min(calc(100% - 2rem), 32rem); max-height: calc(100dvh - 2rem); padding: 0;
  border: 2px solid var(--goon-ink); border-radius: 0;
  clip-path: polygon(12px 0,calc(100% - 12px) 0,100% 12px,100% calc(100% - 12px),calc(100% - 12px) 100%,12px 100%,0 calc(100% - 12px),0 12px);
  background: var(--panel); color: var(--text); box-shadow: 8px 9px 0 rgba(0,0,0,.2);
}
.rules-dialog::backdrop, .hue-dialog::backdrop { background: rgba(12,30,45,.75); backdrop-filter: blur(5px); }
.rules-dialog form, .hue-dialog form { padding: 1.5rem; }
.rules-dialog h2, .hue-dialog h2 { font-size: 2rem; }
.rules-dialog ol { padding-left: 1.25rem; }
.rules-dialog li, .rules-dialog p { margin-bottom: .7rem; color: var(--muted); line-height: 1.48; }
.dialog-close { float: right; width: 2.5rem; height: 2.5rem; border: 0; border-radius: 50%; background: #ece5d9; color: var(--goon-ink); font-size: 1.5rem; cursor: pointer; }
.hue-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: 1rem 0; }
.hue-grid button { min-height: 3.3rem; display: flex; align-items: center; gap: .6rem; border: 1px solid #bfb6aa; background: var(--goon-paper); color: var(--goon-ink); font: 850 .8rem/1 inherit; cursor: pointer; }
.hue-grid span { width: 1.5rem; aspect-ratio: 1; clip-path: polygon(50% 0,100% 50%,50% 100%,0 50%); }
.hue-grid [data-hue="c"] span { background: var(--goon-orange); }
.hue-grid [data-hue="t"] span { background: var(--goon-purple); }
.hue-grid [data-hue="g"] span { background: var(--goon-brown); }
.hue-grid [data-hue="v"] span { background: var(--goon-grey); }

@media (max-height: 760px) {
  .table-wrap { gap: .24rem; }
  .goon-table { min-height: 12rem; }
  .turn-banner { min-height: 1.1rem; font-size: .72rem; }
  .hand { min-height: 4.7rem; }
  .table-actions { min-height: 2.4rem; }
}
@media (max-height: 620px) and (orientation: landscape) {
  .goon-shell { width: min(100%, 72rem); }
  .goon-shell .scorebar { grid-column: 1; }
  .goon-table { min-height: 10rem; }
  .hand { min-height: 4rem; }
  .hand-card { width: clamp(3rem, 6.5vw, 4rem); }
  .hand-card + .hand-card { margin-left: clamp(-2.3rem, -3.8vw, -1.5rem); }
  .start-card { height: 100%; padding: .55rem .7rem; display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); grid-template-rows: auto auto minmax(0,1fr) auto auto; align-items: center; gap: .15rem .65rem; }
  .start-card > :not(.mini-rack) { grid-column: 2; }
  .start-card .mini-rack { grid-column: 1; grid-row: 1 / -1; height: auto; margin: 0; justify-self: center; }
  .start-card .eyebrow, .start-card h2, .start-card > p { margin: 0; }
  .start-card h2 { font-size: 1.55rem; }
  .start-card > p:not(.eyebrow) { font-size: .7rem; line-height: 1.3; }
  .start-card .start-actions { gap: .4rem; }
  .start-card .action-button { min-height: 2.35rem; padding: .35rem .45rem; font-size: .7rem; }
  .start-card .no-account { display: none; }
}
@media (max-width: 520px) {
  .start-card, .queue-card { padding: 1.15rem; }
  .start-actions, .queue-actions { flex-direction: column; }
  .goon-table { border-radius: 18px; }
  .player-seat.left { left: .22rem; }
  .player-seat.right { right: .22rem; }
  .player-seat.you { left: 43%; }
  .seat-name { font-size: .54rem; }
  .seat-meta { padding-inline: .25rem; font-size: .51rem; }
  .goon-scorebar .metric-label { font-size: .56rem; }
  .goon-scorebar .metric-value { font-size: 1rem; }
}
@media (max-height: 300px) and (orientation: landscape) {
  .start-card { grid-template-columns: 5.5rem minmax(0,1fr); padding: .35rem .5rem; gap: .08rem .4rem; }
  .start-card h2 { font-size: 1.22rem; }
  .start-card > p:not(.eyebrow) { font-size: .6rem; line-height: 1.2; }
  .start-card .eyebrow { font-size: .55rem; }
  .start-card .start-actions { gap: .2rem; }
  .start-card .action-button { min-height: 2rem; padding: .25rem .12rem; font-size: .56rem; }
}
@media (prefers-reduced-motion: reduce) {
  .search-mark, .player-seat.active .seat-avatar, .call-toggle[aria-pressed="true"] { animation: none; }
}
@media (max-height: 620px) and (orientation: landscape) {
  .queue-card { height: 100%; padding: .5rem .7rem; display: grid; grid-template-columns: 6rem minmax(0, 1fr); grid-template-rows: auto auto auto auto; align-content: center; gap: .1rem .6rem; overflow: hidden; }
  .queue-card > * { grid-column: 2; margin-block: .08rem; }
  .queue-card > :first-child { grid-column: 1; grid-row: 1 / -1; margin: auto; scale: .62; }
  .queue-card h2 { font-size: 1.45rem; }
  .queue-card > p:not(.eyebrow) { font-size: .7rem; line-height: 1.25; }
  .queue-card .action-button { min-height: 2.25rem; padding: .3rem .45rem; font-size: .7rem; }
  .rules-dialog form { max-height: calc(100dvh - 2rem); overflow: auto; }
  .rules-dialog form > .action-button:last-child { position: sticky; bottom: 0; }
}
