/*!
 * Générateur de structure de tournoi de poker Texas hold'em
 * Copyright (c) 2026 screen97 - https://screen97.fr
 *
 * Tous droits réservés. Ce code source est protégé par le droit d'auteur.
 * Toute reproduction, distribution, modification ou réutilisation, totale ou
 * partielle, est interdite sans autorisation écrite préalable de l'auteur.
 * Voir le fichier LICENSE à la racine du projet.
 */
:root {
  color-scheme: dark;
  --bg: #08170f;
  --bg-2: #0c2018;
  --panel: #10281d;
  --panel-2: #153325;
  --line: #21402f;
  --text: #e8f1ec;
  --muted: #8fa89a;
  --accent: #2ee6a6;
  --accent-ink: #04281b;
  --gold: #e9c46a;
  --warn: #f0a050;
  --danger: #ff7a7a;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 20% -10%, #14402c 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2 { margin: 0; line-height: 1.2; }
h2 { font-size: 0.95rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }

/* ----- en-tête ----- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(8, 23, 15, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 1280px; margin: 0 auto;
  padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }

/* ----- menu en haut à gauche ----- */
.menu-wrap { position: relative; flex: none; }
.menu-btn {
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
  width: 40px; height: 40px; padding: 0; border-radius: 12px; cursor: pointer;
  background: transparent; border: 1px solid var(--accent);
}
.menu-btn span { display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--accent); }
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: rgba(46,230,166,.12); }
.menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 30;
  min-width: 200px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.menu[hidden] { display: none; }
.menu-item {
  display: block; width: 100%; box-sizing: border-box; text-align: left;
  padding: 11px 14px; border: 0; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--text);
  font: inherit; font-weight: 600; font-size: 0.92rem; text-decoration: none;
}
.menu-item:hover, .menu-item:focus-visible { background: rgba(46,230,166,.12); color: var(--accent); outline: none; }
button.menu-item + .menu-item, .menu-item + button.menu-item { border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; }
.suit {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); font-size: 1.5rem;
}
.brand h1 { font-size: 1.15rem; }
.brand p { margin: 0; color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; align-items: center; gap: 8px; flex: none; }
.navlink {
  color: var(--accent); border: 1px solid var(--accent);
  padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 0.85rem; text-decoration: none; white-space: nowrap;
}
.navlink:hover { background: rgba(46,230,166,.12); }
.single { grid-template-columns: 1fr; max-width: 720px; }
.jump {
  display: none; flex: none;
  color: var(--accent-ink); background: var(--accent);
  padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 0.85rem; text-decoration: none;
}

/* ----- mise en page ----- */
.layout {
  max-width: 1280px; margin: 0 auto;
  padding: 18px max(16px, env(safe-area-inset-left)) 28px max(16px, env(safe-area-inset-right));
  display: grid; gap: 18px;
  grid-template-columns: 1fr;
}
@media (min-width: 980px) {
  .layout { grid-template-columns: 380px minmax(0, 1fr); align-items: start; }
  .params { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; }
}

.panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel { padding: 16px; }
.params { display: grid; gap: 12px; background: transparent; border: 0; padding: 0; }
.card { padding: 16px; }
.results { display: grid; gap: 16px; min-width: 0; }

/* ----- champs ----- */
.grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.grid .field:only-child { grid-column: 1 / -1; }
@media (max-width: 420px) { .grid { grid-template-columns: 1fr; } }

.field { display: grid; gap: 6px; font-size: 0.88rem; color: var(--muted); align-content: start; }
.field > span em { font-style: normal; opacity: 0.7; }

input[type="number"], input[type="time"], select {
  width: 100%; min-height: 46px;
  font: inherit; font-size: 1rem; color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px;
  font-variant-numeric: tabular-nums;
}
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
select { appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }

