/* Memes variables et ambiance que le guide des roles (index de reference) */
*, *::before, *::after { box-sizing: border-box; }
:root { --bg: #f5eade; --ink: #394369; --ink-soft: #555e77; --accent: #d38a3e; --accent-light: #eac398; --white: #fff; --line: rgba(234,195,152,.6); --tabbar: 58px; }
html, body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; height: 100%; margin: 0; overflow: hidden; }
body { touch-action: manipulation; font-family: "Montserrat", sans-serif; color: var(--ink); background: var(--bg); line-height: 1.45; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4 { font-family: "Fredoka", sans-serif; margin: 0; color: var(--ink); }
button { font: inherit; color: inherit; cursor: pointer; }
.bg-blobs { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.bg-blob { position: absolute; border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; }
.b1 { top: -16vh; right: -10vw; width: 46vw; height: 46vw; background: var(--accent-light); opacity: .45; }
.b2 { bottom: -18vh; left: -12vw; width: 40vw; height: 40vw; background: var(--accent); opacity: .16; }
.b4 { top: 58vh; right: -7vw; width: 26vw; height: 26vw; background: #013c9a; opacity: .1; }

main { position: fixed; inset: 0 0 calc(var(--tabbar) + env(safe-area-inset-bottom)) 0; padding-top: env(safe-area-inset-top); }
.tab { position: absolute; inset: 0; padding-top: env(safe-area-inset-top); }
.tab[hidden] { display: none; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page { max-width: 860px; margin: 0 auto; padding: 18px 16px 24px; }
.page h2 { font-size: 26px; margin-bottom: 12px; }
#tab-setup:not([hidden]) { display: flex; flex-direction: column; }
.scroll-area { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--ink); z-index: 20; }
.tabbar button { flex: 1; border: 0; background: none; color: #c9cde0; font-weight: 600; font-size: 13px; letter-spacing: .3px; }
.tabbar button.on { color: #f4e0af; box-shadow: inset 0 -3px 0 var(--accent); }

/* Cartes et controles */
.btn { background: var(--ink); color: #f4e0af; border: 0; border-radius: 20px; padding: 11px 20px; font-weight: 700; font-size: 13px; letter-spacing: .5px; }
.btn.ghost { background: var(--white); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: #760006; color: #fff; }
.btn[disabled] { opacity: .45; }
input, textarea { -webkit-user-select: text; user-select: text; }
.field { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); font: inherit; color: var(--ink); }
.lbl { display: block; margin: 14px 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--ink-soft); }
.check { display: flex; gap: 10px; align-items: center; margin: 10px 0; font-size: 14px; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 6px 0 12px; }
.row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.scroll-x { overflow-x: auto; }
.comp { width: 100%; border-collapse: collapse; background: var(--white); border: 1px solid var(--line); border-radius: 14px; font-size: 13px; text-align: center; }
.comp th, .comp td { padding: 6px 7px; }
.comp th:first-child { text-align: left; }
.comp .cur { background: #fbf0e0; font-weight: 800; }
.team-h { margin: 22px 0 8px; font-size: 18px; }

/* Selection de roles */
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.pick { display: flex; gap: 12px; align-items: center; text-align: left; background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; box-shadow: 0 2px 10px rgba(57,67,105,.05); }
.pick { position: relative; }
.pick.on { border-color: var(--tc); box-shadow: 0 0 0 3px var(--tc); }
.pick.on::after { content: ""; position: absolute; top: -9px; right: -7px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff;
  background: var(--tc) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4L18 8' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 72% no-repeat; }
.comp .cl { cursor: pointer; } .comp .cl:hover { background: #fbf0e0; }
.pick.used { opacity: .65; }
.pick-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.pick-tip { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }
.warn { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; flex: none; }
.dock { flex: none; padding: 10px 16px 12px; background: rgba(245,234,222,.96); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.compbar { display: flex; gap: 8px; width: 100%; max-width: 860px; }
.cb { flex: 1; background: var(--white); border-radius: 12px; padding: 4px 8px; border-bottom: 3px solid var(--tc); text-align: center; }
.cb small { display: block; font-size: 10.5px; font-weight: 700; color: var(--tc); } .cb b { font-size: 15px; }

/* Pastilles d'icones */
.ico { position: relative; flex: none; width: 46px; height: 46px; border-radius: 50%; border: 3px solid; background: #e8dcc9; display: grid; place-items: center; overflow: hidden; }
.ico img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ico .ini { font-family: "Fredoka"; font-weight: 700; font-size: 18px; }
.ico.big { width: min(52vw, 220px); height: min(52vw, 220px); border-width: 6px; }
.ico.dead { filter: grayscale(1) brightness(.85); border-color: #000 !important; }

/* Grimoire */
#stage-wrap { position: absolute; inset: 0; overflow: hidden; }
#stage { isolation: isolate; position: absolute; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; --t: clamp(52px, 12vmin, 88px); background: radial-gradient(circle at 50% 50%, rgba(255,255,255,.55), transparent 70%); }
.token { position: absolute; width: var(--t); height: var(--t); transform: translate(-50%, -50%); cursor: grab; will-change: left, top; }
.token .ico { width: 100%; height: 100%; box-shadow: 0 3px 8px rgba(57,67,105,.3); }
.token.drag { cursor: grabbing; filter: drop-shadow(0 8px 10px rgba(0,0,0,.3)); transform: translate(-50%, -50%) scale(1.1); }
.token.reminder { width: calc(var(--t) * .62); height: calc(var(--t) * .62); }
.token.reminder .ini { color: #fff; }
.rem-label { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); font-size: 10px; font-weight: 700; text-align: center; background: var(--white); border-radius: 8px; padding: 0 5px; margin-top: 2px; width: max-content; max-width: 90px; }
.pname { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 2px; background: var(--ink); color: #f4e0af; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 0 8px; white-space: nowrap; }
.vote { position: absolute; right: -9px; top: -9px; width: 30px; height: 30px; filter: drop-shadow(0 2px 3px rgba(57,67,105,.5)); pointer-events: none; }
.vote svg { display: block; width: 100%; height: auto; }
#side-open { position: absolute; z-index: 11; left: 10px; top: 10px; background: var(--ink); color: #f4e0af; border: 0; border-radius: 20px; padding: 8px 16px; font-weight: 700; font-size: 12px; }
#side { position: absolute; z-index: 10; left: 0; top: 0; bottom: 0; width: min(80vw, 300px); background-color: #ffffff; opacity: 1; overflow-y: auto; padding: 18px 14px; transform: translateX(-102%); transition: transform .18s; box-shadow: 4px 0 18px rgba(57,67,105,.18); }
#side.open { transform: none; }

/* Fenetres */
/* Les fenetres ignorent les touches pendant 0.4 s: evite le clic fantome qui suit un tap */
.backdrop, .full { pointer-events: none; animation: arm 0s linear .4s forwards; }
@keyframes arm { to { pointer-events: auto; } }
.menu-item.off { opacity: .4; }
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(57,67,105,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: min(100%, 560px); max-height: 86vh; display: flex; flex-direction: column; border-radius: 18px 18px 0 0; }
@media (min-width: 700px) { .backdrop { align-items: center; } .sheet { border-radius: 18px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 6px; }
.x { border: 0; background: none; font-size: 28px; line-height: 1; }
.sheet-body { overflow-y: auto; padding: 6px 18px 20px; }
.menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.menu .menu-item { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; min-height: 66px; padding: 10px; }
.menu-item small { font-weight: 500; font-size: 11px; color: var(--ink-soft); }
.menu-item.danger { color: #760006; }
#side .menu-item { display: block; width: 100%; text-align: left; margin-bottom: 8px; }
.menu-item { text-align: left; background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 13px 16px; font-weight: 600; font-size: 14px; }
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 12px; }
.rtile { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; }
.rtile .ico { width: 58px; height: 58px; } .rtile .ini { color: #fff; }
.center { text-align: center; } .rbig { border-radius: 18px; padding: 20px; color: #fff; } .rbig h2 { color: #fff; margin-top: 10px; } .rbig .ico { margin: 0 auto; }
.full { position: fixed; inset: 0; z-index: 80; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; overflow-y: auto; }
.full h1 { font-size: clamp(26px, 6vw, 44px); } .abil { max-width: 560px; font-size: 17px; } .hint { font-size: 12px; color: var(--ink-soft); position: absolute; bottom: 14px; }
.tiles { display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; } .tile h3 { margin-top: 8px; } .free { white-space: pre-wrap; }

/* Nuit et infos */
.seg { display: flex; background: var(--white); border-radius: 20px; border: 1px solid var(--line); padding: 3px; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 17px; padding: 9px; font-weight: 700; font-size: 13px; } .seg .on { background: var(--ink); color: #f4e0af; }
.night-row { display: flex; gap: 12px; align-items: center; background: var(--white); border: 1px solid var(--line); border-left: 5px solid var(--tc); border-radius: 14px; padding: 10px 12px; margin-top: 8px; }
.night-row.grey { opacity: .42; filter: grayscale(.8); }
.night-txt { font-size: 13px; color: var(--ink-soft); } .sub { font-weight: 500; color: var(--ink-soft); }
.empty { color: var(--ink-soft); margin-top: 16px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 20px; }
.info-card { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 18px 14px; font-family: "Fredoka"; font-size: 17px; font-weight: 600; box-shadow: 0 2px 10px rgba(57,67,105,.05); }

.info-card { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.info-thumb { width: 64px; height: 64px; object-fit: contain; }
.info-img { max-width: min(80vw, 420px); max-height: 45vh; object-fit: contain; }
.rows { --sz: min(calc((100vw - 96px) / var(--cols)), calc((100vh - 230px) / var(--nrows)), 200px); display: flex; flex-direction: column; align-items: center; gap: 18px; }
@supports (height: 1dvh) { .rows { --sz: min(calc((100vw - 96px) / var(--cols)), calc((100dvh - 230px) / var(--nrows)), 200px); } }
.rrow { display: flex; justify-content: center; gap: 18px; }
.rows .tile { text-align: center; width: var(--sz); }
.rows .tile .ico.big { width: var(--sz); height: var(--sz); border-width: 4px; }
.rows .tile h3 { font-size: clamp(13px, 3.6vw, 20px); }

/* Rappels: pas de contour, icone centree sur un disque de la couleur du rappel */
.ico.rem { border: 0; }
.ico.rem img { inset: 12%; width: 76%; height: 76%; object-fit: contain; }
