/* =========================================================================
   COMBO DICE — styles.css (v4)
   ========================================================================= */

:root{
  --bg:            #12172a;
  --bg-deep:       #0b0f1c;
  --panel:         #1b2340;
  --panel-alt:     #222b4d;
  --panel-line:    #333f68;
  --panel-raised:  #2a3559;

  --text:          #eef1fb;
  --text-dim:      #b7c0e0;
  --text-faint:    #7c88b3;

  --accent:        #e8a33d;
  --accent-strong: #cf8620;
  --accent-soft:   #f2c56b;
  --teal:          #35c6b0;
  --gold:          #ffd166;

  --good:          #5fd68a;
  --bad:           #ff6b6b;
  --info:          #4fb8e8;

  --row-pair:   #4fa8e8;
  --row-brelan: #5fd68a;
  --row-full:   #e8c93d;
  --row-carre:  #e8a33d;
  --row-gsuite: #e8703d;
  --row-yams:   #ff5c5c;

  --radius-s:  10px;
  --radius-m:  16px;
  --radius-l:  24px;
  --shadow-1:  0 2px 8px rgba(0,0,0,.35);
  --shadow-2:  0 10px 30px rgba(0,0,0,.5);

  --font-display: 'Rubik', 'Inter', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  background:
    radial-gradient(1100px 700px at 12% -10%, #1a2348 0%, transparent 60%),
    radial-gradient(900px 600px at 105% 15%, #17203e 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.4;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4{ font-family: var(--font-display); margin: 0; }
p{ margin: 0; }
button{ font-family: var(--font-body); }
::selection{ background: var(--accent); color: #1c1226; }
@media (prefers-reduced-motion: reduce){ *{ animation-duration:.001ms !important; transition-duration:.001ms !important; } }

#app{ position: relative; width: 100vw; height: 100vh; }
.screen{ position: absolute; inset: 0; display: none; flex-direction: column; height: 100vh; width: 100vw; overflow: auto; }
.screen.active{ display: flex; }
::-webkit-scrollbar{ width: 8px; height: 8px; }
::-webkit-scrollbar-track{ background: transparent; }
::-webkit-scrollbar-thumb{ background: var(--panel-line); border-radius: 8px; }

/* =========================== BUTTONS ================================= */
.btn{
  font-family: var(--font-display); font-weight: 600; font-size: 15px; border: none;
  border-radius: var(--radius-s); padding: 10px 18px; cursor: pointer; color: var(--text);
  background: var(--panel-raised); border-bottom: 3px solid rgba(0,0,0,.25);
  transition: transform .08s ease, filter .12s ease, opacity .12s ease;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.btn:hover{ filter: brightness(1.15); }
.btn:active{ transform: translateY(2px); border-bottom-width: 1px; }
.btn:disabled{ opacity: .35; cursor: not-allowed; filter: none; transform: none; }
.btn:focus-visible{ outline: 3px solid var(--gold); outline-offset: 2px; }
.btn--primary{ background: linear-gradient(180deg, var(--accent-soft), var(--accent-strong)); color: #2a1a06; border-bottom-color: #8a5c11; }
.btn--good{ background: linear-gradient(180deg, #8fe8ac, var(--good)); color: #0a2b16; border-bottom-color: #237a44; }
.btn--ghost{ background: transparent; border: 2px solid var(--panel-line); border-bottom: 2px solid var(--panel-line); }
.btn--ghost:hover{ border-color: var(--accent-soft); }
.btn--small{ padding: 6px 12px; font-size: 13px; }
.btn--block{ width: 100%; justify-content: center; }

/* =========================== SETUP SCREEN ============================= */
.setup-wrap{ max-width: 720px; margin: 0 auto; padding: 28px 20px 60px; display: flex; flex-direction: column; gap: 16px; }
.setup-hero{ text-align: center; padding: 10px 0 6px; }
.setup-hero__emoji{ font-size: 26px; letter-spacing: 6px; color: var(--accent-soft); }
.setup-hero__title{
  font-size: 52px; font-weight: 800; letter-spacing: .5px;
  background: linear-gradient(180deg, var(--accent-soft), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent; margin: 2px 0;
}
.setup-hero__subtitle{ color: var(--text-dim); font-size: 14px; }
.setup-card{ background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius-m); padding: 16px 18px; }
.setup-card__title{ font-size: 16px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.setup-card__title .num{
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #2a1a06; font-size: 12px; font-weight: 800;
}
.setup-card__hint{ color: var(--text-faint); font-size: 12.5px; line-height: 1.6; }
.chip-row{ display: flex; flex-wrap: wrap; gap: 8px; }
.chip{
  padding: 8px 16px; border-radius: 999px; border: 2px solid var(--panel-line); background: var(--panel-alt);
  color: var(--text-dim); cursor: pointer; font-weight: 700; font-family: var(--font-display); font-size: 14px;
  transition: all .12s ease;
}
.chip:hover{ border-color: var(--accent-soft); }
.chip.is-selected{ background: var(--accent); border-color: var(--accent-strong); color: #2a1a06; }
.player-name-grid{ display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 10px; }
.player-name-field{ display: flex; align-items: center; gap: 8px; background: var(--panel-alt); border: 1px solid var(--panel-line); border-radius: var(--radius-s); padding: 8px 10px; }
.player-name-field__swatch{ width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0; display:flex; align-items:center; justify-content:center; font-size:14px; }
.player-name-field input{ flex: 1; min-width: 0; background: transparent; border: none; color: var(--text); font-weight: 700; font-size: 14px; outline: none; }
.field-label{ font-size: 12.5px; color: var(--text-dim); font-weight: 700; display:block; margin-bottom: 6px; }
.field-num{ width: 100%; background: var(--panel-alt); border: 1px solid var(--panel-line); color: var(--text); border-radius: var(--radius-s); padding: 9px 10px; font-size: 14px; font-weight: 700; }
.setup-footer{ display: flex; justify-content: center; padding-top: 8px; }

/* =========================== GAME SCREEN =============================== */
#screen-game{ background: var(--bg); }
#hud{
  flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: var(--bg-deep); border-bottom: 1px solid var(--panel-line);
}
.hud-brand{ font-family: var(--font-display); font-weight: 800; font-size: 15px; color: var(--accent-soft); flex-shrink: 0; padding-right: 6px; }
.hud-players{ display: flex; gap: 8px; flex: 1; min-width: 0; overflow-x: auto; }
.hud-chip{
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--panel);
  border: 2px solid var(--panel-line); border-radius: var(--radius-s); flex-shrink: 0; min-width: 148px;
}
.hud-chip.is-active{ border-color: var(--accent); background: var(--panel-alt); box-shadow: 0 0 0 2px rgba(232,163,61,.25); }
.hud-chip__avatar{ font-size: 18px; width: 26px; text-align: center; flex-shrink:0; }
.hud-chip__body{ min-width: 0; flex: 1; }
.hud-chip__name{ font-size: 12.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-chip__meta{ display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); }
.hud-chip__bar{ height: 4px; border-radius: 3px; background: var(--panel-line); margin-top: 3px; overflow: hidden; }
.hud-chip__bar-fill{ height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); }
.hud-chip__coins{ color: var(--gold); font-weight: 800; }

#round-banner{
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 5px 10px;
  font-family: var(--font-display); font-size: 13px; color: var(--text-dim); background: var(--panel); border-bottom: 1px solid var(--panel-line);
}
#round-banner b{ color: var(--text); }

#stage{ flex: 1; min-height: 0; position: relative; overflow: hidden; }
#player-viewport{ position: absolute; inset: 0; overflow: auto; }
.player-panel{ position: absolute; inset: 0; padding: 12px 14px; }
.panel-cols{ width: 100%; min-height: 100%; display: flex; gap: 14px; }

.side-rail{ width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }
.side-rail__name{ font-size: 20px; font-weight: 800; font-family: var(--font-display); padding: 2px 2px 4px; }
.side-stat{ background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius-m); padding: 10px 12px; flex-shrink: 0; }
.side-stat__row{ display: flex; align-items: center; justify-content: space-between; }
.side-stat__label{ font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.side-stat__value{ font-family: var(--font-display); font-weight: 800; font-size: 18px; }
.side-stat__value.accent{ color: var(--accent-soft); }
.side-stat__value.gold{ color: var(--gold); }
.quota-progress__bar{ height: 8px; border-radius: 5px; background: var(--panel-line); overflow: hidden; margin-top: 8px; }
.quota-progress__fill{ height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .3s ease; }

.items-card{ background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius-m); padding: 10px 12px; }
.items-card__title{ font-size: 11px; font-weight: 800; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.items-empty{ color: var(--text-faint); font-size: 12px; }

.board-main{ flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }

/* ------------------------------ DÉS ------------------------------------ */
.dice-card{ background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius-m); padding: 12px 14px; flex-shrink: 0; }
.dice-card__head{ display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.dice-card__title{ font-size: 12.5px; font-weight: 800; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.reroll-tokens{ font-size: 12.5px; color: var(--text-dim); }
.reroll-tokens b{ color: var(--gold); }
.dice-row{ display: flex; flex-wrap: wrap; gap: 10px; }

.die-slot{ width: 64px; height: 64px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; }
.die-slot--empty{ background: var(--panel-alt); border: 2px dashed var(--panel-line); }
.die-input{
  width: 44px; height: 44px; text-align: center; font-size: 22px; font-weight: 800; font-family: var(--font-display);
  background: var(--panel); border: 2px solid var(--panel-line); border-radius: 10px; color: var(--text); outline: none;
}
.die-input:focus{ border-color: var(--accent-soft); }
.die-slot--set{ background: var(--panel-raised); border: 2px solid var(--accent); }
.die-slot--bonus{ background: var(--panel-alt); border: 2px dashed var(--gold); opacity: .9; }
.die-face{ font-size: 26px; font-weight: 800; font-family: var(--font-display); }
.die-tools{ display: flex; gap: 3px; position: absolute; bottom: -12px; }
.die-tool-btn{
  width: 20px; height: 20px; border-radius: 6px; border: none; background: var(--panel-line); color: var(--text);
  font-size: 11px; cursor: pointer; display:flex; align-items:center; justify-content:center; line-height:1;
}
.die-tool-btn:hover{ background: var(--accent); color: #2a1a06; }
.die-tool-btn:disabled{ opacity: .3; cursor: not-allowed; }
.die-slot--pickable{ cursor: pointer; border-color: var(--gold) !important; animation: cell-pulse 1.4s ease-in-out infinite; }
.die-pick-hint{ font-size: 8px; color: var(--gold); position: absolute; bottom: -12px; white-space: nowrap; }
.dice-hint{ font-size: 12px; color: var(--gold); margin-top: 8px; }

/* --------------------------- APERÇU EN DIRECT --------------------------- */
.preview-card{ background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius-m); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.preview-card__title{ font-size: 11px; font-weight: 800; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.preview-lines{ display: flex; flex-direction: column; gap: 3px; max-height: 160px; overflow-y: auto; }
.preview-line{ font-size: 11.5px; color: var(--text-dim); background: var(--panel-alt); border-radius: 6px; padding: 3px 7px; }
.preview-empty{ font-size: 12px; color: var(--text-faint); font-style: italic; }
.preview-total{ font-size: 13.5px; font-weight: 700; color: var(--accent-soft); border-top: 1px dashed var(--panel-line); padding-top: 6px; }

/* ------------------------------ PLATEAU --------------------------------- */
.board-card{ background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius-m); padding: 10px 16px 12px; flex: 1; min-height: 380px; display: flex; flex-direction: column; gap: 8px; }
.board-card__title{ font-size: 11.5px; font-weight: 700; color: var(--text-faint); text-align: center; }
.board-tower{ display: flex; flex-direction: column; flex: 1; gap: 8px; }
.board-row{ flex: 1; display: flex; align-items: center; gap: 10px; padding: 5px 10px; border-radius: var(--radius-s); background: var(--panel-alt); border-left: 5px solid var(--row-color, var(--accent)); opacity: .75; }
.board-row.is-achievable{ opacity: 1; box-shadow: inset 0 0 0 1px rgba(255,209,102,.3); }
.board-row__label{ width: 128px; flex-shrink: 0; font-size: 12.5px; font-weight: 800; line-height: 1.2; }
.board-row__label small{ display:block; font-weight: 600; color: var(--text-faint); font-size: 9.5px; margin-top:1px; }
.board-row__cells{ display: flex; gap: 6px; flex: 1; }
.board-row__side{ width: 66px; flex-shrink: 0; text-align: right; }
.row-token-badge{ font-size: 9px; font-weight: 800; color: var(--teal); background: rgba(53,198,176,.12); border: 1px solid rgba(53,198,176,.35); border-radius: 999px; padding: 2px 6px; white-space: nowrap; }

.cell{
  flex: 1; min-width: 0; aspect-ratio: 1; max-height: 58px; border-radius: 14px; background: var(--panel);
  border: 2px solid var(--panel-line); display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; font-family: var(--font-display); transition: transform .1s ease, box-shadow .15s ease;
}
.cell__pts{ font-size: clamp(11px, 1.3vw, 15px); font-weight: 800; color: var(--text-dim); }
.cell__badges{ position: absolute; bottom: 3px; display: flex; gap: 4px; align-items: center; }
.cell__coins{ font-size: 8px; color: var(--gold); }
.cell__token{ font-size: 8px; }
.cell.is-done{ background: var(--row-color, var(--accent)); border-color: var(--row-color, var(--accent)); }
.cell.is-done .cell__pts, .cell.is-done .cell__coins{ color: rgba(0,0,0,.55); }
.cell.is-crossed{ background: var(--panel-alt); border-color: var(--bad); }
.cell.is-crossed .cell__pts{ opacity: .3; text-decoration: line-through; }
.cell__crossmark{ position: absolute; font-size: 20px; color: var(--bad); font-weight: 800; }
.cell.is-clickable{ cursor: pointer; border-color: var(--gold); animation: cell-pulse 1.8s ease-in-out infinite; }
.cell.is-clickable:hover{ transform: scale(1.08); }
.cell.is-pending-validate{ background: var(--good); border-color: var(--good); cursor: pointer; }
.cell.is-pending-validate .cell__pts{ color: #0a2b16; }
.cell.is-pending-cross{ background: rgba(255,107,107,.3); border-color: var(--bad); cursor: pointer; }
@keyframes cell-pulse{ 0%,100%{ box-shadow: 0 0 0 2px rgba(255,209,102,.3);} 50%{ box-shadow: 0 0 0 5px rgba(255,209,102,.1);} }

/* ------------------------- CARTES IMMEDIATES ----------------------------- */
.immediate-hand{ display: flex; flex-direction: column; gap: 6px; }
.immediate-card{ display: flex; align-items: center; gap: 8px; background: var(--panel-alt); border: 1px solid var(--panel-line); border-radius: var(--radius-s); padding: 7px 9px; }
.immediate-card__icon{ font-size: 20px; width: 30px; text-align: center; flex-shrink: 0; }
.immediate-card__body{ flex: 1; min-width: 0; }
.immediate-card__name{ font-weight: 800; font-size: 12px; }
.immediate-card__desc{ font-size: 10.5px; color: var(--text-faint); }
.copy-pick-list{ display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.copy-pick-btn{ width: 100%; justify-content: flex-start; text-align: left; }
.modal-inline-hint{ font-size: 12px; color: var(--text-faint); margin-top: 6px; }

.permanent-cards-list{ display: flex; flex-direction: column; gap: 6px; }
.permanent-card{ display: flex; align-items: center; gap: 8px; background: var(--panel-alt); border: 1px solid var(--panel-line); border-left: 3px solid var(--info); border-radius: var(--radius-s); padding: 7px 9px; }
.permanent-card--score{ border-left-color: var(--good); }
.permanent-card__icon{ font-size: 18px; width: 26px; text-align: center; flex-shrink: 0; }
.permanent-card__body{ flex: 1; min-width: 0; }
.permanent-card__name{ font-weight: 800; font-size: 12px; }
.permanent-card__desc{ font-size: 10.5px; color: var(--text-faint); }

/* =========================== MODALS =================================== */
.modal{ position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; background: rgba(6,9,20,.75); backdrop-filter: blur(2px); }
.modal.show{ display: flex; }
.modal__box{ background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius-l); max-width: 920px; width: 92vw; max-height: 88vh; overflow: auto; box-shadow: var(--shadow-2); display: flex; flex-direction: column; }
.modal__box--narrow{ max-width: 560px; }
.modal__head{ display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--panel-line); flex-shrink: 0; position: sticky; top:0; background: var(--panel); z-index:2; }
.modal__title{ font-size: 20px; font-weight: 800; }
.modal__body{ padding: 18px 20px; }
.modal__foot{ padding: 14px 20px; border-top: 1px solid var(--panel-line); display: flex; justify-content: flex-end; gap: 10px; flex-shrink:0; }
.modal__close{ background: transparent; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.modal__close:hover{ background: var(--panel-alt); color: var(--text); }

/* Shop */
.shop-top{ display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; flex-wrap: wrap; gap: 10px; }
.shop-wallet{ font-family: var(--font-display); font-size: 20px; font-weight: 800; color: var(--gold); }
.shop-grid{ display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
@media (max-width: 900px){ .shop-grid{ grid-template-columns: repeat(2,1fr); } }
.shop-item{ border-radius: var(--radius-m); border: 2px solid var(--panel-line); background: var(--panel-alt); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.shop-item.shop-cat-permanent{ border-color: var(--info); }
.shop-item.shop-cat-score{ border-color: var(--good); }
.shop-item.shop-cat-immediate{ border-color: var(--gold); }
.shop-item--hidden{ border-color: var(--panel-line); border-style: dashed; align-items: center; text-align: center; }
.shop-item__top{ display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.shop-item__icon{ font-size: 26px; }
.shop-item__type{ font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; padding: 2px 7px; border-radius: 999px; background: rgba(0,0,0,.28); }
.shop-item__name{ font-weight: 800; font-size: 13px; font-family: var(--font-display); }
.shop-item__desc{ font-size: 11px; color: var(--text-dim); flex: 1; min-height: 44px; }
.shop-item__buy{ display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shop-item__cost{ font-family: var(--font-display); font-weight: 800; color: var(--gold); font-size: 14px; }
.shop-empty-slot{ border: 2px dashed var(--panel-line); border-radius: var(--radius-m); display: flex; align-items: center; justify-content: center; color: var(--text-faint); font-size: 12px; min-height: 150px; }

/* Fin de partie */
.gameover-wrap{ text-align: center; padding: 10px 0 20px; }
.gameover-crown{ font-size: 54px; }
.gameover-winner{ font-family: var(--font-display); font-size: 28px; font-weight: 800; color: var(--gold); margin: 8px 0 6px; }

/* Toast */
#toast-host{ position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast{ background: var(--bg-deep); border: 1px solid var(--panel-line); color: var(--text); padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 700; box-shadow: var(--shadow-2); animation: toast-in .18s ease; }
@keyframes toast-in{ from{ transform: translateY(8px); opacity:0; } to{ transform: translateY(0); opacity:1; } }

@media (max-width: 980px){
  .panel-cols{ flex-direction: column; }
  .side-rail{ width: 100%; }
}
