:root {
  --heart-navy: #681f35;
  --felt: #174d43;
  --felt-light: #22695b;
  --cream: #fffaf0;
  --gold: #e8b648;
  --coral: #d96955;
}

.hearts-shell { width: min(100%, 68rem); }
.hearts-shell .game-stage { place-items: stretch; touch-action: manipulation; }
.hearts-app { width: 100%; min-height: 0; display: grid; place-items: center; }
.hearts-app > [hidden] { display: none !important; }
.start-card, .queue-card {
  width: min(100%, 34rem);
  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: var(--heart-navy);
  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-hand { height: 4.4rem; margin-bottom: 1rem; display: flex; align-items: end; }
.mini-hand .playing-card {
  width: 3.3rem; height: 4.2rem; margin-right: -.75rem;
  border: 2px solid var(--heart-navy); font-size: 1rem;
  box-shadow: 2px 3px 0 rgba(23,50,77,.15); transform: rotate(-10deg);
}
.mini-hand .playing-card:nth-child(2) { transform: translateY(-.25rem) rotate(-3deg); }
.mini-hand .playing-card:nth-child(3) { transform: translateY(-.2rem) rotate(5deg); }
.mini-hand .playing-card:nth-child(4) { transform: rotate(12deg); }
.queue-card { text-align: center; }
.search-table {
  position: relative; width: 7rem; height: 7rem; margin: 0 auto 1rem;
  border: 2px dashed #9db5ac; border-radius: 50%;
  animation: queue-spin 7s linear infinite;
}
.search-table span, .search-table i, .search-table b, .search-table em {
  position: absolute; width: 1.75rem; height: 2.3rem;
  border: 2px solid var(--heart-navy); border-radius: 4px; background: white;
}
.search-table span { top: -.7rem; left: 2.5rem; }
.search-table i { top: 2.2rem; right: -.45rem; transform: rotate(90deg); }
.search-table b { bottom: -.7rem; left: 2.5rem; background: var(--gold); }
.search-table em { top: 2.2rem; left: -.45rem; transform: rotate(90deg); }
.search-table strong {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--heart-navy); font: 2rem/1 Georgia, serif;
}
@keyframes queue-spin { to { transform: rotate(360deg); } }

.bag-count { margin-left: .38rem; color: var(--muted); font-size: .62rem; font-weight: 800; }
.round-status { color: var(--muted); font-size: .78rem; font-weight: 800; text-align: center; }
.hearts-scorebar { grid-template-columns: repeat(4, 1fr); }
.hearts-scorebar .metric { text-align: center; }
.hearts-scorebar .metric-value { display: block; }
.table-wrap { width: 100%; height: 100%; min-height: 0; display: grid; grid-template-rows: auto 4px minmax(0, 1fr) auto auto; gap: .4rem; }
.turn-banner { min-height: 1.4rem; color: var(--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(--gold); transition: transform .1s linear, background .2s ease; }
.card-table {
  position: relative; min-height: 17rem; overflow: hidden;
  border: 3px solid #0d352e; border-radius: min(7vw, 34px);
  background:
    radial-gradient(circle at 50% 43%, rgba(255,255,255,.075), transparent 37%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.013) 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);
}
.card-table::after {
  content: ""; position: absolute; inset: 15%; pointer-events: none;
  border: 1px solid rgba(255,255,255,.08); border-radius: 50%;
}
.player-seat { position: absolute; z-index: 4; min-width: 6rem; 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 { display: block; max-width: 8rem; overflow: hidden; font-size: .68rem; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.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,.23); color: #dce9e5;
  font-size: .57rem; font-weight: 750; white-space: nowrap;
}
.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; flex: none;
  width: 1rem; height: 1rem; border-radius: 50%;
  background: var(--gold); color: var(--heart-navy);
  font-size: .55rem; font-style: normal; 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: 2;
  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, 2.7vw, 1.15rem); 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); }