.dur, .unit { display: flex; align-items: center; gap: 6px; }
.dur input { text-align: right; }
.dur b, .unit b { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
.dur input:first-child { flex: 1.1; }
.dur input:nth-of-type(2) { flex: 1; }
.unit input { flex: 1; }
.sub { margin-top: 14px; display: grid; gap: 12px; }
.hint { margin: 10px 0 0; color: var(--muted); font-size: 0.8rem; }

/* interrupteur */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; min-height: 40px; font-size: 0.95rem; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i {
  position: relative; flex: none; width: 46px; height: 26px; border-radius: 999px;
  background: #284637; transition: background .15s;
}
.switch i::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform .15s;
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); background: var(--accent-ink); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-head span { font-size: 0.95rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.card-body > .switch + .grid, .card-body > .grid + .switch { margin-top: 12px; }

.adv summary { cursor: pointer; font-weight: 600; color: var(--accent); list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 36px; }
.adv summary::-webkit-details-marker { display: none; }
.adv summary::after { content: "+"; flex: none; display: grid; place-items: center; width: 36px; font-size: 1.2rem; font-weight: 600; line-height: 1; }
.adv[open] summary::after { content: "-"; }
.adv .grid { margin-top: 14px; }

/* zones repliables */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h2 { margin: 0; }
.card-head .switch { flex: 1; min-width: 0; }
.card-body { margin-top: 14px; }
.card-body.tight { margin-top: 0; }
.fold {
  flex: none; display: grid; place-items: center;
  width: 36px; min-height: 36px; padding: 0;
  background: transparent; color: var(--accent); border: 0; border-radius: 8px;
  font-size: 1.2rem; font-weight: 600; line-height: 1;
}
.none { margin: 14px 0 0; color: var(--muted); font-size: 0.95rem; }
.fold::after { content: "-"; }
.fold[aria-expanded="false"]::after { content: "+"; }
.fold:hover { filter: none; background: rgba(46,230,166,.12); }

.actions { display: flex; justify-content: flex-end; }

button {
  font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  min-height: 42px; padding: 8px 16px; border-radius: 10px;
  color: var(--accent-ink); background: var(--accent); border: 0;
}
button:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.tools button { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }

/* ----- résultats ----- */
.stats { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 2px; align-content: start; min-width: 0; }
.stat-l { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-v { font-size: 1.3rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-s { color: var(--muted); font-size: 0.78rem; }

.alert { padding: 12px 14px; border-radius: 10px; font-size: 0.9rem; margin-bottom: 8px; }
.alert.warn { background: rgba(240, 160, 80, 0.12); border: 1px solid rgba(240, 160, 80, 0.45); color: #ffd7ad; }
.alert.err { background: rgba(255, 122, 122, 0.12); border: 1px solid rgba(255, 122, 122, 0.5); color: #ffc4c4; }
#warnings:empty { display: none; }

.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.bar h2 { margin: 0; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.num { text-align: right; }
.strong { font-weight: 700; }
.muted { color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }

.c-lvl { font-weight: 700; color: var(--accent); width: 44px; }
.c-time .clk { display: block; font-weight: 600; }
.c-time .el { display: block; color: var(--muted); font-size: 0.8rem; }
.c-time .el::before { content: "T+ "; }
.c-sb, .c-bb { font-size: 1.1rem; font-weight: 600; }
.c-den { font-weight: 700; }
.c-notes { white-space: normal; }

.tag { display: inline-block; font-size: 0.72rem; padding: 3px 8px; border-radius: 999px; background: var(--panel-2); color: var(--text); margin: 2px 4px 2px 0; border: 1px solid var(--line); }
.tag-rebuy { background: rgba(240, 160, 80, 0.15); border-color: rgba(240, 160, 80, 0.5); color: #ffd7ad; }
.tag-addon { background: rgba(233, 196, 106, 0.15); border-color: rgba(233, 196, 106, 0.55); color: var(--gold); }
.tag-last { background: rgba(255, 122, 122, 0.14); border-color: rgba(255, 122, 122, 0.5); color: #ffc4c4; }

.row-break td { background: rgba(233, 196, 106, 0.08); color: var(--gold); padding: 12px 10px; }
.row-break strong { margin-right: 10px; }
.row-break .break-when { color: var(--muted); margin-right: 10px; font-size: 0.85rem; }

.no-ante .col-ante, .no-addon .col-addon { display: none; }

.toast { margin: 12px 0 0; padding: 8px 12px; border-radius: 8px; background: var(--panel-2); color: var(--accent); font-size: 0.88rem; }

.foot { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 8px 16px 32px; opacity: 0.9; }
.foot img { height: 36px; width: auto; }
.foot .by { color: var(--muted); font-size: 0.85rem; font-style: italic; }
.foot img.screen97 { height: 30px; }
.foot a { display: inline-flex; transition: opacity .15s; }
.foot a:hover, .foot a:focus-visible { opacity: .75; }

/* ----- mobile ----- */
@media (max-width: 979px) { .jump { display: inline-block; } }
@media (max-width: 600px) {
  .brand p { display: none; }
  th, td { padding: 9px 6px; }
  .col-bb { display: none; }
  .c-sb, .c-bb { font-size: 1rem; }
  .tools button { flex: 1; }
}

/* ----- impression ----- */
@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #000; }
  .top, .params, .tools, .toast, .foot, #summaryPanel { display: none !important; }
  .layout { display: block; padding: 0; }
  .panel { border: 0; background: #fff; padding: 0; }
  h2 { color: #000; }
  .fold { display: none !important; }
  .card-body[hidden] { display: block !important; }
  th, td { color: #000; border-color: #bbb; }
  .c-lvl { color: #000; }
  .row-break td { background: #eee; color: #000; }
  .tag, .tag-rebuy, .tag-addon, .tag-last { background: #fff; color: #000; border-color: #888; }
  .muted, .c-time .el, .row-break .break-when { color: #444; }
  #chipsPanel { break-inside: avoid; margin-top: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .switch i, .switch i::after { transition: none; }
}

/* ----- sélecteurs à molette (smartphone) ----- */
.wheel-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; min-height: 46px; padding: 8px 12px; text-align: left;
  font: inherit; font-size: 1rem; font-weight: 400; font-variant-numeric: tabular-nums;
  color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 10px;
}
.wheel-btn::after {
  content: ""; flex: none; width: 7px; height: 7px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
}
.wheel-btn:hover { filter: none; border-color: var(--accent); }
.wheel-btn.is-empty { color: var(--muted); }

html.wheel-lock, html.wheel-lock body { overflow: hidden; }
.wheel-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0; transition: opacity .18s;
  touch-action: none;
}
.wheel-overlay.open { opacity: 1; }
.wheel-sheet {
  --wi: 34px;
  width: 100%; max-width: 480px;
  background: var(--panel); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 6px 16px calc(14px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .22s ease;
}
.wheel-overlay.open .wheel-sheet { transform: none; }
.wheel-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; }
.wheel-title { flex: 1; min-width: 0; text-align: center; font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wheel-top button { min-height: 40px; padding: 6px 10px; background: transparent; color: var(--muted); border: 0; }
.wheel-top .wheel-ok { color: var(--accent); }
.wheel-heads {
  display: grid; grid-template-columns: repeat(var(--n), 1fr);
  text-align: center; color: var(--muted); font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.06em; margin: 2px 0 0;
}
.wheel-body {
  position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr);
  height: calc(var(--wi) * 5);
}
.wheel-band {
  position: absolute; left: 0; right: 0; top: calc(var(--wi) * 2); height: var(--wi);
  background: rgba(255, 255, 255, 0.09); border-radius: 12px; pointer-events: none;
}
.wheel-col {
  position: relative; height: 100%; overflow-y: auto;
  scroll-snap-type: y mandatory; scrollbar-width: none;
  overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch;
  contain: layout paint; will-change: scroll-position;
  -webkit-mask-image: linear-gradient(transparent, #000 28%, #000 72%, transparent);
  mask-image: linear-gradient(transparent, #000 28%, #000 72%, transparent);
}
.wheel-col::-webkit-scrollbar { display: none; }
.wheel-sp { height: calc(var(--wi) * 2); flex: none; }
.wheel-it {
  height: var(--wi); display: flex; align-items: center; justify-content: center;
  scroll-snap-align: center; scroll-snap-stop: normal;
  font-size: 1.4rem; font-variant-numeric: tabular-nums;
  color: var(--muted); cursor: pointer; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.wheel-it.is-sel { color: var(--text); font-weight: 600; }
.wheel-clear { margin-top: 10px; width: 100%; }

@media (prefers-reduced-motion: reduce) {
  .wheel-overlay, .wheel-sheet { transition: none; }
}
@media print { .wheel-overlay { display: none !important; } }

/* ----- en-tête sur smartphone : boutons sur une 2e ligne ----- */
@media (max-width: 640px) {
  .top-in { flex-wrap: wrap; gap: 8px 12px; }
  .brand { flex: 1 1 0; }
  .brand h1 { white-space: nowrap; }
  .nav { flex: 1 1 100%; }
  .nav .navlink, .nav .jump { flex: 1 1 0; text-align: center; padding: 9px 10px; }
}
