/* Application (tableau de bord, pages, chat, modales) */

/* ---------- connexion ---------- */
.gate { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.gate-box {
  width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 24px 26px; box-shadow: 0 30px 80px rgba(0, 0, 0, .7); text-align: center;
}
.gate-art { width: 100%; border-radius: 8px; margin-bottom: 8px; box-shadow: 0 0 0 1px var(--line); }
.gate-box h1 { font-family: 'Cinzel', serif; color: var(--gold-hi); margin: 4px 0; font-size: 30px; }
.gate-box form, .gate-box .list { text-align: left; margin-top: 14px; }
.pseudo-btn { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); }
.pseudo-btn:hover:not(:disabled) { border-color: var(--gold); }

/* ---------- structure ---------- */
.app {
  height: 100%; display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 340px;
  grid-template-rows: 56px minmax(0, 1fr);
  grid-template-areas: 'top top top' 'nav main chat';
}
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 14px; padding: 0 16px;
  border-bottom: 1px solid var(--line); background: linear-gradient(#1f1912, #15110c);
}
.brand { font-family: 'Cinzel', serif; font-weight: 800; letter-spacing: .06em; color: var(--gold-hi); font-size: 20px; white-space: nowrap; }
.brand span { font-family: 'Barlow Condensed'; font-weight: 600; font-size: 12px; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; margin-left: 6px; }
.status { flex: 1; display: flex; align-items: center; gap: 14px; justify-content: flex-end; min-width: 0; overflow: hidden; }
.me-chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-weight: 800; white-space: nowrap; }
.me-chip:hover { border-color: var(--gold); }
.icon-btn { background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; color: var(--muted); white-space: nowrap; }
.icon-btn:hover { color: var(--gold-hi); border-color: var(--gold); }
.nav-toggle { display: none; }
.nav { grid-area: nav; border-right: 1px solid var(--line); padding: 10px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; background: rgba(0, 0, 0, .18); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 600; }
.nav a .ico { width: 20px; text-align: center; color: var(--gold); }
.nav a:hover { background: var(--panel2); }
.nav a.on { background: linear-gradient(90deg, rgba(217, 180, 90, .22), transparent); color: var(--gold-hi); box-shadow: inset 3px 0 0 var(--gold); }
.nav a.staff-only { display: none; }
body.is-staff .nav a.staff-only { display: flex; }
.nav a.admin-only { display: none; }
body.is-admin .nav a.admin-only { display: flex; }
.main { grid-area: main; overflow-y: auto; padding: 22px 26px 60px; }
.page { max-width: 1180px; margin: 0 auto; }
body.offline .topbar::after { content: 'Connexion perdue… reconnexion'; color: var(--red); font-weight: 800; }