.hearts-status {
  position: absolute; z-index: 4; top: 2.9rem; left: 50%; translate: -50% 0;
  padding: .22rem .5rem; border: 1px solid rgba(255,255,255,.14); border-radius: 99px;
  background: rgba(4,25,22,.55); color: #afc6be; font-size: .56rem; font-weight: 850;
  letter-spacing: .04em; white-space: nowrap;
}
.hearts-status.broken { color: #ffe18c; border-color: rgba(255,225,140,.32); }
.table-hud {
  position: absolute; z-index: 4; right: .6rem; bottom: .6rem;
  min-width: 8.2rem; padding: .46rem .55rem;
  border: 1px solid rgba(255,255,255,.2); border-radius: 10px;
  background: rgba(5,29,24,.8); color: white;
  box-shadow: 0 3px 12px rgba(0,0,0,.16); backdrop-filter: blur(4px);
}
.table-hud-label {
  display: block; margin-bottom: .24rem; color: #b9d0c8;
  font-size: .52rem; font-weight: 900; letter-spacing: .13em; text-transform: uppercase;
}
.trick-score { display: flex; align-items: baseline; justify-content: space-between; gap: .7rem; color: #e8f0ed; font-size: .57rem; font-weight: 750; }
.trick-score + .trick-score { margin-top: .12rem; }
.trick-score strong { color: white; font-size: .8rem; }
.trick-score i { font-style: normal; }
.point-row { display: flex; align-items: baseline; justify-content: space-between; gap: .7rem; color: #e8f0ed; font-size: .57rem; font-weight: 750; }
.point-row + .point-row { margin-top: .12rem; }
.point-row strong { color: white; font-size: .8rem; }
.pass-actions { min-height: 3rem; display: flex; align-items: center; justify-content: center; gap: .7rem; }
.pass-label { color: var(--muted); font-size: .66rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.pass-actions .action-button { min-width: 7rem; min-height: 2.65rem; padding: .4rem .8rem; font-size: .78rem; }
.bid-actions { min-height: 3rem; display: flex; align-items: center; justify-content: center; gap: .7rem; }
.bid-label { color: var(--muted); font-size: .66rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.bid-controls { display: flex; align-items: center; justify-content: center; gap: .35rem; }
.bid-actions .action-button { min-width: 0; min-height: 2.65rem; padding: .4rem .68rem; font-size: .78rem; }
.bid-actions .bid-step { width: 2.65rem; padding: 0; font-size: 1.1rem; }
.bid-value { min-width: 2.4rem; color: var(--heart-navy); font: 900 1.15rem/1 Georgia, serif; text-align: center; }
.bid-actions .bid-submit { min-width: 5.4rem; }
.hand {
  min-height: clamp(5rem, 18vw, 7.2rem);
  display: flex; align-items: end; justify-content: center;
  padding: 0 .15rem .15rem;
}
.hand-card {
  flex: none; width: clamp(3.35rem, 9vw, 5rem); margin: 0;
  border: 2px solid var(--heart-navy); border-radius: 9px;
  box-shadow: 3px 4px 0 rgba(23,50,77,.18);
  font-size: clamp(.92rem, 3vw, 1.32rem);
  transition: filter .15s ease, box-shadow .15s ease, transform .15s ease;
}
.hand-card + .hand-card { margin-left: clamp(-2.9rem, -5vw, -1.85rem); }
.hand-card:not(:disabled) { cursor: pointer; }
.hand-card:not(:disabled):hover { z-index: 30; box-shadow: 3px 5px 0 rgba(23,50,77,.28); transform: translateY(-5px); }
.hand-card:not(:disabled):focus-visible { z-index: 40; outline: 3px solid var(--gold); outline-offset: 2px; }
.hand-card:disabled { filter: none; }
.hand-card.selected-pass {
  z-index: 25;
  outline: 3px solid var(--coral);
  outline-offset: -1px;
  box-shadow: 3px 7px 0 rgba(104,31,53,.28);
  transform: translateY(-9px);
}

.rules-dialog {
  width: min(calc(100% - 2rem), 32rem); max-height: calc(100dvh - 2rem); padding: 0;
  border: 2px solid var(--heart-navy); 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: var(--heart-navy); font-size: 1.5rem; cursor: pointer; }

@media (max-height: 760px) {
  .table-wrap { gap: .25rem; }
  .card-table { min-height: 12rem; }
  .turn-banner { min-height: 1.1rem; font-size: .72rem; }
  .hand { min-height: 4.7rem; }
  .bid-actions { min-height: 2.7rem; }
  .bid-actions .action-button { min-height: 2.4rem; }
}
@media (max-height: 620px) and (orientation: landscape) {
  .hearts-shell { width: min(100%, 72rem); }
  .hearts-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(3rem, 6.5vw, 4.1rem); }
  .hand-card + .hand-card { margin-left: clamp(-2.35rem, -3.8vw, -1.55rem); }
}
@media (max-width: 520px) {
  .start-card, .queue-card { padding: 1.15rem; }
  .start-actions, .queue-actions { flex-direction: column; }
  .card-table { border-radius: 18px; }
  .player-seat.left { left: .22rem; }
  .player-seat.right { right: .22rem; }
  .seat-name { max-width: 6.2rem; font-size: .62rem; }
  .seat-meta { padding-inline: .25rem; font-size: .51rem; }
  .table-hud { right: .38rem; bottom: .38rem; min-width: 7.4rem; padding: .38rem .42rem; }
  .bag-count { display: block; margin: .06rem 0 0; }
  .bid-label { display: none; }
  .hearts-scorebar .metric-label { font-size: .56rem; }
  .hearts-scorebar .metric-value { font-size: 1rem; }
  .pass-label { font-size: .57rem; }
}
@media (max-width: 350px) {
  .player-seat { min-width: 5rem; }
  .seat-name { max-width: 5rem; }
  .seat-meta { font-size: .47rem; }
  .table-hud { min-width: 6.8rem; }
  .trick-score { gap: .3rem; font-size: .52rem; }
  .bid-actions .action-button { padding-inline: .5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .search-table { animation: none; }
  .table-card { will-change: auto; }
}
