/* =========================================================
   Structure : app, tapis, zones, main, console
   ========================================================= */

.app {
  position: relative;
  height: 100%;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  isolation: isolate;
  overflow: hidden;
  --topbar-h: 56px;
  --console-h: 112px;
}

.app > * { min-width: 0; max-width: 100%; }

/* ---------- Décor de fond ---------- */

.bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(130% 90% at 50% -22%, rgba(120, 255, 205, .10), transparent 58%),
    radial-gradient(85% 62% at 50% 34%, var(--felt-hi) 0%, var(--felt) 46%, var(--felt-deep) 100%);
}

.bg__glow {
  position: absolute;
  left: 50%;
  top: -18%;
  width: 78%;
  height: 78%;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(200, 255, 230, .16), rgba(200, 255, 230, .04) 55%, transparent 72%);
  filter: blur(6px);
  opacity: .8;
}

.bg__arc {
  position: absolute;
  left: 50%;
  bottom: -46%;
  width: 128%;
  height: 92%;
  transform: translateX(-50%);
  border-radius: 50% 50% 0 0;
  border-top: 1px solid rgba(233, 200, 133, .16);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, .04), 0 -22px 60px rgba(0, 0, 0, .22) inset;
  opacity: .9;
}

.bg__noise {
  position: absolute;
  inset: 0;
  opacity: .22;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

/* ---------- Barre haute ---------- */

.topbar {
  position: relative;
  z-index: 4;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 max(12px, env(safe-area-inset-left)) 0 max(12px, env(safe-area-inset-right));
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--gold);
  opacity: .92;
}

.brand__pip {
  font-size: 13px;
  line-height: 1;
  transform: translateY(-1px);
  opacity: .85;
}

.brand__text {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .22em;
  white-space: nowrap;
}

.credit {
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 15px 0 11px;
  border-radius: var(--r-pill);
  background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .015));
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 8px 20px rgba(0, 0, 0, .22);
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease);
}

.credit.is-up {
  border-color: rgba(86, 226, 168, .62);
  box-shadow: 0 0 0 1px rgba(86, 226, 168, .28), 0 0 22px rgba(86, 226, 168, .2);
}

.credit.is-down {
  border-color: rgba(239, 107, 98, .5);
  box-shadow: 0 0 0 1px rgba(239, 107, 98, .18), 0 0 18px rgba(239, 107, 98, .14);
}

.credit__coin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, #fff6de, transparent 46%),
    radial-gradient(circle at 50% 50%, #f3d79a, #c79a4e 62%, #9d7433 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .3) inset, 0 1px 3px rgba(0, 0, 0, .38);
  position: relative;
  flex: none;
}

.credit__coin::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px solid rgba(90, 60, 10, .35);
}

.credit__value {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 15px;
  letter-spacing: .02em;
  color: var(--gold-hi);
  min-width: 3ch;
  text-align: center;
}

.tools { display: flex; align-items: center; gap: 6px; }

.iconbtn {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--cream-dim);
  border: 1px solid transparent;
  transition: color .2s, background .2s, border-color .2s, transform .12s;
}

.iconbtn:hover { color: var(--gold); background: rgba(255, 255, 255, .05); border-color: var(--line-soft); }
.iconbtn:active { transform: scale(.94); }

.iconbtn--clear {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  color: var(--cream-faint);
}

.iconbtn--clear:hover { color: var(--gold); }

.iconbtn .i--off { display: none; }
.app[data-muted="1"] .iconbtn .i--on { display: none; }
.app[data-muted="1"] .iconbtn .i--off { display: block; }

/* ---------- Table ---------- */

.table {
  position: relative;
  z-index: 2;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  padding: 0 10px;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
}

.zone {
  position: relative;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.zone--dealer { align-items: flex-end; padding-bottom: 4px; }

.zone--player {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  padding-top: 4px;
}

/* Le sabot, décor + origine des cartes */
.shoe {
  position: absolute;
  top: 2px;
  right: max(10px, env(safe-area-inset-right));
  width: 52px;
  height: 30px;
  border-radius: 6px 6px 4px 4px;
  background: linear-gradient(170deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, .02) 42%, rgba(0, 0, 0, .3));
  border: 1px solid var(--line-soft);
  box-shadow: 0 8px 16px rgba(0, 0, 0, .3), 0 1px 0 rgba(255, 255, 255, .14) inset;
  z-index: 1;
  opacity: .85;
  transform: perspective(120px) rotateX(16deg);
}

.shoe::after {
  content: "";
  position: absolute;
  inset: 3px 6px auto 6px;
  height: 5px;
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, rgba(233, 200, 133, .5) 0 2px, transparent 2px 4px);
  opacity: .7;
}