/* ---------- chat ---------- */
.chat { grid-area: chat; border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: rgba(0, 0, 0, .22); }
.chat-head { display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); }
.chat-tabs { flex: 1; display: flex; gap: 4px; overflow-x: auto; }
.chat-tabs button { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 4px 9px; color: var(--muted); white-space: nowrap; font-weight: 600; }
.chat-tabs button.on { border-color: var(--line); color: var(--gold-hi); background: var(--panel2); }
.unread { background: var(--red); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 13px; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; font-size: 16px; line-height: 1.3; }
.msg { overflow-wrap: anywhere; }
.msg .t { color: var(--muted); font-size: 13px; }
.msg.sys { color: var(--muted); font-style: italic; }
.msg.quiz { color: var(--gold-hi); font-style: normal; font-weight: 600; }
.msg.hl { color: #ffd27a; font-weight: 600; }
.msg.auto { opacity: .7; }
.who { background: none; border: 0; padding: 0; color: var(--gold-hi); font-weight: 800; text-align: left; }
.who:hover { text-decoration: underline; }
.chat-form { padding: 8px; border-top: 1px solid var(--line); }
.chat-form input { width: 100%; }
.chat.folded .chat-log, .chat.folded .chat-form { display: none; }

/* ---------- éléments de formulaire ---------- */
input, select, textarea {
  background: #0f0c08; color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font: inherit; font-size: 16px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
textarea { width: 100%; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.field input, .field select { color: var(--ink); }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 12px; }
legend { color: var(--gold); font-weight: 800; padding: 0 6px; }
.check { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.check input { accent-color: var(--gold); width: 16px; height: 16px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px 12px; }
.btn { border-radius: 8px; padding: 8px 16px; font-weight: 800; letter-spacing: .03em; border: 1px solid transparent; white-space: nowrap; }
.btn.primary { background: linear-gradient(var(--gold-hi), var(--gold)); color: #1c1408; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover:not(:disabled) { border-color: var(--gold); }
.btn.danger { background: transparent; border-color: rgba(255, 97, 112, .5); color: #ffb0b8; }
.btn.danger:hover:not(:disabled) { background: rgba(255, 97, 112, .12); }
.btn:disabled { opacity: .45; }
.btn.xs { padding: 2px 8px; font-size: 14px; }

/* ---------- utilitaires ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.row.center { justify-content: center; margin: 14px 0; }
.gap { gap: 10px; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.warn { color: #ffb36b; }
.ok-text { color: var(--green); font-weight: 600; }
.tag { font-size: 13px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge { font-size: 12px; padding: 1px 6px; border-radius: 4px; font-weight: 800; vertical-align: middle; }
.badge.ok { background: rgba(143, 216, 143, .2); color: var(--green); }
.role-anim { background: #3a2f63; color: #cbbcff; }
.role-op { background: #5d2b2b; color: #ffb8b8; }
.role-admin { background: #6a521b; color: #ffe39a; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #5d5240; flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
a { color: var(--gold-hi); }

/* ---------- pages ---------- */
.page-head { margin-bottom: 18px; }
.page-head h1 { font-family: 'Cinzel', serif; color: var(--gold-hi); margin: 0; font-size: 28px; }
.page-head p { margin: 4px 0 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.panel h2 { font-size: 14px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); margin: 4px 0 10px; }
.panel h2:not(:first-child) { margin-top: 18px; }
.panel h3 { margin: 8px 0 6px; font-size: 18px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.cols .panel { margin-bottom: 0; }
.cols + .panel, .cols + .cols { margin-top: 16px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list li { padding: 8px 10px; border-radius: 8px; background: var(--panel2); }
.list li p { margin: 0 0 2px; }
.list.compact li { padding: 4px 8px; }
.list.scroll { max-height: 60vh; overflow-y: auto; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a, .tabs button { font: inherit; cursor: pointer; background: none; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; color: var(--muted); font-weight: 600; }
.tabs a.on, .tabs button.on { background: var(--gold); color: #1c1408; border-color: var(--gold); }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 16px; }
.big-btn { text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.big-btn b { font-size: 20px; color: var(--gold-hi); }
.big-btn span { color: var(--muted); }
.big-btn:hover { border-color: var(--gold); }
.big-btn.primary { background: linear-gradient(135deg, rgba(217, 180, 90, .3), rgba(217, 180, 90, .08)); border-color: var(--gold); }
.res { font-weight: 800; text-transform: uppercase; font-size: 13px; }
.res.victoire { color: var(--green); }
.res.défaite { color: var(--red); }
.poll { margin-top: 14px; }
.poll h3 { font-size: 17px; }
.poll-opt { position: relative; width: 100%; display: flex; justify-content: space-between; padding: 6px 10px; margin-bottom: 4px; border-radius: 6px; background: var(--panel2); border: 1px solid var(--line); overflow: hidden; }
.poll-opt .bar { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(217, 180, 90, .18); z-index: 0; }
.poll-opt span:first-child, .poll-opt small { position: relative; z-index: 1; }
.poll-opt.on { border-color: var(--gold); }
.filters { margin-bottom: 14px; }
.filters input[type=search] { flex: 1; min-width: 180px; }
.table-wrap { overflow-x: auto; margin-bottom: 16px; }
table.data { width: 100%; border-collapse: collapse; font-size: 16px; }
.data th, .data td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data th { color: var(--gold); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.data tr.me td { background: rgba(217, 180, 90, .1); }

/* ---------- tuiles de cartes ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.tile-grid.mini { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); min-height: 72px; }
.tile-grid.five { grid-template-columns: repeat(5, 1fr); }
.tile { position: relative; aspect-ratio: 200 / 247; border-radius: 7%/5.7%; overflow: hidden; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .5)); }
.tile img { width: 100%; height: 100%; display: block; }
.tile[data-act], [data-add] .tile, [data-pick] .tile, [data-rm] .tile, [data-rem] .tile, [data-act=t] .tile { cursor: pointer; }
.tile[data-act]:hover, [data-add]:hover .tile, [data-pick]:hover .tile, [data-act=t]:hover .tile { outline: 2px solid var(--gold); }
.tile.sel { outline: 3px solid var(--gold-hi); outline-offset: 1px; }
.tile.dim { opacity: .35; }
.tile.empty { border: 1px dashed var(--line); background: transparent; box-shadow: none; }
.tile .qty { position: absolute; right: 3px; top: 3px; background: rgba(0, 0, 0, .75); color: #fff; font-weight: 800; font-size: 13px; padding: 0 5px; border-radius: 4px; }
.tile .tname { position: absolute; left: 0; right: 0; bottom: 0; font-size: 12px; font-weight: 600; padding: 8px 4px 2px; text-align: right; background: linear-gradient(transparent, rgba(0, 0, 0, .8)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-slots { display: grid; grid-template-columns: repeat(5, minmax(0, 96px)); gap: 8px; margin: 12px 0; }
.shop-item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.shop-item .tile { width: 100%; }
.shop-item small { color: var(--gold-hi); font-weight: 600; }
.shop-item.locked .tile { filter: grayscale(.7); }
.card-detail { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 10px; }
.card-detail .duo { display: grid; grid-template-columns: repeat(2, 124px); gap: 8px; }
.card-detail h2 { margin: 0; color: var(--gold-hi); font-family: 'Cinzel', serif; }
.cross { position: relative; width: 84px; height: 96px; flex: none; font-size: 26px; font-weight: 800; }
.cross b { position: absolute; transform: translate(-50%, -50%); }
.cross .t { left: 50%; top: 14%; } .cross .b { left: 50%; top: 86%; } .cross .l { left: 16%; top: 50%; } .cross .r { left: 84%; top: 50%; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.deck-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(560px, 1fr)); gap: 16px; }
.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.skill { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.skill p { margin: 0; flex: 1; }
.levels { display: flex; gap: 4px; }
.levels span { flex: 1; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .08); }
.levels span.on { background: linear-gradient(90deg, var(--gold), var(--gold-hi)); }
.auction-list { display: grid; gap: 10px; }
.auction { display: flex; gap: 14px; align-items: center; margin: 0; }
.auction .tile { width: 96px; flex: none; }
.auction h3 { margin: 0; }
.auction p { margin: 4px 0; }
.auction.leading { border-color: var(--green); }
.glogo { width: 64px; height: 64px; object-fit: contain; image-rendering: auto; }
.glogo.sm { width: 28px; height: 28px; }
.topic { white-space: pre-wrap; background: var(--panel2); border-radius: 8px; padding: 10px; max-height: 260px; overflow-y: auto; }
.bracket { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 6px; }
.round { min-width: 190px; display: flex; flex-direction: column; gap: 8px; }
.round h3 { font-size: 15px; color: var(--gold); margin: 0; }
.match { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; background: var(--panel2); }
.match .win { color: var(--green); font-weight: 800; }
.match.done { opacity: .85; }
.profile-head h2 { margin: 0; font-family: 'Cinzel', serif; color: var(--gold-hi); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.stats-grid div { background: var(--panel2); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; }
.stats-grid b { font-size: 20px; color: var(--gold-hi); }
.stats-grid span { font-size: 13px; color: var(--muted); }
.actions-row { margin-top: 12px; }
details.staff { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
details.staff summary { cursor: pointer; color: var(--gold); font-weight: 800; margin-bottom: 8px; }
.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.trade-cols section { background: var(--panel2); border-radius: 8px; padding: 10px; }
.trade-cols h3 { margin-top: 0; }

/* ---------- modales & notifications ---------- */
.modal-back { position: fixed; inset: 0; z-index: 200; background: rgba(6, 4, 2, .7); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 16px; }
.modal {
  position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel);
  border: 1px solid var(--line-hi); border-radius: 12px; padding: 20px 22px; box-shadow: 0 30px 90px rgba(0, 0, 0, .8);
}
.modal.wide { width: min(1080px, 100%); }
.modal h2 { margin: 0 0 10px; font-family: 'Cinzel', serif; color: var(--gold-hi); font-size: 22px; padding-right: 30px; }
.modal .x { position: absolute; right: 12px; top: 12px; background: none; border: 0; color: var(--muted); font-size: 18px; }
.confirm-text { font-size: 19px; }
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(560px, calc(100vw - 32px)); }
.toast { background: #241d14; border: 1px solid var(--line-hi); color: var(--ink); padding: 10px 16px; border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .6); transition: opacity .4s, transform .4s; text-align: center; }
.toast.ok { border-color: var(--green); }
.toast.error { border-color: var(--red); color: #ffc9ce; }
.toast.out { opacity: 0; transform: translateY(10px); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .app { grid-template-columns: 200px minmax(0, 1fr); grid-template-rows: 56px minmax(0, 1fr) auto; grid-template-areas: 'top top' 'nav main' 'chat chat'; }
  .chat { border-left: 0; border-top: 1px solid var(--line); max-height: 38vh; }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'top' 'main' 'chat'; }
  .nav-toggle { display: inline-block; }
  .nav { position: fixed; top: 56px; left: 0; bottom: 0; width: 240px; z-index: 50; background: var(--bg2); transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .nav { transform: none; }
  .brand span { display: none; }
  .brand { font-size: 17px; }
  .status { gap: 8px; font-size: 15px; }
  .main { padding: 16px 16px 40px; }
  .deck-list { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .trade-cols { grid-template-columns: 1fr; }
  .pick-slots { grid-template-columns: repeat(5, 1fr); }
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
}
