:root {
  color-scheme: dark;
  --ink: #f8f6ef;
  --muted: #a8bab3;
  --felt: #126447;
  --felt-dark: #073c2d;
  --gold: #d8b968;
  --gold-light: #f1dda4;
  --ivory: #f4eedf;
  --cyan: #d9bd72;
  --violet: #8f7138;
  --night: #08100d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; overflow-x: hidden; }

body {
  background:
    radial-gradient(circle at 50% -20%, rgba(216, 185, 104, 0.11), transparent 38rem),
    linear-gradient(180deg, #0b1813 0%, #030806 100%);
  color: var(--ink);
}

button { font: inherit; }

.game-shell {
  margin: 0 auto;
  max-width: 1280px;
  min-height: 100dvh;
  padding: 20px clamp(16px, 3vw, 42px) 26px;
}

.brand-bar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 auto 14px;
  max-width: 1120px;
}

.brand { align-items: center; display: flex; gap: 11px; }
.brand img { filter: drop-shadow(0 4px 9px rgba(216, 185, 104, 0.22)); object-fit: contain; }
.brand p, .brand h1, .table-label { margin: 0; }
.brand-name { color: var(--muted); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.19em; text-transform: uppercase; }
.brand h1 { font-size: clamp(1.35rem, 2.4vw, 2rem); font-weight: 900; letter-spacing: -0.045em; line-height: 1; }
.brand h1 span { color: var(--gold-light); }
.table-label { color: var(--gold); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.table-label strong { color: var(--ivory); font-variant-numeric: tabular-nums; }

.table-frame {
  background:
    linear-gradient(110deg, transparent 0 18%, rgba(255,255,255,.18) 28%, transparent 38% 67%, rgba(255,255,255,.12) 76%, transparent 84%),
    linear-gradient(135deg, #5a3d17, #d0aa58 27%, #f0d991 43%, #76521e 68%, #c9a04e);
  border-radius: 48% 48% 24% 24% / 13% 13% 10% 10%;
  box-shadow: 0 30px 75px rgba(0, 0, 0, 0.58), inset 0 1px rgba(255, 249, 220, 0.72), 0 0 0 1px rgba(39, 25, 8, 0.8);
  margin: 0 auto;
  max-width: 1120px;
  padding: 8px;
}

.table {
  background:
    radial-gradient(ellipse at 50% 46%, rgba(255, 248, 218, 0.07), transparent 52%),
    repeating-linear-gradient(14deg, rgba(255,255,255,.018) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(104deg, rgba(0,0,0,.018) 0 1px, transparent 1px 5px),
    linear-gradient(155deg, var(--felt) 0%, #0b533d 45%, var(--felt-dark) 100%);
  border: 2px solid rgba(43, 29, 10, 0.88);
  box-shadow: inset 0 0 70px rgba(0, 21, 14, 0.3), inset 0 1px rgba(255, 244, 205, 0.14);
  border-radius: 48% 48% 23% 23% / 13% 13% 10% 10%;
  display: grid;
  grid-template-rows: minmax(145px, 1fr) auto minmax(145px, 1fr);
  min-height: 610px;
  overflow: hidden;
  padding: 42px clamp(44px, 8vw, 112px) 32px;
  position: relative;
}

.table::before {
  border: 1px solid rgba(225, 198, 127, 0.5);
  border-radius: inherit;
  content: "";
  inset: 18px;
  pointer-events: none;
  position: absolute;
}

.table-emblem {
  align-items: center;
  color: rgba(244, 238, 223, 0.35);
  display: flex;
  flex-direction: column;
  left: 50%;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  user-select: none;
}

.table-emblem img { filter: grayscale(0.28) sepia(0.12) saturate(0.58); height: 168px; object-fit: contain; opacity: 0.24; width: 168px; }
.table-emblem strong { font-size: 1.05rem; letter-spacing: 0.18em; margin-top: -12px; text-transform: uppercase; }
.table-emblem span { font-size: 0.58rem; font-weight: 800; letter-spacing: 0.42em; margin-top: 4px; }

.hand { position: relative; text-align: center; z-index: 2; }
.hand-dealer { align-self: start; }
.hand-player { align-self: end; }
.hand-heading { align-items: center; display: flex; gap: 12px; justify-content: center; margin-bottom: 12px; }
.hand h2 { font-size: 0.73rem; letter-spacing: 0.16em; margin: 0; text-transform: uppercase; }
.score { align-items: center; color: var(--muted); display: flex; font-size: 0.72rem; font-weight: 700; gap: 6px; margin: 0; }
.score output { align-items: center; background: rgba(2, 21, 16, 0.72); border: 1px solid rgba(231, 200, 123, 0.35); border-radius: 999px; color: white; display: inline-flex; font-size: 0.84rem; height: 28px; justify-content: center; min-width: 38px; padding: 0 9px; }

.cards { display: flex; justify-content: center; list-style: none; margin: 0; min-height: 116px; padding: 0; }
.playing-card {
  animation: deal 360ms cubic-bezier(.2,.8,.25,1) both;
  background: linear-gradient(145deg, #fff, #ece9df);
  border: 1px solid rgba(0, 0, 0, 0.24);
  border-radius: 9px;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  color: #131414;
  height: 116px;
  margin-left: -12px;
  padding: 8px;
  position: relative;
  transform-origin: 50% 120%;
  width: 82px;
}
.playing-card:first-child { margin-left: 0; }
.playing-card:nth-child(2) { animation-delay: 70ms; }
.playing-card:nth-child(3) { animation-delay: 140ms; }
.playing-card:nth-child(4) { animation-delay: 210ms; }
.playing-card.red { color: #c71e3a; }
.card-corner { display: flex; flex-direction: column; font-size: 1rem; font-weight: 900; left: 8px; line-height: 0.9; position: absolute; top: 8px; }
.card-suit { font-size: 2.2rem; left: 50%; line-height: 1; position: absolute; top: 52%; transform: translate(-50%, -50%); }
.card-name { clip: rect(0 0 0 0); clip-path: inset(50%); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }

.card-back {
  background:
    linear-gradient(135deg, rgba(32, 216, 255, 0.22), transparent 35%),
    linear-gradient(315deg, rgba(142, 66, 255, 0.32), transparent 40%),
    #11134d;
  border: 4px solid #f0e7ce;
  box-shadow: inset 0 0 0 2px #151961, inset 0 0 0 4px rgba(32, 216, 255, 0.45), 0 10px 18px rgba(0, 0, 0, 0.35);
  padding: 10px;
}
.card-back img { height: 100%; object-fit: contain; width: 100%; }

.result-banner {
  align-self: center;
  background: rgba(4, 25, 18, 0.82);
  border: 1px solid rgba(216, 185, 104, 0.3);
  border-radius: 999px;
  box-shadow: 0 9px 28px rgba(0, 0, 0, 0.24);
  color: var(--ivory);
  font-size: clamp(0.78rem, 1.4vw, 0.95rem);
  font-weight: 800;
  justify-self: center;
  letter-spacing: 0.02em;
  margin: 10px 0;
  max-width: min(90%, 500px);
  padding: 10px 22px;
  position: relative;
  text-align: center;
  z-index: 3;
}

.table[data-outcome="victoire"]::after,
.table[data-outcome="blackjack"]::after {
  animation: victory-glow 1.8s ease-in-out infinite alternate;
  border: 2px solid rgba(255, 225, 133, 0.65);
  border-radius: inherit;
  content: "";
  inset: 10px;
  pointer-events: none;
  position: absolute;
}
.table[data-outcome="victoire"] .result-banner,
.table[data-outcome="blackjack"] .result-banner { background: #f1d27d; color: #17251f; transform: scale(1.05); }
.table[data-outcome="victoire"] .table-emblem img,
.table[data-outcome="blackjack"] .table-emblem img { animation: niglo-cheer 700ms ease-out; opacity: 0.26; }

.chip-rack { bottom: 22px; display: flex; gap: 7px; position: absolute; right: 28px; z-index: 3; }
.chip {
  --chip-color: #355f75;
  align-items: center;
  background:
    radial-gradient(circle, var(--chip-color) 0 36%, #f4ecd9 37% 43%, var(--chip-color) 44% 66%, transparent 67%),
    repeating-conic-gradient(#f4ecd9 0 10deg, var(--chip-color) 10deg 35deg);
  border: 2px solid rgba(25, 19, 10, 0.82);
  border-radius: 50%;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.42), inset 0 0 0 2px rgba(255, 255, 255, 0.32), inset 0 0 0 5px rgba(0, 0, 0, 0.12);
  display: flex;
  color: #fffaf0;
  font-size: 0.56rem;
  font-weight: 900;
  height: 38px;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transform: rotate(-8deg);
  width: 38px;
}
.chip:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 3px; }
.chip.selectionne { box-shadow: 0 0 0 3px var(--gold-light), 0 7px 13px rgba(0,0,0,.48), inset 0 0 0 2px rgba(255,255,255,.32); }
.chip:disabled { cursor: not-allowed; filter: saturate(.55); opacity: .66; }
.chip-50 { --chip-color: #285f76; }
.chip-100 { --chip-color: #80542d; transform: rotate(6deg); }
.chip-200 { --chip-color: #7b2835; transform: rotate(-2deg); }

.actions {
  background: linear-gradient(180deg, #65471e, #2d1f0e);
  border: 1px solid #b79247;
  border-radius: 0 0 18px 18px;
  box-shadow: 0 12px 24px rgba(0,0,0,.34), inset 0 1px rgba(255,244,205,.25);
  display: grid;
  gap: 8px;
  grid-template-columns: 1.4fr repeat(4, 1fr);
  margin: 0 auto;
  max-width: 780px;
  padding: 9px;
}
.button {
  background: linear-gradient(180deg, #28483a, #10261e);
  border: 1px solid rgba(241, 221, 164, 0.24);
  border-radius: 9px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
  color: var(--ivory);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 850;
  min-height: 48px;
  padding: 10px 16px;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}
.button:hover:not(:disabled) { background: linear-gradient(180deg, #355d4b, #163127); border-color: var(--gold-light); transform: translateY(-1px); }
.button:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.button:disabled { cursor: not-allowed; opacity: 0.38; }
.button-new { background: linear-gradient(180deg, #e0c276, #a88037); color: #172119; text-shadow: 0 1px rgba(255,255,255,.32); }
.button-new:hover:not(:disabled) { background: linear-gradient(180deg, #f0d995, #b58d40); }
.button-double:not(:disabled) { border-color: rgba(231, 200, 123, 0.52); color: #ffe4a0; }
.button-rebuy { color: var(--gold-light); }

@keyframes deal {
  from { opacity: 0; transform: translate(80px, -55px) rotate(8deg) scale(0.82); }
  to { opacity: 1; transform: none; }
}
@keyframes victory-glow {
  from { box-shadow: inset 0 0 20px rgba(255, 224, 125, 0.12), 0 0 8px rgba(255, 224, 125, 0.12); }
  to { box-shadow: inset 0 0 55px rgba(255, 224, 125, 0.24), 0 0 24px rgba(255, 224, 125, 0.28); }
}
@keyframes niglo-cheer {
  0%, 100% { transform: rotate(0) scale(1); }
  35% { transform: rotate(-5deg) scale(1.08); }
  70% { transform: rotate(5deg) scale(1.08); }
}

@media (max-width: 680px) {
  .game-shell { padding: max(10px, env(safe-area-inset-top)) 10px calc(92px + env(safe-area-inset-bottom)); }
  .brand-bar { margin-bottom: 8px; padding: 0 4px; }
  .brand img { height: 38px; width: 38px; }
  .brand-name { font-size: 0.58rem; }
  .brand h1 { font-size: 1.25rem; }
  .table-label { font-size: 0.58rem; }
  .table-frame, .table { border-radius: 34px; }
  .table-frame { padding: 5px; }
  .table {
    grid-template-rows: minmax(122px, 1fr) auto minmax(122px, 1fr);
    min-height: min(650px, calc(100dvh - 150px));
    padding: 30px 12px 24px;
  }
  .table::before { border-radius: 25px; inset: 10px; }
  .table-emblem img { height: 105px; width: 105px; }
  .table-emblem strong { font-size: 0.72rem; }
  .table-emblem span { font-size: 0.45rem; }
  .hand-heading { margin-bottom: 8px; }
  .cards { min-height: 88px; }
  .playing-card { border-radius: 7px; height: 88px; margin-left: -8px; padding: 5px; width: 62px; }
  .card-corner { font-size: 0.8rem; left: 6px; top: 6px; }
  .card-suit { font-size: 1.65rem; }
  .result-banner { margin: 7px 0; padding: 8px 15px; }
  .chip-rack { bottom: 13px; right: 15px; }
  .chip { border-width: 3px; height: 31px; width: 31px; }
  .actions {
    background: linear-gradient(180deg, rgba(25, 35, 29, 0.97), rgba(8, 14, 11, 0.99));
    border: 0;
    border-radius: 0;
    border-top: 1px solid rgba(216, 185, 104, 0.48);
    bottom: 0;
    gap: 7px;
    grid-template-columns: repeat(3, 1fr);
    left: 0;
    margin: 0;
    padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
    position: fixed;
    right: 0;
    z-index: 10;
  }
  .button { font-size: 0.76rem; min-height: 46px; padding: 7px 4px; }
  .button-new { grid-column: 1 / span 2; min-height: 38px; }
  .button-rebuy { grid-column: 3; min-height: 38px; }
}

@media (max-width: 390px) {
  .playing-card { height: 78px; width: 55px; }
  .cards { min-height: 78px; }
  .chip-rack { bottom: 12px; display: flex; right: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: 1ms !important; }
}


.sound-button {
  margin-left: 12px;
  border: 0;
  background: transparent;
  font-size: 1.3rem;
  cursor: pointer;
  vertical-align: middle;
}
