:root {
  --felt: #123f36;
  --felt-light: #1c5a4d;
  --cream: #fffaf0;
  --gold: #e8b648;
  --red: #b93c43;
}

.euchre-shell { width: min(100%, 58rem); }
.euchre-shell .game-stage { place-items: stretch; touch-action: manipulation; }
.euchre-app { width: 100%; min-height: 0; display: grid; place-items: center; }
.euchre-app > [hidden] { display: none !important; }
.start-card, .queue-card {
  width: min(100%, 32rem);
  padding: clamp(1.25rem, 4vw, 2.25rem);
  border: 1px solid #c9c0b2;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 8px 9px 0 #e8dfcf;
  text-align: left;
}
.start-card h2, .queue-card h2, .rules-dialog h2 {
  margin: .2rem 0 .8rem;
  color: #17324d;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 8vw, 3rem);
  line-height: .98;
  letter-spacing: -.035em;
}
.start-card > p:not(.eyebrow), .queue-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.55; }
.eyebrow { margin: 0 0 .7rem; color: var(--accent-2); 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-trick { height: 4.1rem; margin-bottom: 1rem; display: flex; align-items: end; }
.mini-trick .playing-card { width: 3.25rem; height: 4rem; margin-right: -.7rem; border: 2px solid #17324d; font-size: 1rem; box-shadow: 2px 3px 0 rgba(23,50,77,.15); transform: rotate(-8deg); }
.mini-trick .playing-card:nth-child(2) { transform: translateY(-.25rem) rotate(2deg); }
.mini-trick .playing-card:nth-child(3) { transform: rotate(10deg); }
.queue-card { text-align: center; }
.search-orbit { position: relative; width: 6.5rem; height: 6.5rem; margin: 0 auto 1rem; border: 2px dashed #9db5ac; border-radius: 50%; animation: queue-spin 7s linear infinite; }
.search-orbit span, .search-orbit i, .search-orbit b, .search-orbit em { position: absolute; width: 1.7rem; height: 2.25rem; border: 2px solid #17324d; border-radius: 4px; background: white; }
.search-orbit span { top: -.7rem; left: 2.25rem; }
.search-orbit i { top: 2.1rem; right: -.45rem; }
.search-orbit b { bottom: -.7rem; left: 2.25rem; background: var(--gold); }
.search-orbit em { top: 2.1rem; left: -.45rem; }
@keyframes queue-spin { to { transform: rotate(360deg); } }

.round-status { color: var(--muted); font-size: .78rem; font-weight: 800; text-align: center; }
.table-wrap { width: 100%; height: 100%; min-height: 0; display: grid; grid-template-rows: auto 4px minmax(0, 1fr) auto auto; gap: .45rem; }
.turn-banner { min-height: 1.45rem; color: var(--felt); font-size: .84rem; 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(--gold); transition: transform .1s linear, background .2s ease; }
.card-table {
  position: relative; min-height: 16rem; overflow: hidden;
  border: 3px solid #0b3129; border-radius: min(8vw, 32px);
  background:
    radial-gradient(circle at 50% 45%, rgba(255,255,255,.07), transparent 37%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.012) 0 2px, transparent 2px 6px),
    var(--felt);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.05), 5px 6px 0 rgba(23,50,77,.15);
}
.player-seat { position: absolute; z-index: 2; min-width: 5rem; color: white; text-align: center; }
.player-seat.partner { top: .55rem; left: 50%; translate: -50% 0; }
.player-seat.left { left: .55rem; top: 50%; translate: 0 -50%; }
.player-seat.right { right: .55rem; top: 50%; translate: 0 -50%; }
.player-seat.you { bottom: .55rem; left: 50%; translate: -50% 0; }
.seat-name { display: block; max-width: 7rem; overflow: hidden; font-size: .68rem; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.seat-meta { display: inline-flex; align-items: center; gap: .2rem; margin-top: .15rem; padding: .13rem .35rem; border-radius: 99px; background: rgba(0,0,0,.2); color: #dce9e5; font-size: .58rem; }
.player-seat.active .seat-name { color: #ffe18c; text-shadow: 0 0 14px rgba(255,225,140,.7); }
.dealer-dot { display: inline-grid; place-items: center; width: 1rem; height: 1rem; border-radius: 50%; background: var(--gold); color: #17324d; font-size: .55rem; font-weight: 950; }
.trick-area {
  --trick-x: clamp(3.25rem, 10vw, 4.25rem);
  --trick-y: clamp(3.25rem, 10vw, 4.25rem);
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
}
.table-card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: clamp(2.35rem, 6vw, 3.2rem);
  border: 2px solid #d7d0c4;
  border-radius: 7px;
  font-size: clamp(.82rem, 3vw, 1.1rem);
  box-shadow: 2px 3px 0 rgba(0,0,0,.24);
  will-change: translate, scale, opacity;
}
.table-card.pos-0 { transform: translate(-50%, calc(-50% + var(--trick-y))) rotate(2deg); }
.table-card.pos-1 { transform: translate(calc(-50% - var(--trick-x)), -50%) rotate(88deg); }
.table-card.pos-2 { transform: translate(-50%, calc(-50% - var(--trick-y))) rotate(-2deg); }
.table-card.pos-3 { transform: translate(calc(-50% + var(--trick-x)), -50%) rotate(-88deg); }
.upcard-area { position: absolute; left: 50%; top: 49%; translate: -50% -50%; color: white; text-align: center; }
.upcard-area .table-card { position: relative; display: inline-block; }
.upcard-label { display: block; margin-bottom: .25rem; color: #dce9e5; font-size: .58rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.table-hud {
  position: absolute;
  z-index: 3;
  bottom: .65rem;
  min-width: 6.7rem;
  padding: .48rem .58rem;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 10px;
  background: rgba(5,29,24,.78);
  color: white;
  box-shadow: 0 3px 12px rgba(0,0,0,.16);
  backdrop-filter: blur(4px);
}
.table-hud[hidden] { display: none; }
.table-hud-label {
  display: block;
  margin-bottom: .25rem;
  color: #b9d0c8;
  font-size: .54rem;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.trump-hud { left: .65rem; }
.trump-suit {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  line-height: 1;
}
.trump-suit.red { color: #ff9298; }
.trump-caller { display: block; margin-top: .22rem; color: #e8f0ed; font-size: .6rem; font-weight: 750; }
.tricks-hud { right: .65rem; }
.trick-score { display: flex; align-items: baseline; justify-content: space-between; gap: .65rem; color: #e8f0ed; font-size: .58rem; font-weight: 750; }
.trick-score + .trick-score { margin-top: .12rem; }
.trick-score strong { color: white; font-size: .82rem; }
.bid-actions { min-height: 2.7rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .4rem; }
.bid-actions .action-button { min-width: 0; min-height: 2.55rem; padding: .45rem .72rem; font-size: .78rem; }
.alone-toggle { display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .5rem; color: var(--muted); font-size: .72rem; font-weight: 800; }
.alone-toggle input { width: 1.05rem; height: 1.05rem; accent-color: var(--felt); }
.hand { min-height: clamp(5.4rem, 20vw, 7rem); display: flex; align-items: end; justify-content: center; gap: clamp(.08rem, .65vw, .32rem); padding: 0 .35rem .15rem; }
.hand-card {
  width: clamp(3.45rem, 14vw, 5.1rem); margin: 0;
  border: 2px solid #17324d; border-radius: 9px;
  box-shadow: 3px 4px 0 rgba(23,50,77,.18); font-size: clamp(1rem, 4vw, 1.35rem);
  transition: filter .15s ease, box-shadow .15s ease;
}
.hand-card:not(:disabled) { cursor: pointer; }
.hand-card:not(:disabled):hover { box-shadow: 3px 5px 0 rgba(23,50,77,.28); }
.hand-card:not(:disabled):focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.hand-card:disabled { filter: none; }

.rules-dialog { width: min(calc(100% - 2rem), 31rem); max-height: calc(100dvh - 2rem); padding: 0; border: 2px solid #17324d; border-radius: 14px; background: var(--panel); color: var(--text); box-shadow: 8px 9px 0 rgba(0,0,0,.2); }
.rules-dialog::backdrop { background: rgba(16,38,58,.72); backdrop-filter: blur(5px); }
.rules-dialog form { padding: 1.5rem; }
.rules-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: #17324d; font-size: 1.5rem; cursor: pointer; }

@media (max-height: 760px) {
  .table-wrap { gap: .28rem; }
  .card-table { min-height: 12rem; }
  .turn-banner { min-height: 1.1rem; font-size: .73rem; }
  .hand { min-height: 4.7rem; }
}
@media (max-height: 620px) and (orientation: landscape) {
  .euchre-shell { width: min(100%, 64rem); }
  .euchre-shell .scorebar { grid-column: 1; }
  .table-wrap { grid-template-rows: auto 3px minmax(0, 1fr) auto auto; }
  .card-table { min-height: 10rem; }
  .hand { min-height: 4rem; }
  .hand-card { width: clamp(3.2rem, 8vw, 4.3rem); }
}
@media (max-width: 420px) {
  .start-card, .queue-card { padding: 1.15rem; }
  .start-actions, .queue-actions { flex-direction: column; }
  .card-table { border-radius: 18px; }
  .player-seat.left { left: .25rem; }
  .player-seat.right { right: .25rem; }
  .seat-name { max-width: 5.5rem; }
  .hand { padding-inline: .2rem; }
  .table-hud { bottom: .45rem; min-width: 5.9rem; padding: .4rem .45rem; }
  .trump-hud { left: .4rem; }
  .tricks-hud { right: .4rem; }
  .trump-suit { font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .search-orbit { animation: none; }
  .table-card { will-change: auto; }
}