/* ---------- Mains ---------- */

.spots {
  grid-area: 1 / 1;
  align-self: center;
  justify-self: center;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 100%;
  padding-top: 2px;
}

.hand {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: calc(var(--cw) * 6.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 2px;
  transition: opacity .3s var(--ease), filter .3s var(--ease), transform .3s var(--ease);
}

.hand--dealer {
  flex: none;
  width: 100%;
  max-width: calc(var(--cw) * 7.2);
}

.hand.is-dim { opacity: .46; filter: saturate(.6); }

.hand.is-active::before {
  content: "";
  position: absolute;
  inset: -6px -2px 2px;
  border-radius: 18px;
  background: radial-gradient(58% 74% at 50% 76%, rgba(233, 200, 133, .2), rgba(233, 200, 133, .05) 58%, transparent 76%);
  box-shadow: 0 0 0 1px rgba(233, 200, 133, .22) inset;
  pointer-events: none;
  animation: activePulse 2.6s ease-in-out infinite;
}

@keyframes activePulse {
  0%, 100% { opacity: .72; }
  50% { opacity: 1; }
}

.hand__cards {
  position: relative;
  width: 100%;
  height: var(--ch);
}

.spots.is-refitting .card { transition: none; }

.hand__foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 22px;
}

.total {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--gold);
  background: rgba(4, 20, 14, .62);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.total.is-soft { color: var(--gold-hi); }

.hand__badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px);
  border: 1px solid transparent;
  white-space: nowrap;
}

.hand__badge[data-outcome="win"],
.hand__badge[data-outcome="blackjack"] {
  color: #06251b;
  background: linear-gradient(180deg, #7df0c1, #3ecf95);
  box-shadow: 0 4px 14px rgba(86, 226, 168, .32);
}

.hand__badge[data-outcome="push"] {
  color: #1b2733;
  background: linear-gradient(180deg, #dfe9f3, #adc0d3);
}

.hand__badge[data-outcome="lose"],
.hand__badge[data-outcome="bust"] {
  color: #2a0c0a;
  background: linear-gradient(180deg, #ff9d95, #dd5c53);
}

/* ---------- Mise centrale ---------- */

.bet {
  grid-area: 1 / 1;
  align-self: center;
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: opacity .28s var(--ease), transform .28s var(--ease);
}

.app:not([data-phase="betting"]) .bet {
  opacity: 0;
  transform: translateY(6px) scale(.94);
  pointer-events: none;
}

.bet__stack {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  height: calc(var(--chip) * 1.9);
  justify-content: flex-start;
}

.bet__stack .chip {
  margin-top: calc(var(--chip) * -.62);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .4));
}

.bet__amount {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--gold-hi);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .5);
}

.bet__amount::before {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 5px;
  border-radius: 50%;
  vertical-align: -1px;
  background: radial-gradient(circle at 35% 30%, #fff3d3, #d8ab5f 60%, #9a7132);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}

/* ---------- Console ---------- */

.console {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 6px max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-bottom));
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.console__bar {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.console__bar--bet {
  justify-content: center;
  position: relative;
}

.console__bar--actions {
  justify-content: center;
  min-height: 50px;
}

.shoe-meter {
  position: absolute;
  right: 2px;
  bottom: 4px;
  width: 42px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
  opacity: .8;
}

.shoe-meter span {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
  transform-origin: left center;
  transition: transform .4s var(--ease);
}

/* ---------- Couche d'effets ---------- */

.fx {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  overflow: hidden;
}

/* ---------- Tailles ---------- */

.app[data-size="md"] { --topbar-h: 50px; --console-h: 104px; }
.app[data-size="xs"] { --topbar-h: 38px; --console-h: 88px; }

.app[data-size="xs"] .topbar { gap: 6px; }
.app[data-size="xs"] .brand__text { font-size: 9px; letter-spacing: .18em; }
.app[data-size="xs"] .credit { height: 30px; padding: 0 11px 0 8px; }
.app[data-size="xs"] .credit__value { font-size: 13px; }
.app[data-size="xs"] .credit__coin { width: 14px; height: 14px; }
.app[data-size="xs"] .iconbtn { width: 32px; height: 32px; }
.app[data-size="xs"] .console { gap: 5px; padding-bottom: 6px; }
.app[data-size="xs"] .console__bar--actions { min-height: 40px; }
.app[data-size="xs"] .shoe { width: 40px; height: 24px; }

.app[data-narrow="1"] .brand__text { display: none; }
.app[data-size="xs"][data-narrow="1"] .brand { display: none; }
