:root {
  --gold: #d9ad54;
  --gold-light: #f4d78d;
  --background: #080b0a;
  --panel: rgba(13, 19, 16, .96);
  --text: #f4f1e9;
  --muted: #a7aea7;
  --table-color: #075638;
  --card-background: #fffdf7;
  --card-text: #171717;
  --card-back-color: #173c68;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--background);
}

body {
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  opacity: .38;
  cursor: not-allowed;
}

/* APPLICATION */

.app-shell {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(180deg, #0b120d, #080b09 65%);
  border-left: 1px solid rgba(255,255,255,.04);
  border-right: 1px solid rgba(255,255,255,.04);
  box-shadow: 0 0 60px rgba(0,0,0,.7);
}

#three-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: .72;
}

#three-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.app-content,
main {
  position: relative;
  z-index: 2;
}

/* BARRE SUPÉRIEURE */

.topbar {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  align-items: center;
  gap: 8px;
  padding: 12px 11px 10px;
  background: linear-gradient(
    180deg,
    rgba(5,10,7,.99),
    rgba(5,10,7,.88)
  );
  border-bottom: 1px solid rgba(217,173,84,.23);
}

.hud-block {
  min-width: 0;
}

.hud-label {
  display: block;
  margin-bottom: 3px;
  color: #a9b1aa;
  font-size: 9px;
  letter-spacing: .8px;
  text-transform: uppercase;
}

.money-value {
  color: var(--gold-light);
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.xp-block {
  text-align: center;
}

.xp-text {
  display: block;
  margin-bottom: 5px;
  color: #e7d7ad;
  font-size: 10px;
}

.xp-progress {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 20px;
  background: #1d2720;
}

.xp-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg,#b98730,#ffdf83);
  box-shadow: 0 0 10px rgba(217,173,84,.5);
  transition: width .3s;
}

.player-profile {
  overflow: hidden;
  text-align: right;
}

.player-name {
  display: block;
  overflow: hidden;
  color: white;
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-level {
  display: block;
  margin-top: 3px;
  color: var(--gold);
  font-size: 10px;
}

/* PAGES */

.page {
  display: none;
  position: relative;
  z-index: 2;
  min-height: calc(100vh - 132px);
  padding: 12px 12px 105px;
  animation: pageFade .22s ease;
}

.page.active {
  display: block;
}

@keyframes pageFade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-title {
  margin: 4px 0 14px;
  color: var(--gold-light);
  font-size: 19px;
  font-weight: 900;
}

.page-subtitle {
  margin: -7px 0 15px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

/* TABLE */

#page-game {
  padding: 7px 9px 110px;
}

.game-layout {
  position: relative;
  min-height: 640px;
}

.table-felt {
  position: absolute;
  top: 26px;
  left: -20%;
  width: 140%;
  height: 465px;
  overflow: hidden;
  border: 11px solid #392719;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    var(--table-color) 0%,
    #06442d 68%,
    #052f20 100%
  );
  box-shadow:
    inset 0 0 0 3px rgba(220,175,86,.34),
    inset 0 0 45px rgba(0,0,0,.45),
    0 12px 25px rgba(0,0,0,.5);
  pointer-events: none;
}

.table-felt::before {
  content: "";
  position: absolute;
  inset: 20px;
  border: 1px solid rgba(239,207,139,.24);
  border-radius: 50%;
}

.table-felt::after {
  content: "BLACKJACK";
  position: absolute;
  top: 25%;
  left: 0;
  width: 100%;
  color: rgba(255,236,185,.14);
  font-family: Georgia,serif;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 7px;
  text-align: center;
}

.dealer-zone,
.player-zone,
.opponents-row {
  position: relative;
  z-index: 5;
  text-align: center;
}

.dealer-zone {
  min-height: 134px;
  padding-top: 12px;
}

.zone-title {
  margin-bottom: 7px;
  color: #e8d7ad;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 0 2px 4px #000;
}

