@font-face {
  font-family: "Instrument Serif";
  src: url('/assets/fonts/InstrumentSerif-Regular.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  font-synthesis: none;
  --ink: #071f1a;
  --cream: #fff4da;
  --gold: #d4b879;
  --gold-muted: #bba16d;
  --line: #d4b8793d;
  --soft-white: #e8e8d0;
  background: var(--ink);
  color: var(--cream);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html { min-width: 280px; min-height: 100%; background: var(--ink); }
body {
  margin: 0;
  min-width: 280px;
  min-height: 100svh;
  background: #0c352b url('/assets/table-atmosphere-v2.webp') center / cover fixed;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 48%, #0b3a2d00 20%, #0216118c 100%);
  pointer-events: none;
}
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible { outline: 2px solid #ffdc93; outline-offset: 4px; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr) 46px;
  gap: 12px;
  width: 100%;
  height: 100svh;
  height: 100dvh;
  min-height: 560px;
  padding: max(14px, env(safe-area-inset-top)) max(36px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(36px, env(safe-area-inset-left));
}
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; width: 100%; max-width: 1360px; margin: 0 auto; }
.brand { flex-shrink: 0; }
h1 { margin: 0; font-weight: 400; }
h1 > span { display: block; font: 400 47px/.88 "Instrument Serif", Georgia, serif; letter-spacing: -.025em; }
h1 > small { display: block; margin-top: 10px; font: 500 9px/1 -apple-system, BlinkMacSystemFont, sans-serif; text-transform: uppercase; letter-spacing: .32em; padding-left: 2px; color: var(--gold); }
.header-tools { display: flex; align-items: center; gap: 7px; }
.utility-button { position: relative; min-height: 44px; padding: 0 15px; border: 1px solid #d4b87940; border-radius: 100px; background: #051c1666; color: #efebd6d9; font-size: 11px; line-height: 1; font-weight: 500; white-space: nowrap; transition: background-color 140ms, border-color 140ms; }
.utility-button[aria-pressed="true"] { border-color: #d4b87968; }
.utility-button:active { background: #c9ae6c1a; }
.utility-button input[type="checkbox"] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.table { position: relative; width: 100%; min-height: 0; isolation: isolate; overflow: hidden; }
.table-inner { display: grid; grid-template-rows: minmax(0, 1fr) 88px minmax(0, 1fr) 60px; row-gap: 8px; height: 100%; width: 100%; max-width: 1080px; margin: 0 auto; padding: 14px 0 6px; }
.hand-area { display: grid; grid-template-rows: 27px minmax(0, 1fr); gap: 10px; min-width: 0; min-height: 0; }
.hand-heading { display: flex; align-items: center; justify-content: center; gap: 11px; min-height: 27px; }
.hand-heading h2 { margin: 0; color: #e3d4adbd; font-size: 10px; font-weight: 550; line-height: 1; letter-spacing: .18em; text-transform: uppercase; }
.hand-total { display: inline-flex; align-items: center; justify-content: center; min-width: 33px; min-height: 25px; padding: 4px 10px; border: 1px solid #d4b87950; border-radius: 100px; color: #fff7df; font-size: 12px; line-height: 1.05; font-weight: 600; font-variant-numeric: tabular-nums; background: #061e1840; }
.hand-cards { position: relative; width: 100%; height: 100%; min-height: 0; max-width: 780px; margin: 0 auto; perspective: 1000px; }
.playing-card { position: absolute; width: 100px; aspect-ratio: 5 / 7; top: 0; left: 0; transform: translateX(var(--card-x, 0px)); transition: transform 300ms cubic-bezier(.22,.7,.2,1), width 300ms cubic-bezier(.22,.7,.2,1); border-radius: 8px; }
.playing-card::after { content: ""; position: absolute; inset: 2px 0 0; border-radius: inherit; box-shadow: 0 8px 12px #0006, 0 1px 2px #0008; z-index: -1; }
.card-rotator { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transform: rotateY(0deg); transition: transform 440ms cubic-bezier(.25,.65,.2,1); }
.is-hidden .card-rotator { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border-radius: 7px; backface-visibility: hidden; -webkit-backface-visibility: hidden; object-fit: fill; }
/* Explicit face visibility also covers WebKit software compositing. */
.card-front { opacity: 1; }
.card-back { transform: rotateY(180deg); opacity: 0; }
.card-face { transition: opacity 0s linear 220ms; }
.is-hidden .card-front { opacity: 0; }
.is-hidden .card-back { opacity: 1; }
.table-message { text-align: center; display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: 5px 4px; }
#game-status { margin: 0; font: 400 clamp(32px, 4.2vw, 52px)/1.05 "Instrument Serif", Georgia, serif; letter-spacing: -.02em; text-wrap: balance; }
#table-rule { margin: 11px 0 0; color: #e2d5a89c; font-size: 9px; letter-spacing: .12em; line-height: 1.4; text-transform: uppercase; }
.table[data-outcome="win"] #game-status { color: #f3d892; text-shadow: 0 0 35px #ddc06c22; }
.table[data-outcome="loss"] #game-status { color: #f2c6b5; }
.player-hands { display: flex; justify-content: center; gap: 18px; min-width: 0; min-height: 0; }
.player-hand { flex: 1; min-width: 0; min-height: 0; padding: 10px 14px 12px; border: 1px solid transparent; border-radius: 14px; }
.player-hands:not(.is-split) .player-hand { max-width: 850px; padding-top: 0; padding-bottom: 0; }
.player-hands.is-split .player-hand { background: #061f171c; border-color: #d4b87916; }
.player-hands.is-split .player-hand.is-active { border-color: #d4b8797a; background: #c5ad6b0a; }
.player-hand.is-bust { background: #a93d3d12; border-color: #e8a09060; }
.player-hand.is-winner .hand-total { border-color: #d8c69299; color: #f7df9a; }
.player-hand .hand-result { font-size: 10px; font-weight: 600; line-height: 1; text-transform: uppercase; color: #edd5a9c7; letter-spacing: .06em; }
.table-controls { display: flex; align-items: stretch; justify-content: center; min-height: 0; width: 100%; max-width: 860px; margin: 0 auto; }
.playing-controls { display: grid; width: 100%; grid-template-columns: 1.15fr 1.15fr 1fr 1fr; gap: 10px; }
.action-button { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; padding: 0 14px; border: 1px solid #c7b07959; border-radius: 8px; background: linear-gradient(#123c30bd, #09271fdd); color: #fff5df; font-size: 15px; font-weight: 550; line-height: 1.1; box-shadow: 0 2px 0 #0002; transition: transform 100ms, background-color 140ms, border-color 140ms; }
.action-button > span { font-size: 22px; font-weight: 400; line-height: 1; }
.action-button.primary-action { color: #1b3528; border-color: #dfca95; background: linear-gradient(160deg, #f0dfb1, #c8ad72); box-shadow: inset 0 1px #fff3, 0 3px 12px #010c1d30; }
.action-button.secondary-action { font-size: 13px; }
.action-button.secondary-action > span { font-size: 15px; }
.action-button:active:not(:disabled) { transform: translateY(2px); }
.action-button:disabled { color: #b9bd9b62; border-color: #c6b47d22; background: #061b1620; box-shadow: none; }
.action-button.play-again { width: 100%; max-width: 360px; }
.table-bottom { display: flex; align-items: center; justify-content: space-between; gap: 20px; width: 100%; max-width: 1080px; margin: 0 auto; }
.table-tip { margin: 0; color: #dfd9b18c; font-size: 11px; line-height: 1.5; max-width: 620px; }
.new-hand { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 4px 0 10px; border: 0; background: transparent; color: #ddc58de0; font-size: 11px; font-weight: 550; white-space: nowrap; }
.new-hand > span { font-size: 21px; font-weight: 400; line-height: 1; }
.rules-dialog { border: 1px solid #bc9f5f80; border-radius: 18px; background: #0b2922; color: var(--cream); padding: 25px; max-width: min(460px, calc(100vw - 30px)); max-height: calc(100dvh - 44px); box-shadow: 0 25px 90px #0008; }
.rules-dialog::backdrop { background: #010e0bbf; backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.rules-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.rules-heading h2 { margin: 0; font: 400 37px/1 "Instrument Serif", Georgia, serif; letter-spacing: -.02em; }
.close-button { width: 44px; height: 44px; margin: -10px -10px -10px 0; border: 0; background: transparent; color: #d1bd8f; font-size: 30px; }
.rules-dialog > p { font-size: 14px; line-height: 1.6; color: #dedcc8cf; }
.rules-dialog dl { margin: 25px 0; }
.rules-dialog dl > div + div { margin-top: 20px; }
.rules-dialog dt { font-size: 13px; font-weight: 650; color: #e5cfa0; margin-bottom: 6px; }
.rules-dialog dd { margin: 0; font-size: 13px; line-height: 1.65; color: #dedcc8c7; }
.rules-dialog .rules-note { border-top: 1px solid #b89d642e; padding-top: 17px; font-size: 12px; }
.noscript { position: fixed; inset: auto 15px 15px; padding: 15px; border: 1px solid #d9b87e; background: #0b2922; color: #fff4da; }
@media (hover: hover) {
  .utility-button:hover { background-color: #c9ae6c1a; border-color: #d4b87988; }
  .action-button:hover:not(:disabled) { border-color: #e6d1a08f; background-color: #224e3a; }
  .action-button.primary-action:hover { filter: brightness(1.06); }
  .new-hand:hover { color: #fff2c6; }
}
@media (max-width: 700px) {
  .app-shell { grid-template-rows: 54px minmax(0, 1fr) 44px; gap: 8px; padding: max(10px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
  .site-header { gap: 10px; }
  h1 > span { font-size: 36px; }
  h1 > small { margin-top: 8px; font-size: 7px; letter-spacing: .29em; }
  .header-tools { gap: 5px; }
  .utility-button { padding: 0 11px; font-size: 10px; }
  .table-inner { grid-template-rows: minmax(0, 1fr) 70px minmax(0, 1fr) 56px; gap: 8px; padding: 10px 0 5px; }
  .hand-area { grid-template-rows: 25px minmax(0, 1fr); gap: 8px; }
  .hand-heading { min-height: 25px; gap: 8px; }
  .hand-heading h2 { font-size: 9px; letter-spacing: .15em; }
  .hand-total { min-height: 23px; padding: 4px 9px; font-size: 11px; }
  #game-status { font-size: clamp(30px, 6vw, 41px); }
  #table-rule { margin-top: 9px; font-size: 8px; letter-spacing: .055em; }
  .player-hands { gap: 10px; }
  .player-hand { padding: 9px 7px; border-radius: 11px; }
  .player-hands:not(.is-split) .player-hand { padding-inline: 0; }
  .player-hands.is-split .hand-heading { gap: 5px; }
  .player-hands.is-split .hand-heading h2 { font-size: 8px; letter-spacing: .065em; }
  .player-hand .hand-result { font-size: 8px; }
  .playing-controls { gap: 7px; grid-template-columns: 1fr 1fr 1fr 1fr; }
  .action-button { min-height: 50px; padding: 0 7px; gap: 6px; font-size: 14px; }
  .action-button > span { font-size: 20px; }
  .action-button.secondary-action { font-size: 12px; }
  .action-button.secondary-action > span { font-size: 13px; }
  .table-tip { font-size: 10px; max-width: 360px; }
  .new-hand { font-size: 10px; }
}
@media (max-width: 370px) {
  .app-shell { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  h1 > span { font-size: 31px; }
  h1 > small { font-size: 6px; letter-spacing: .25em; }
  .header-tools { gap: 4px; }
  .utility-button { padding-inline: 8px; font-size: 9px; }
  .table-inner { grid-template-rows: minmax(0, 1fr) 64px minmax(0, 1fr) 54px; }
  .playing-controls { gap: 6px; }
  .action-button { flex-direction: column; gap: 4px; font-size: 11px; padding: 5px 4px; }
  .action-button.secondary-action { font-size: 11px; }
  .action-button.secondary-action > span { font-size: 17px; }
  .table-tip { font-size: 9px; max-width: 190px; }
}
@media (min-width: 1100px) and (min-height: 750px) {
  .app-shell { grid-template-rows: 86px minmax(0, 1fr) 46px; padding-inline: 48px; }
  h1 > span { font-size: 57px; }
  h1 > small { font-size: 10px; }
  .table-inner { grid-template-rows: minmax(0, 1fr) 102px minmax(0, 1fr) 62px; }
  .hand-heading h2 { font-size: 11px; }
  .hand-total { font-size: 13px; }
  .table-tip { font-size: 12px; }
}
@media (orientation: landscape) and (max-height: 560px) and (min-width: 601px) {
  .app-shell { grid-template-rows: 45px minmax(0, 1fr) 44px; min-height: 330px; gap: 5px; padding: max(8px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); }
  h1 > span { font-size: 32px; }
  h1 > small { margin-top: 6px; font-size: 6px; }
  .utility-button { min-height: 40px; }
  .table-inner { grid-template-columns: 1fr 1.2fr; grid-template-rows: minmax(0, 1fr) 52px 44px; column-gap: 24px; row-gap: 5px; padding: 2px 0; max-width: 1000px; }
  .dealer-area { grid-column: 1; grid-row: 1; }
  .player-hands { grid-column: 2; grid-row: 1; }
  .table-message { grid-column: 1 / -1; grid-row: 2; padding: 0; }
  #game-status { font-size: 30px; }
  #table-rule { margin-top: 5px; font-size: 7px; }
  .hand-area { grid-template-rows: 23px minmax(0, 1fr); gap: 6px; }
  .hand-heading { min-height: 23px; gap: 7px; }
  .hand-heading h2 { font-size: 8px; }
  .hand-total { min-height: 22px; font-size: 10px; }
  .player-hand, .player-hands:not(.is-split) .player-hand { padding: 0 4px; border-radius: 8px; }
  .player-hands { gap: 8px; }
  .player-hands.is-split .hand-heading { gap: 4px; }
  .player-hand .hand-result { font-size: 8px; }
  .table-controls { grid-column: 1 / -1; grid-row: 3; max-width: 750px; }
  .action-button { min-height: 44px; font-size: 13px; }
  .action-button.secondary-action { font-size: 12px; }
  .action-button > span { font-size: 18px; }
  .table-bottom { max-width: 1000px; }
  .table-tip { font-size: 9px; }
  .new-hand { min-height: 44px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Real iPhone touches land on the native switch; semantic buttons retain
   keyboard and VoiceOver actions beneath the transparent touch surface. */
.native-haptic-control { position: relative; display: grid; min-width: 0; }
.native-haptic-control > button { width: 100%; height: 100%; }
.native-haptic-target { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; touch-action: manipulation; appearance: auto; -webkit-appearance: auto; }
.native-haptic-control.is-pressed > button:not(:disabled) { transform: translateY(2px); filter: brightness(1.12); }
.table-controls > .native-haptic-control { width: 100%; max-width: 360px; }
.dealer-area { position: relative; }
#deck-shoe { position: absolute; top: 37px; right: 10px; width: 37px; height: 52px; pointer-events: none; opacity: .85; }
#deck-shoe i { position: absolute; inset: 0; border: 1px solid #d4b87999; border-radius: 4px; background: #092a20 url('/assets/cards/back-v2.webp') center / cover; box-shadow: 0 3px 8px #0005; }
#deck-shoe i:nth-child(1) { transform: translate(4px, 4px) rotate(7deg); }
#deck-shoe i:nth-child(2) { transform: translate(2px, 2px) rotate(3deg); }
.discard-card { position: fixed; z-index: 30 !important; pointer-events: none; transition: none !important; }
@media (max-width: 700px) { #deck-shoe { width: 28px; height: 39px; right: 1px; top: 35px; opacity: .6; } }
@media (orientation: landscape) and (max-height: 560px) { #deck-shoe { top: 32px; right: 0; width: 25px; height: 35px; } }
