:root {
  color-scheme: dark;
  font-family: "Outfit", system-ui, sans-serif;
  --vh: 1vh;
  --card-w: clamp(74px, 8vw, 132px);
  --card-h: calc(var(--card-w) * 1.4);
  --gold: #fbbf24;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow: hidden; }
body { min-height: 100dvh; color: #fff; background: #03130d; }
html:fullscreen, html:fullscreen body, html:-webkit-full-screen, html:-webkit-full-screen body { width: 100%; height: 100%; }
button, input { font: inherit; }
button { touch-action: manipulation; }
.game-shell { height: calc(var(--vh) * 100); min-height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; background: #03130d; }

.game-header { position: relative; z-index: 20; min-height: 66px; padding: max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 12px; background: linear-gradient(180deg, #071d35, #041526); border-bottom: 1px solid rgb(255 255 255 / 12%); box-shadow: 0 8px 30px rgb(0 0 0 / 35%); }
.network-link, .utility-button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid rgb(255 255 255 / 18%); border-radius: 12px; color: #d9e9f6; background: rgb(255 255 255 / 7%); font-weight: 800; text-decoration: none; }
.network-link { width: max-content; padding: 0 16px; }
.header-tools { justify-self: end; display: flex; gap: 8px; }
.utility-button { padding: 0 13px; cursor: pointer; }
.utility-button[aria-pressed="true"] { color: #081426; background: var(--gold); border-color: var(--gold); }
.fullscreen-button { width: 44px; padding: 0; font-size: 20px; line-height: 1; }

.table { position: relative; min-height: 0; display: grid; grid-template-rows: minmax(150px, 43%) auto minmax(130px, 1fr); overflow: hidden; isolation: isolate; background: radial-gradient(ellipse at center, transparent 20%, rgb(0 0 0 / 32%) 100%), url("/games/zacjack/assets/felt.png") center / cover; box-shadow: inset 0 0 100px rgb(0 0 0 / 50%); }
.table::after { content: ""; position: absolute; inset: 5% 4%; z-index: -1; border: clamp(2px, .35vw, 6px) solid rgb(255 255 255 / 12%); border-radius: 50%; pointer-events: none; }
.table-logo { position: absolute; z-index: -1; inset: 50% auto auto 50%; width: min(34vw, 370px); transform: translate(-50%, -52%); opacity: .16; filter: drop-shadow(0 12px 28px rgb(0 0 0 / 40%)); pointer-events: none; }
.balance-panel { position: absolute; z-index: 5; top: 16px; left: max(16px, env(safe-area-inset-left)); display: flex; flex-direction: column; padding: 10px 16px; border: 1px solid rgb(255 255 255 / 16%); border-radius: 16px; background: rgb(4 18 31 / 78%); backdrop-filter: blur(10px); box-shadow: 0 10px 30px rgb(0 0 0 / 30%); }
.balance-label { color: #a8d7ed; font-size: 11px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.balance-panel strong { color: var(--gold); font-size: clamp(26px, 3vw, 42px); line-height: 1; }

.dealer-zone, .player-zone { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dealer-zone { padding-top: 6px; }
.zone-heading { position: relative; display: grid; place-items: center; margin-bottom: 7px; font-size: clamp(13px, 1.4vw, 19px); font-weight: 900; letter-spacing: .32em; text-align: center; text-transform: uppercase; }
.score-badge { position: absolute; top: 50%; left: calc(100% + 10px); min-width: 34px; color: var(--gold); font-size: 1.25em; letter-spacing: 0; text-align: left; transform: translateY(-50%); }
.card-row { min-height: var(--card-h); display: flex; align-items: center; justify-content: center; }
.playing-card + .playing-card { margin-left: calc(var(--card-w) * -.24); }
.playing-card { position: relative; width: var(--card-w); height: var(--card-h); flex: 0 0 auto; border: clamp(2px, .24vw, 4px) solid #d9dde3; border-radius: clamp(8px, .8vw, 14px); color: #10151b; background: linear-gradient(145deg, #fff, #eef1f4); box-shadow: 0 8px 18px rgb(0 0 0 / 35%); }
.playing-card.is-new { transform-origin: center; animation: deal-card .38s cubic-bezier(.18,.78,.2,1) both; animation-delay: var(--deal-delay, 0ms); }
.playing-card.red { color: #dc2626; }
.playing-card .corner { position: absolute; top: 7%; left: 9%; display: grid; justify-items: center; font-weight: 900; font-size: clamp(15px, calc(var(--card-w) * .2), 27px); line-height: .9; }
.playing-card .corner.bottom { inset: auto 9% 7% auto; transform: rotate(180deg); }
.playing-card .suit-center { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--card-w) * .48); }
.playing-card.card-back { overflow: hidden; border-color: #fff; background: linear-gradient(135deg, rgb(255 255 255 / 8%) 25%, transparent 25%) 0 0 / 18px 18px, linear-gradient(315deg, rgb(255 255 255 / 8%) 25%, transparent 25%) 0 0 / 18px 18px, #071f3a; }
.playing-card.card-back img { width: 78%; height: 78%; object-fit: contain; position: absolute; inset: 11%; filter: drop-shadow(0 4px 8px #000); }
.playing-card.is-revealing { transform-style: preserve-3d; }
.hole-card-cover { position: absolute; z-index: 4; inset: -2px; overflow: hidden; display: grid; place-items: center; border: inherit; border-radius: inherit; background: linear-gradient(135deg, rgb(255 255 255 / 8%) 25%, transparent 25%) 0 0 / 18px 18px, linear-gradient(315deg, rgb(255 255 255 / 8%) 25%, transparent 25%) 0 0 / 18px 18px, #071f3a; backface-visibility: hidden; transform-origin: left center; animation: reveal-hole .42s ease-in-out var(--reveal-delay, 0ms) both; }
.hole-card-cover img { width: 78%; height: 78%; object-fit: contain; filter: drop-shadow(0 4px 8px #000); }

.message-zone { z-index: 3; align-self: center; justify-self: center; max-width: min(90%, 720px); text-align: center; }
#round-message { margin: 0; padding: 8px 22px; border-radius: 999px; background: rgb(0 0 0 / 45%); font-size: clamp(16px, 2vw, 25px); font-weight: 900; text-transform: uppercase; box-shadow: 0 8px 22px rgb(0 0 0 / 25%); }
#error-message { min-height: 18px; margin: 4px 0 0; color: #ffd2d2; font-size: 13px; font-weight: 800; }
.player-zone { justify-content: end; padding: 0 18px 12px; }
.player-hands { width: min(100%, 1050px); display: flex; justify-content: center; align-items: end; gap: clamp(8px, 2vw, 26px); }
.hand { position: relative; min-width: 0; overflow: hidden; padding: 10px 12px 12px; border: 2px solid transparent; border-radius: 18px; background: rgb(0 0 0 / 22%); opacity: .82; transition: transform .2s, border-color .2s, box-shadow .2s, opacity .2s; }
.hand.active { transform: translateY(-6px); border-color: var(--gold); box-shadow: 0 0 26px rgb(251 191 36 / 55%); }
.hand.active, .hand.celebrating { opacity: 1; }
.hand.split-enter { animation: split-hand-enter .42s cubic-bezier(.2,.8,.2,1) backwards; }
.hand.action-feedback { animation: action-feedback .28s ease-out; }
.hand.action-feedback::after { content: attr(data-action-feedback); position: absolute; z-index: 6; inset: 8px 8px auto auto; padding: 4px 8px; border-radius: 999px; color: #07111f; background: var(--gold); font-size: 11px; font-weight: 900; text-transform: uppercase; animation: action-label .45s ease-out both; }
.hand.celebrating { border-color: var(--gold); box-shadow: 0 0 26px rgb(251 191 36 / 38%); }
.hand .card-row { --card-w: clamp(62px, 7vw, 116px); }
.hand-meta { position: relative; z-index: 2; display: grid; justify-items: center; gap: 3px; margin-bottom: 7px; font-weight: 900; text-align: center; text-transform: uppercase; text-shadow: 0 2px 5px #000; }
.hand-title { font-size: clamp(14px, 1.45vw, 20px); letter-spacing: .08em; }
.hand-stats { display: flex; justify-content: center; gap: clamp(12px, 2vw, 28px); color: #e8f2fa; font-size: clamp(16px, 1.75vw, 24px); line-height: 1; }
.hand-stats strong { color: var(--gold); font-size: 1.12em; }
.hand-state { padding: 2px 8px; border-radius: 999px; color: #c9d8e4; background: rgb(7 25 45 / 82%); font-size: 11px; letter-spacing: .08em; }
.hand-state.bust { color: #fff; background: #b91c1c; }
.hand-state.blackjack, .hand-state.twenty-one { color: #07111f; background: var(--gold); }
.hand > .card-row { position: relative; z-index: 2; width: 100%; }
.hand-outcome { position: absolute; z-index: 3; inset: 50% auto auto 50%; width: max-content; max-width: 92%; transform: translate(-50%, -50%) rotate(-3deg); padding: 6px 12px; border-radius: 10px; color: #fff; background: #172033; font-size: clamp(15px, 1.8vw, 26px); font-weight: 900; line-height: 1.05; text-align: center; text-transform: uppercase; box-shadow: 0 8px 20px #0008; animation: result-arrive .34s cubic-bezier(.2,.85,.2,1) both; }
.hand-outcome.win, .hand-outcome.blackjack { background: #059669; }
.hand-outcome.loss { background: #dc2626; }
.hand-outcome.push { background: #526172; }
.chip-rain { position: absolute; z-index: 1; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none; }
.chip-rain img { position: absolute; top: -34px; left: var(--chip-left); width: clamp(22px, 3.2vw, 38px); height: auto; opacity: 0; will-change: transform, opacity; animation: chip-fall var(--chip-duration) ease-in var(--chip-delay) both; }
.player-hands[data-hand-count="3"] { gap: clamp(5px, 1vw, 12px); }
.player-hands[data-hand-count="4"] { gap: clamp(3px, .65vw, 8px); }
.player-hands[data-hand-count="3"] .hand .card-row { --card-w: clamp(54px, 5.7vw, 86px); }
.player-hands[data-hand-count="4"] .hand .card-row { --card-w: clamp(48px, 4.7vw, 72px); }
.player-hands[data-hand-count="3"] .hand, .player-hands[data-hand-count="4"] .hand { padding-inline: 7px; }
.action.acknowledged { transform: translateY(3px) scale(.98); filter: brightness(1.18); box-shadow: inset 0 0 0 3px rgb(255 255 255 / 30%); }
.table.collecting .playing-card { pointer-events: none; animation: collect-card .52s cubic-bezier(.65,0,.8,.25) both !important; animation-delay: calc(var(--card-order, 0) * 24ms) !important; }
.table.collecting .hand-meta, .table.collecting .zone-heading { transition: opacity .18s; opacity: 0; }

.control-dock { z-index: 20; min-height: 118px; padding: 10px max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: linear-gradient(180deg, #07192d, #030e1b); border-top: 1px solid rgb(255 255 255 / 12%); box-shadow: 0 -10px 34px rgb(0 0 0 / 35%); }
.control-view { width: min(1180px, 100%); min-height: 96px; margin: auto; }
.control-view[hidden] { display: none !important; }
.betting-controls { display: grid; grid-template-columns: minmax(180px, .7fr) minmax(380px, 1.4fr); align-items: center; gap: 24px; }
.wager-copy span { display: block; color: var(--gold); font-size: 20px; font-weight: 900; text-transform: uppercase; }
.wager-copy small { color: #9eb7ca; }
.wager-entry { display: grid; grid-template-columns: 48px minmax(92px, 1fr) 48px 62px minmax(105px, 1fr); gap: 7px; align-items: end; }
.wager-entry button, .action, .deal-button, .reset-button { min-height: 52px; border: 0; border-radius: 12px; color: #fff; background: #17334d; font-weight: 900; text-transform: uppercase; cursor: pointer; }
.wager-entry label { display: grid; gap: 2px; }
.wager-entry label span { color: #9eb7ca; font-size: 10px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
#wager { width: 100%; min-height: 52px; border: 2px solid #365a78; border-radius: 12px; color: #fff; background: #061526; font-size: 22px; font-weight: 900; text-align: center; }
.max-button { color: var(--gold) !important; }
.deal-button { background: var(--gold) !important; color: #07111f !important; font-size: 20px; box-shadow: 0 5px 0 #8a5c00; }
.deal-button:active { transform: translateY(3px); box-shadow: 0 2px 0 #8a5c00; }
.reset-button { grid-column: 1 / -1; justify-self: center; padding: 0 24px; background: #7c3aed; }

.action-controls { display: grid; grid-template-columns: auto minmax(400px, 760px); justify-content: center; align-items: center; gap: 18px; }
.active-wager { color: #9eb7ca; font-size: 13px; font-weight: 800; text-transform: uppercase; }
.active-wager strong { display: block; color: var(--gold); font-size: 28px; }
.action-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.action { min-height: 64px; font-size: clamp(16px, 2vw, 23px); }
.action.hit { background: #059669; }
.action.stand { background: #dc2626; }
.action.double { color: #161009; background: var(--gold); }
.action.split { background: #7c3aed; }
.action:disabled { opacity: .3; filter: grayscale(.5); cursor: not-allowed; }
.action-help { grid-column: 2; min-height: 16px; margin: -7px 0 0; color: #a8bdcc; font-size: 12px; text-align: center; }
.result-controls { display: flex; align-items: center; justify-content: center; gap: 26px; }
.result-summary { font-size: clamp(16px, 2vw, 24px); font-weight: 900; text-transform: uppercase; }
.result-summary strong { color: var(--gold); }
.result-controls .deal-button { min-width: 180px; padding: 0 25px; }
.dealer-wait { display: grid; place-items: center; color: var(--gold); font-size: 24px; font-weight: 900; text-transform: uppercase; }
.out-of-coins { display: flex; align-items: center; justify-content: center; gap: clamp(20px, 5vw, 70px); text-transform: uppercase; }
.out-of-coins div { display: grid; gap: 3px; }
.out-of-coins strong { color: var(--gold); font-size: clamp(24px, 3vw, 36px); }
.out-of-coins span { color: #c5d7e5; font-weight: 800; }
.viewer-cannon-cta { min-height: 58px; display: inline-flex; align-items: center; justify-content: center; padding: 0 24px; border-radius: 12px; color: #07111f; background: var(--gold); font-size: 18px; font-weight: 900; text-decoration: none; box-shadow: 0 5px 0 #8a5c00; }

@keyframes deal-card { 0% { opacity: .15; transform: translate(var(--deal-origin-x, 42vw), var(--deal-origin-y, -35vh)) scale(.72) rotate(12deg); } 72% { opacity: 1; transform: translate(-3px, 4px) scale(1.015) rotate(-1deg); } 100% { opacity: 1; transform: translate(0) scale(1) rotate(0); } }
@keyframes reveal-hole { 0% { transform: perspective(700px) rotateY(0); opacity: 1; } 48% { transform: perspective(700px) rotateY(-88deg); opacity: 1; } 52%, 100% { transform: perspective(700px) rotateY(-92deg); opacity: 0; } }
@keyframes split-hand-enter { from { opacity: .45; transform: translateX(calc(var(--split-direction) * -34px)) scale(.94); } to { opacity: .82; transform: translateX(0) scale(1); } }
@keyframes action-feedback { 0% { filter: brightness(1); } 38% { filter: brightness(1.32); } 100% { filter: brightness(1); } }
@keyframes action-label { from { opacity: 0; transform: translateY(5px) scale(.88); } 30% { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(-5px) scale(.98); } }
@keyframes result-arrive { from { opacity: 0; transform: translate(-50%, -42%) scale(.84) rotate(-3deg); } to { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-3deg); } }
@keyframes collect-card { 0% { opacity: 1; transform: translate(0) rotate(0) scale(1); } 100% { opacity: 0; transform: translate(var(--collect-x, 44vw), var(--collect-y, -36vh)) rotate(18deg) scale(.68); } }
@keyframes chip-fall { 0% { opacity: 0; transform: translate(-50%, -28px) rotate(0); } 18% { opacity: .82; } 82% { opacity: .72; } 100% { opacity: 0; transform: translate(-50%, calc(var(--card-h) + 105px)) rotate(var(--chip-rotation)); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } .chip-rain { display: none; } }

@media (max-width: 760px) and (orientation: portrait) {
  :root { --card-w: clamp(64px, 20vw, 94px); }
  .game-header { min-height: 54px; grid-template-columns: 1fr 1fr; gap: 6px; }
  .network-link { width: auto; padding: 0 8px; font-size: 11px; }
  .header-tools { gap: 4px; }
  .utility-button { min-height: 40px; padding: 0 8px; font-size: 11px; }
  .table { grid-template-rows: minmax(145px, 37%) auto minmax(180px, 1fr); }
  .table::after { inset: 3% -30%; }
  .table-logo { width: min(52vw, 250px); }
  .balance-panel { top: 8px; left: 8px; padding: 7px 10px; }
  .balance-label { max-width: 120px; font-size: 8px; }
  .balance-panel strong { font-size: 26px; }
  .dealer-zone { padding-top: 26px; }
  .zone-heading { margin-bottom: 4px; }
  #round-message { padding: 6px 14px; font-size: 14px; }
  #error-message { font-size: 11px; }
  .player-zone { overflow-x: auto; justify-content: end; padding-inline: 8px; }
  .player-zone { align-items: flex-start; }
  .player-hands { width: max-content; max-width: none; gap: 7px; }
  .player-hands[data-hand-count="0"], .player-hands[data-hand-count="1"] { align-self: center; }
  .player-hands[data-hand-count="2"], .player-hands[data-hand-count="3"], .player-hands[data-hand-count="4"] { align-self: flex-start; }
  .hand { width: max-content; padding: 5px 6px 7px; }
  .hand .card-row { --card-w: clamp(58px, 17vw, 80px); }
  .hand-title { font-size: 14px; }
  .hand-stats { gap: 16px; font-size: 18px; }
  .control-dock { min-height: 178px; padding-top: 8px; }
  .betting-controls { grid-template-columns: 1fr; gap: 6px; }
  .wager-copy { display: none; }
  .wager-entry { grid-template-columns: 44px minmax(78px, 1fr) 44px 56px minmax(88px, 1fr); gap: 5px; }
  .wager-entry button, #wager { min-height: 48px; }
  .action-controls { grid-template-columns: 1fr; gap: 6px; }
  .active-wager { display: flex; justify-content: center; align-items: baseline; gap: 8px; }
  .active-wager strong { display: inline; font-size: 20px; }
  .action-buttons { gap: 6px; }
  .action { min-height: 64px; padding-inline: 4px; font-size: 15px; }
  .action-help { grid-column: 1; margin-top: 0; }
  .result-controls { flex-direction: column; gap: 8px; text-align: center; }
  .result-controls .deal-button { min-height: 54px; }
  .out-of-coins { flex-direction: column; gap: 10px; text-align: center; }
  .viewer-cannon-cta { min-height: 52px; }
}

@media (orientation: landscape) and (max-height: 700px) {
  :root { --card-w: clamp(56px, 12vh, 82px); }
  .game-shell { grid-template-rows: minmax(0, 1fr) auto; }
  .game-header { position: absolute; z-index: 30; inset: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) auto max(8px, env(safe-area-inset-left)); min-height: 44px; padding: 0; background: transparent; border: 0; box-shadow: none; pointer-events: none; }
  .game-header > * { pointer-events: auto; }
  .network-link, .utility-button { min-height: 40px; background: rgb(4 18 31 / 78%); font-size: 11px; }
  .table { grid-row: 1; grid-template-rows: 43% auto 1fr; }
  .balance-panel { top: 56px; padding: 6px 10px; }
  .balance-panel strong { font-size: 24px; }
  .dealer-zone { padding-top: 4px; }
  .player-zone { padding-bottom: 5px; }
  .hand { padding: 4px 6px; }
  .hand .card-row { --card-w: clamp(50px, 10vh, 72px); }
  .control-dock { grid-row: 2; min-height: 92px; padding-top: 6px; }
  .control-view { min-height: 74px; }
  .betting-controls { grid-template-columns: auto minmax(350px, 1fr); gap: 12px; }
  .wager-copy small { display: none; }
  .wager-entry button, #wager { min-height: 46px; }
  .action { min-height: 54px; }
}

@media (orientation: landscape) and (max-height: 700px) and (max-width: 800px) {
  .betting-controls { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .wager-copy { display: none; }
  .wager-entry { grid-template-columns: 40px minmax(70px, 1fr) 40px 56px minmax(86px, 1fr); gap: 5px; }
}

@media (min-aspect-ratio: 2/1) and (max-height: 520px) {
  .table { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
  .dealer-zone { grid-column: 1; grid-row: 1; padding-top: 45px; }
  .message-zone { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); }
  .player-zone { grid-column: 2; grid-row: 1; justify-content: center; padding-top: 45px; }
  .table-logo { left: 50%; width: 190px; }
}