.hand-cards,
.cards-row {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.hand-total {
  display: inline-block;
  min-width: 24px;
  margin-top: 4px;
  padding: 3px 8px;
  border: 1px solid rgba(235,205,139,.35);
  border-radius: 20px;
  background: rgba(0,0,0,.53);
  color: #fff1c8;
  font-size: 11px;
  font-weight: 800;
}

.opponents-row {
  display: flex;
  min-height: 115px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 4px 0;
}

.opponent {
  width: 29%;
  min-width: 82px;
  text-align: center;
}

.opponent-name {
  margin-bottom: 4px;
  color: #d7c9a7;
  font-size: 10px;
  font-weight: 800;
}

.opponent .hand-cards {
  min-height: 64px;
  gap: 3px;
}

.opponent .playing-card {
  width: 37px;
  height: 55px;
  border-radius: 5px;
}

.opponent .card-value {
  font-size: 12px;
}

.player-zone {
  margin-top: 9px;
  padding: 5px 0 9px;
}

.player-zone .zone-title {
  color: var(--gold-light);
  font-size: 12px;
}

.player-hands {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

.player-hand {
  min-width: 100px;
  max-width: 49%;
  padding: 5px;
  border: 1px solid transparent;
  border-radius: 10px;
}

.player-hand.current {
  border-color: rgba(244,215,141,.65);
  background: rgba(0,0,0,.18);
  box-shadow: 0 0 14px rgba(244,215,141,.12);
}

.player-hand .hand-cards {
  gap: 4px;
}

/* CARTES */

.playing-card {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  width: 55px;
  height: 80px;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px;
  overflow: hidden;
  border: 1px solid #dedbd1;
  border-radius: 7px;
  background: var(--card-background);
  color: var(--card-text);
  box-shadow: 0 5px 9px rgba(0,0,0,.48);
  animation: cardAppear .2s ease;
}

@keyframes cardAppear {
  from {
    opacity: 0;
    transform: translateY(-7px) rotate(-3deg);
  }

  to {
    opacity: 1;
    transform: translateY(0) rotate(0);
  }
}

.card-top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
}

.card-value {
  font-size: 16px;
  font-weight: 900;
}

.card-suit-small {
  margin-top: 2px;
  font-size: 10px;
}

.card-center {
  align-self: center;
  font-size: 27px;
  line-height: 1;
}

.card-bottom {
  align-self: flex-end;
  font-size: 11px;
  font-weight: 900;
  transform: rotate(180deg);
}

.red-suit {
  color: #c62836;
}

.black-suit {
  color: #171717;
}

.card-back {
  border: 2px solid #e4d7b5;
  background:
    repeating-linear-gradient(
      45deg,
      transparent 0 5px,
      rgba(255,255,255,.13) 5px 7px
    ),
    var(--card-back-color);
}

.card-back::after {
  content: "W";
  display: grid;
  position: absolute;
  inset: 8px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.36);
  border-radius: 3px;
  color: rgba(255,255,255,.78);
  font-family: Georgia,serif;
  font-size: 19px;
  font-weight: 900;
}

/* COMMANDES */

.game-controls {
  position: relative;
  z-index: 15;
  margin-top: 8px;
  padding: 11px 9px;
  border: 1px solid rgba(217,173,84,.25);
  border-radius: 16px;
  background: linear-gradient(
    145deg,
    rgba(12,23,17,.97),
    rgba(5,12,8,.98)
  );
  box-shadow: 0 8px 20px rgba(0,0,0,.42);
}

.control-title {
  margin: 0 0 8px;
  color: #d6c397;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.bet-line {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 9px;
}

.bet-line input,
.input-field {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 11px;
  outline: none;
  border: 1px solid rgba(217,173,84,.35);
  border-radius: 9px;
  background: #101c15;
  color: white;
}

.bet-line input:focus,
.input-field:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(217,173,84,.12);
}

.bet-line button {
  flex: 0 0 110px;
}

.chip-scroll {
  display: flex;
  gap: 7px;
  padding: 3px 1px 11px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) #18221b;
}

.chip-scroll::-webkit-scrollbar {
  height: 4px;
}

.chip-scroll::-webkit-scrollbar-thumb {
  border-radius: 5px;
  background: var(--gold);
}

