
:root {
  --bg: #10100f;
  --panel: #1b1a17;
  --gold: #e2bd66;
  --gold-light: #ffdf91;
  --text: #f5f1e8;
  --muted: #aaa69b;
  --line: rgba(226, 189, 102, .3);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: #080807;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

button, input {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

#app {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(ellipse at top, #29251b, #10100f 65%);
  border-left: 1px solid #403725;
  border-right: 1px solid #403725;
}

.page {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(75px + env(safe-area-inset-bottom));
}

.page.active {
  display: block;
}

.secondary-page {
  background:
    linear-gradient(#10100fdc, #10100ff0),
    radial-gradient(ellipse at top, #44351f, #10100f 75%);
}

.game-header {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  padding: 10px 8px;
  background: #10100ff5;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--gold);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
}

.balance-box {
  min-height: 36px;
  padding: 7px 5px;
  border: 1px solid var(--gold);
  border-radius: 5px;
  background: linear-gradient(145deg, #302719, #12110e);
  overflow-wrap: anywhere;
}

#balance {
  color: var(--gold-light);
  font-size: clamp(14px, 4vw, 18px);
  font-weight: 900;
}

.currency {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.xp-area {
  min-width: 0;
  padding-top: 16px;
}

.xp-label {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
}

.xp-track {
  height: 9px;
  overflow: hidden;
  border: 1px solid #6e5b31;
  border-radius: 20px;
  background: #35332d;
}

.xp-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #a67a25, #ffe69c);
  transition: width .25s ease;
}

.xp-progress, .xp-remaining {
  margin-top: 4px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.player-area {
  min-width: 0;
  text-align: right;
}

.player-name {
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.level-pill {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 5px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  color: var(--gold-light);
  font-size: 9px;
}

.game-scene {
  position: relative;
  height: clamp(235px, 36vh, 330px);
  overflow: hidden;
  background: radial-gradient(ellipse, #267b52, #125236 60%, #071b14);
  border-bottom: 2px solid #735522;
}

#threeContainer {
  position: absolute;
  inset: 0;
  z-index: 1;
}

#threeContainer canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.table-overlay {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 5px;
  pointer-events: none;
}

.hand {
  min-height: 65px;
  text-align: center;
}

.hand-title {
  margin-bottom: 5px;
  color: #fff3cb;
  font-size: 10px;
  font-weight: 900;
  text-shadow: 0 1px 4px #000;
}

.cards {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 58px;
}

.playing-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  width: 37px;
  height: 53px;
  padding: 3px;
  border: 1px solid #d6d0c2;
  border-radius: 4px;
  background: #fffdf6;
  color: #171717;
  box-shadow: 0 3px 8px #0008;
  font-size: 11px;
  font-weight: 900;
  animation: cardAppear .2s ease-out;
}

.playing-card.red {
  color: #bc1f2c;
}

.playing-card .suit-large {
  align-self: center;
  font-size: 19px;
}

.playing-card.hidden-card {
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    45deg, #182b3c, #182b3c 5px, #29445a 5px, #29445a 10px
  );
  border: 2px solid #f2d48b;
  color: var(--gold);
  font-size: 22px;
}

@keyframes cardAppear {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.round-message {
  align-self: center;
  max-width: 95%;
  padding: 6px 10px;
  border: 1px solid #ffffff32;
  border-radius: 5px;
  background: #000b;
  color: #fff0bd;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.game-controls {
  padding: 9px 7px 12px;
  background: linear-gradient(#181714, #0e0e0d);
}

.action-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.action-button {
  min-width: 0;
  min-height: 38px;
  padding: 7px 3px;
  border: 1px solid #72674c;
  border-radius: 5px;
  background: linear-gradient(#36342e, #1c1b18);
  font-size: 10px;
  font-weight: 800;
}

.action-button.primary {
  color: #17130a;
  border-color: #f5d889;
  background: linear-gradient(#f7dfa0, #c49a43);
}

.action-button:active:not(:disabled) {
  filter: brightness(1.12);
}

.bet-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 65px 57px;
  gap: 5px;
  align-items: end;
  margin-top: 12px;
}

.chips {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
}

.chip {
  flex: 1;
  max-width: 35px;
  aspect-ratio: 1;
  padding: 0;
  border: 2px dashed #fff9;
  border-radius: 50%;
  box-shadow: 0 3px 5px #0009;
  color: white;
  font-size: 9px;
  font-weight: 900;
}

.chip-10 { background: #b72f39; }
.chip-25 { background: #2464b4; }
.chip-50 { background: #288a56; }
.chip-100 { background: #343434; border-color: #e3bf6d; }
.chip-500 { background: #8151ae; }

.chip.selected {
  outline: 2px solid var(--gold-light);
  outline-offset: 1px;
  transform: translateY(-2px);
}

.bet-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
}

input {
  min-width: 0;
  max-width: 100%;
  color: white;
  background: #24231f;
  border: 1px solid #665632;
  border-radius: 5px;
  padding: 9px 6px;
}

.bet-input-wrap input {
  width: 100%;
  min-height: 36px;
  padding: 7px 4px;
  font-size: 12px;
}

.game-status {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 9px;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 430px);
  padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: #10100ff7;
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.nav-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 49px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: #99958a;
  font-size: 10px;
  font-weight: 700;
}

.nav-icon {
  font-size: 18px;
  line-height: 1;
}

.nav-button.active {
  color: var(--gold-light);
}

.page-content {
  padding: 18px 10px 25px;
}

.page-content h1 {
  margin: 0 0 6px;
  color: var(--gold-light);
  font-size: 23px;
}

.page-subtitle {
  margin: 0 0 17px;
  color: var(--muted);
  font-size: 11px;
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.stat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(80px, .72fr);
  gap: 6px;
}

.stat-label, .stat-value {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #1b1a17ef;
  font-size: 10px;
  overflow-wrap: anywhere;
}

.stat-value {
  justify-content: flex-end;
  text-align: right;
  color: var(--gold-light);
  font-weight: 900;
}

.panel {
  margin-bottom: 11px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.panel h2 {
  margin: 0 0 10px;
  color: var(--gold-light);
  font-size: 15px;
}

.panel > label {
  display: block;
  margin-bottom: 8px;
  color: var(--gold-light);
  font-size: 11px;
  font-weight: 800;
}

.panel > input {
  display: block;
  width: 100%;
  margin-bottom: 8px;
}

.cheat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.cheat-row input {
  width: 100%;
  font-size: 12px;
}

.full {
  width: 100%;
  margin-top: 8px;
}

.notice, .help-text {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.notice {
  padding: 10px;
  border-left: 3px solid var(--gold);
  background: #292318;
}

.switch-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.switch-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--gold);
}

.danger-panel {
  border-color: #77353a;
}

.danger {
  background: #76252d;
  border-color: #c34e58;
}

.settings-message {
  color: var(--gold-light);
  font-size: 11px;
}

/* POP-UP COMPACT ET CARRÉ */
.modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background: #000d;
}

.modal[hidden] {
  display: none;
}

.event-box {
  position: relative;
  width: min(78vw, 280px);
  max-width: 280px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  border: 1px solid var(--gold);
  border-radius: 8px;
  background: #151410;
  box-shadow: 0 12px 40px #000b;
  animation: modalIn .2s ease-out;
}

.event-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #292116;
}

.event-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-close {
  position: absolute;
  z-index: 2;
  top: 5px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #ffffff99;
  border-radius: 50%;
  background: #000b;
  color: white;
  font-size: 21px;
}

.event-text {
  padding: 11px;
  text-align: center;
}

.event-text h2 {
  margin: 0 0 6px;
  color: var(--gold-light);
  font-size: 19px;
}

.event-text p {
  margin: 0;
  color: #e8e0ce;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-line;
}

.event-text .action-button {
  min-height: 35px;
  margin-top: 9px;
}

@keyframes modalIn {
  from { transform: scale(.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.toast {
  position: fixed;
  z-index: 150;
  left: 50%;
  bottom: calc(70px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: min(360px, calc(100% - 24px));
  padding: 9px 12px;
  border: 1px solid var(--gold);
  border-radius: 5px;
  background: #17150ff5;
  color: var(--gold-light);
  text-align: center;
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.toast.visible {
  opacity: 1;
}

@media (max-width: 350px) {
  .game-header {
    padding: 8px 5px;
    gap: 4px;
  }

  .game-controls {
    padding-left: 5px;
    padding-right: 5px;
  }

  .action-button {
    font-size: 9px;
  }

  .bet-panel {
    grid-template-columns: minmax(0, 1fr) 58px 52px;
    gap: 4px;
  }

  .chip {
    font-size: 8px;
  }

  .event-box {
    width: min(82vw, 260px);
  }
}