.chip {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 3px dashed rgba(255,255,255,.75);
  border-radius: 50%;
  color: white;
  font-size: 10px;
  font-weight: 900;
  text-shadow: 0 1px 2px #000;
  box-shadow: 0 3px 6px rgba(0,0,0,.45);
}

.chip.selected {
  outline: 2px solid var(--gold-light);
  outline-offset: 2px;
  transform: translateY(-2px);
}

.chip-white {
  background: #eee;
  color: #171717;
  text-shadow: none;
}

.chip-pink { background: #dc6ba7; }
.chip-orange { background: #e67d24; }
.chip-red { background: #c52835; }
.chip-green { background: #135a3b; }
.chip-blue { background: #1f65bc; }
.chip-black { background: #171717; }

.chip-lightgreen {
  background: #8fbf56;
  color: #111;
  text-shadow: none;
}

.chip-purple { background: #7138a8; }

.chip-yellow {
  background: #e3c12c;
  color: #171717;
  text-shadow: none;
}

.chip-salmon { background: #dc8778; }

.chip-peach {
  background: #e9a56c;
  color: #171717;
  text-shadow: none;
}

.chip-gold { background: #bf9135; }

.action-row {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 7px;
  margin-top: 8px;
}

.primary-button,
.secondary-button,
.danger-button,
.gold-button {
  min-height: 39px;
  padding: 8px 7px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 9px;
  color: white;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .25px;
  transition: transform .12s, filter .12s;
}

.primary-button:active,
.secondary-button:active,
.danger-button:active,
.gold-button:active {
  transform: scale(.97);
}

.primary-button {
  border-color: #a8c7a9;
  background: linear-gradient(145deg,#178b57,#075c38);
}

.secondary-button {
  background: linear-gradient(145deg,#36483c,#1a2a20);
}

.danger-button {
  border-color: #bd5c60;
  background: linear-gradient(145deg,#ad303a,#741b27);
}

.gold-button {
  border-color: #e1c078;
  background: linear-gradient(145deg,#d6a746,#8c6020);
  color: #17120a;
}

.full-button {
  width: 100%;
}

.advanced-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 9px;
}

.bot-selector {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: #d7c9a7;
  font-size: 10px;
}

.bot-selector .input-field {
  width: 55px;
  height: 36px;
  padding: 0 5px;
}

.game-message {
  min-height: 18px;
  margin-top: 8px;
  color: #f4d78d;
  font-size: 11px;
  text-align: center;
}

/* NAVIGATION */

.bottom-nav {
  position: fixed;
  z-index: 40;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 7px 5px calc(7px + var(--safe-bottom));
  justify-content: space-around;
  border-top: 1px solid rgba(217,173,84,.25);
  background: rgba(5,10,7,.98);
  box-shadow: 0 -8px 25px rgba(0,0,0,.42);
}

.nav-button {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #8f9b91;
  font-size: 9px;
  font-weight: 700;
}

.nav-icon {
  font-size: 17px;
  line-height: 1;
}

.nav-button.active {
  background: rgba(217,173,84,.1);
  color: var(--gold-light);
}

/* PANNEAUX */

.panel,
.settings-card,
.bonus-card {
  margin-bottom: 11px;
  padding: 13px;
  border: 1px solid rgba(217,173,84,.2);
  border-radius: 14px;
  background: linear-gradient(
    145deg,
    rgba(22,32,25,.96),
    rgba(10,17,12,.96)
  );
  box-shadow: 0 5px 14px rgba(0,0,0,.24);
}

.panel h3,
.settings-card h3 {
  margin: 0 0 10px;
  color: var(--gold-light);
  font-size: 13px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-group label,
.setting-row label {
  color: #d2d7d2;
  font-size: 11px;
  font-weight: 700;
}

input[type="color"] {
  width: 100%;
  height: 35px;
  padding: 3px;
  border: 1px solid rgba(217,173,84,.25);
  border-radius: 8px;
  background: #101c15;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}

.setting-row {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.setting-row:last-child {
  border-bottom: 0;
}

/* STATISTIQUES */

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-row {
  display: flex;
  min-height: 39px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 9px;
  background: rgba(255,255,255,.035);
}

.stat-label {
  color: #c0c8c1;
  font-size: 11px;
}

.stat-value {
  color: var(--gold-light);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}

/* BONUS */

.bonus-card {
  text-align: center;
}

.bonus-card p {
  color: #c6cec7;
  font-size: 12px;
}

.bonus-amount {
  margin: 13px 0;
  color: var(--gold-light);
  font-size: 28px;
  font-weight: 900;
}

.bonus-calendar {
  display: grid;
  grid-template-columns: repeat(7,1fr);
  gap: 6px;
  margin: 14px 0;
}

.bonus-day {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid rgba(217,173,84,.2);
  border-radius: 8px;
  background: rgba(255,255,255,.035);
  color: #aeb7ae;
  font-size: 10px;
}

.bonus-day.claimed {
  border-color: #b38b3d;
  background: rgba(217,173,84,.16);
  color: var(--gold-light);
}

.bonus-day.current {
  border-color: var(--gold-light);
  box-shadow: 0 0 12px rgba(217,173,84,.18);
}

/* MODALE RÉSULTAT */

.result-modal,
.modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0,0,0,.84);
  backdrop-filter: blur(7px);
}

.result-modal.show,
.modal.show {
  display: flex;
  animation: modalFade .2s ease;
}

@keyframes modalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.result-box,
.modal-content {
  width: 100%;
  max-width: 390px;
  overflow: hidden;
  border: 1px solid rgba(244,215,141,.55);
  border-radius: 18px;
  background: #0c1510;
  box-shadow: 0 16px 55px rgba(0,0,0,.75);
}

.result-art {
  position: relative;
  display: flex;
  min-height: 220px;
  height: 240px;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(
    circle at center,
    #315d42,
    #07130c 70%
  );
}

/* IMAGES PNG DÉCLARÉES EN HTML */

.result-image-stack {
  position: absolute;
  z-index: 1;
  inset: 0;
}

.result-image {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-image.active {
  display: block;
}

.result-image-fallback {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: none;
  place-items: center;
  color: rgba(244,215,141,.65);
  font-family: Georgia,serif;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 5px;
}

.result-overlay {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 45px 15px 15px;
  background: linear-gradient(
    transparent,
    rgba(0,0,0,.9)
  );
  text-align: center;
}

.result-overlay h2 {
  margin: 0 0 6px;
  color: #fff0c4;
  font-size: 23px;
  font-weight: 1000;
  text-shadow: 0 3px 8px #000;
}

.result-overlay p {
  margin: 0;
  color: white;
  font-size: 12px;
  line-height: 1.5;
  text-shadow: 0 2px 4px #000;
}

.result-details {
  padding: 13px 15px 7px;
  text-align: center;
}

.result-details p {
  margin: 5px 0;
  color: #d7ddd7;
  font-size: 12px;
}

.result-details strong {
  color: var(--gold-light);
}

.result-actions {
  padding: 0 15px 15px;
}

/* MODALE DES RÈGLES */

.help-content {
  padding: 16px;
}

.help-content p {
  color: #d2d9d2;
  font-size: 12px;
  line-height: 1.55;
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.help-header h2 {
  color: var(--gold-light);
  font-size: 18px;
}

.help-header button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  background: #17221a;
  color: white;
}

/* NOTIFICATION */

.toast {
  position: fixed;
  z-index: 150;
  right: 15px;
  bottom: calc(85px + var(--safe-bottom));
  left: 15px;
  max-width: 450px;
  margin: auto;
  padding: 12px 15px;
  border: 1px solid rgba(217,173,84,.4);
  border-radius: 12px;
  background: rgba(10,20,13,.97);
  color: #fff0c4;
  font-size: 12px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ANIMATIONS */

body.no-animations *,
body.no-animations *::before,
body.no-animations *::after {
  animation: none !important;
  transition: none !important;
}

/* PETITS ÉCRANS */

@media (max-width: 360px) {
  .playing-card {
    width: 48px;
    height: 71px;
  }

  .card-center {
    font-size: 23px;
  }

  .chip {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
    font-size: 9px;
  }

  .game-controls {
    padding: 9px 7px;
  }

  .advanced-controls {
    grid-template-columns: 1fr;
  }
}