/* GUSSE : thème « clairière » clair/sombre, suit le cookie bc_theme du portail */
:root {
  --bg: #f3ead6; --bg2: #e8dcc0; --card: #fffaf0; --line: #e2d3b3; --text: #2d2418; --muted: #7a6a52;
  --accent: #c2410c; --accent-2: #9a3412; --accent-text: #fff;
  --good: #3f8f3a; --warn: #d39b14; --bad: #c0392b;
  --rare: #3b82f6; --epique: #a855f7; --legendaire: #f59e0b;
  --shadow: 0 2px 0 #d9c7a1, 0 10px 24px -14px rgba(60, 40, 10, .45);
  --radius: 14px;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #15120e; --bg2: #1d1913; --card: #221d16; --line: #3a3126; --text: #f0e6d4; --muted: #a8977c;
    --accent: #ea6a2a; --accent-2: #f08a50; --shadow: 0 2px 0 #0d0b08, 0 12px 26px -14px rgba(0, 0, 0, .8);
  }
}
:root[data-theme=dark] {
  --bg: #15120e; --bg2: #1d1913; --card: #221d16; --line: #3a3126; --text: #f0e6d4; --muted: #a8977c;
  --accent: #ea6a2a; --accent-2: #f08a50; --shadow: 0 2px 0 #0d0b08, 0 12px 26px -14px rgba(0, 0, 0, .8);
}
.theme-anim, .theme-anim * { transition: background-color .3s, color .3s, border-color .3s !important; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.4;
  background-image: radial-gradient(circle at 15% 10%, rgba(120, 160, 60, .10), transparent 40%), radial-gradient(circle at 90% 80%, rgba(194, 65, 12, .08), transparent 40%);
}
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.15; }
h3 { font-size: 1rem; } h4 { font-size: .95rem; margin-top: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
button, input { font: inherit; color: inherit; }
.muted { color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); font-size: .9rem; }
.boot { display: grid; place-items: center; min-height: 80vh; color: var(--muted); }

/* Boutons */
.btn { border: 1px solid var(--line); background: var(--bg2); padding: .5rem .9rem; border-radius: 10px; cursor: pointer; font-weight: 600; transition: transform .08s, filter .15s; }
.btn:hover:not(:disabled) { filter: brightness(1.05); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent-2); box-shadow: 0 2px 0 var(--accent-2); }
.btn.big { padding: .75rem 1.2rem; font-size: 1.05rem; }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn.loading { opacity: .7; cursor: progress; }
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 50%; width: 2.2rem; height: 2.2rem; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }

/* Auth */
.auth { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-card { width: min(420px, 100%); }
.auth-hero { text-align: center; }
.auth-avatar { width: 150px; margin: -10px auto 0; animation: bob 3s ease-in-out infinite; }
.logo { font-size: 3rem; letter-spacing: .12em; font-weight: 900; color: var(--accent); text-shadow: 0 3px 0 var(--accent-2); margin: .2rem 0; }
.tagline { color: var(--muted); margin-top: 0; }
.auth-tabs { display: flex; gap: .3rem; margin: 1rem 0; background: var(--bg2); padding: .25rem; border-radius: 12px; }
.auth-tabs button { flex: 1; border: 0; background: transparent; padding: .5rem; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); }
.auth-tabs button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.auth-form, .pw-form { display: grid; gap: .8rem; }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
input[type=text], input:not([type]), input[type=password] { padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.form-error { color: var(--bad); min-height: 1.2em; margin: 0; font-weight: 600; }
.pw-form { max-width: 360px; }

/* Créateur */
.creator-card { width: min(760px, 100%); }
.name-field { max-width: 360px; margin-bottom: 1rem; }
.creator { display: grid; grid-template-columns: 220px 1fr; gap: 1.2rem; align-items: start; }
.creator-left { display: grid; gap: .6rem; justify-items: center; position: sticky; top: 1rem; }
.creator-preview { width: 210px; background: radial-gradient(circle at 50% 40%, var(--bg2), transparent 70%); border-radius: 50%; }
.creator-rows { display: grid; gap: .55rem; }
.creator-row { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: .5rem; }
.creator-row .lbl { font-weight: 600; font-size: .9rem; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: .4rem; }
.stepper button { border: 1px solid var(--line); background: var(--bg2); border-radius: 8px; width: 2rem; height: 2rem; cursor: pointer; }
.stepper span { min-width: 8.5rem; text-align: center; font-weight: 600; }
.swatches { display: flex; flex-wrap: wrap; gap: .35rem; }
.swatch { width: 1.9rem; height: 1.9rem; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; padding: 0; font-size: .8rem; background: var(--bg2); }
.swatch.on { outline: 3px solid var(--accent); outline-offset: 1px; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }

/* Jeu */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: .6rem 1rem; position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 900; letter-spacing: .12em; color: var(--accent); font-size: 1.3rem; display: flex; align-items: center; gap: .5rem; }
.brand-mark { width: 1.6rem; height: 1.6rem; background: url(/favicon.svg) center/contain no-repeat; }
.top-actions { display: flex; gap: .5rem; align-items: center; }
.game { max-width: 1200px; margin: 0 auto; padding: 1rem; display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 1rem; align-items: start; }
.col-left, .col-right { display: grid; gap: 1rem; min-width: 0; }

.hero { display: grid; gap: .8rem; }
.avatar-wrap { width: 200px; margin: 0 auto; position: relative; color: var(--muted); }
.avatar-wrap::before { content: ""; position: absolute; inset: 10% 5% 0; border-radius: 50%; background: radial-gradient(circle, var(--bg2), transparent 70%); z-index: -1; }
.gusse-svg { display: block; width: 100%; height: auto; overflow: visible; }
.hero-info h2 { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.lvl { background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: .1rem .55rem; font-size: .8rem; font-weight: 700; }
.status { margin: 0 0 .6rem; font-weight: 600; }

.bar { margin-bottom: .5rem; }
.bar-head { display: flex; justify-content: space-between; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: .2rem; }
.track { position: relative; height: 12px; border-radius: 999px; background: var(--bg2); overflow: hidden; border: 1px solid var(--line); }
.track.thin { height: 8px; }
.fill { height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s ease; }
.energy.good .fill { background: linear-gradient(90deg, #4caf50, #7bd36f); }
.energy.warn .fill { background: linear-gradient(90deg, #e6a817, #f3cf55); }
.energy.bad .fill { background: linear-gradient(90deg, #c0392b, #e8705f); animation: pulse 1.2s infinite; }
.worked .fill { background: linear-gradient(90deg, #6b8fd6, #8fb0f0); }
.worked.bad .fill { background: linear-gradient(90deg, #6b8fd6 0, #6b8fd6 66.6%, #c0392b 66.6%); }
.worked .mark { position: absolute; left: 66.66%; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: .5; }
.xp .fill { background: linear-gradient(90deg, #b07cf0, #f5c542); }
.res .fill.full { background: var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { display: inline-flex; align-items: center; gap: .25rem; font-size: .8rem; padding: .2rem .55rem; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); font-weight: 600; white-space: nowrap; }
.chip.ok { color: var(--good); } .chip.ko { color: var(--bad); } .chip.warn { color: var(--warn); }
.chip.buff { color: var(--epique); border-color: color-mix(in srgb, var(--epique) 40%, var(--line)); }
.chip.r-rare { border-color: var(--rare); } .chip.r-epique { border-color: var(--epique); } .chip.r-legendaire { border-color: var(--legendaire); }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.act-btn { display: grid; justify-items: center; gap: .2rem; padding: .6rem .3rem; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; font-weight: 600; font-size: .82rem; text-align: center; transition: transform .1s; }
.act-btn:hover:not(:disabled) { transform: translateY(-2px); }
.act-btn .act-icon { font-size: 1.6rem; }
.act-btn.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent-2); opacity: 1; }
.act-btn:disabled:not(.on) { opacity: .45; cursor: not-allowed; }
.switch { display: flex; gap: .5rem; align-items: center; font-weight: 500; font-size: .88rem; }
.switch input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }

.res { display: grid; grid-template-columns: 2rem 1fr; gap: .5rem; align-items: center; margin-bottom: .55rem; position: relative; }
.res-icon { font-size: 1.5rem; }
.res-head { display: flex; justify-content: space-between; font-size: .9rem; }
.float-up { position: absolute; right: 0; top: -.4rem; color: var(--good); font-weight: 800; animation: floatup 1.2s ease-out forwards; pointer-events: none; }
.rares { display: grid; grid-template-columns: repeat(6, 1fr); gap: .35rem; }
.rare { display: grid; justify-items: center; padding: .35rem 0; border-radius: 10px; border: 2px solid var(--line); background: var(--bg2); font-size: .8rem; }
.rare-icon { font-size: 1.3rem; }
.rare.r-rare { border-color: var(--rare); } .rare.r-epique { border-color: var(--epique); }
.rare.r-legendaire { border-color: var(--legendaire); box-shadow: 0 0 10px -2px var(--legendaire); }
.rare.unknown { opacity: .45; box-shadow: none; filter: grayscale(1); }

/* Onglets */
.tabs { display: flex; gap: .3rem; overflow-x: auto; padding-bottom: .4rem; border-bottom: 1px solid var(--line); margin-bottom: .8rem; scrollbar-width: thin; }
.tabs button { border: 0; background: transparent; padding: .45rem .7rem; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tabs button.on { background: var(--bg2); color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .7rem; }
.tile { border: 1px solid var(--line); border-radius: 12px; padding: .75rem; display: grid; gap: .45rem; align-content: start; background: var(--bg); }
.tile.dim { opacity: .55; }
.tile.owned { border-color: var(--good); }
.tile.tier-3 .tier { background: var(--epique); color: #fff; } .tile.tier-4 .tier { background: var(--legendaire); color: #1b1300; }
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.tile-head > div { flex: 1; }
.tile-icon { font-size: 2rem; }
.tier { font-size: .72rem; font-weight: 800; padding: .1rem .4rem; border-radius: 6px; background: var(--bg2); }
.desc { margin: 0; font-size: .85rem; color: var(--muted); }
.costs { display: flex; flex-wrap: wrap; gap: .25rem; }
.pips { display: flex; gap: 3px; margin-top: 3px; }
.pips i { width: 14px; height: 6px; border-radius: 3px; background: var(--line); }
.pips i.on { background: var(--accent); }
.maxed { color: var(--good); font-weight: 700; margin: 0; }
.locked { color: var(--muted); margin: 0; font-weight: 600; }
.equip-top { display: grid; grid-template-columns: 140px 1fr; gap: 1rem; align-items: center; }
.bonus-list { margin: 0; padding-left: 1.1rem; display: grid; gap: .2rem; font-size: .9rem; }
.slot-row { display: grid; grid-template-columns: 70px 1fr; gap: .5rem; align-items: center; padding: .5rem 0; border-top: 1px dashed var(--line); }
.slot-items { display: flex; flex-wrap: wrap; gap: .35rem; }

.journal { list-style: none; padding: 0; margin: 0 0 .8rem; display: grid; gap: .3rem; max-height: 60vh; overflow: auto; }
.j { display: grid; grid-template-columns: 6.5rem 1fr; gap: .5rem; font-size: .88rem; padding: .35rem .5rem; border-radius: 8px; border-left: 4px solid var(--line); background: var(--bg); }
.j time { color: var(--muted); font-variant-numeric: tabular-nums; }
.j-bon { border-left-color: var(--good); } .j-mauvais { border-left-color: var(--bad); }
.j-rare { border-left-color: var(--rare); } .j-epique { border-left-color: var(--epique); }
.j-legendaire { border-left-color: var(--legendaire); background: color-mix(in srgb, var(--legendaire) 12%, var(--bg)); font-weight: 700; }

.board { display: grid; gap: .3rem; }
.board-row { display: grid; grid-template-columns: 2.4rem 44px 1fr auto auto; gap: .6rem; align-items: center; padding: .3rem .5rem; border-radius: 10px; background: var(--bg); }
.board-row.me { outline: 2px solid var(--accent); }
.mini { width: 44px; display: block; }
.b-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank { font-weight: 800; text-align: center; }

/* Dialogue du journal de bord */
dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--card); color: var(--text); width: min(560px, calc(100% - 2rem)); padding: 1.2rem; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(20, 12, 4, .55); backdrop-filter: blur(2px); }
.report .facts { padding-left: 1.1rem; display: grid; gap: .2rem; }

/* Toasts */
#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 50; width: min(440px, calc(100% - 2rem)); pointer-events: none; }
.toast { display: flex; gap: .6rem; align-items: center; background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--muted); padding: .65rem .8rem; border-radius: 12px; box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .5); font-weight: 600; animation: toastin .35s cubic-bezier(.2, 1.4, .4, 1); }
.toast.out { opacity: 0; transform: translateY(10px); transition: all .5s; }
.ticon { font-size: 1.5rem; }
.t-bon { border-left-color: var(--good); } .t-mauvais { border-left-color: var(--bad); }
.t-rare { border-left-color: var(--rare); } .t-epique { border-left-color: var(--epique); box-shadow: 0 0 22px -4px var(--epique); }
.t-legendaire { border-left-color: var(--legendaire); box-shadow: 0 0 34px -2px var(--legendaire); font-size: 1.05rem; background: linear-gradient(110deg, var(--card) 40%, color-mix(in srgb, var(--legendaire) 30%, var(--card)) 50%, var(--card) 60%); background-size: 300% 100%; animation: toastin .35s, shine 2s linear infinite; }

/* Animations de l'avatar selon l'activité */
.mode-work .held { transform-origin: 166px 202px; animation: swing .8s ease-in-out infinite; }
.act-bagarre .held { animation-duration: .5s; }
.act-bagarre .gusse-svg { animation: hop .5s ease-in-out infinite; }
.mode-idle .gusse-svg { animation: bob 3.5s ease-in-out infinite; }
.mode-sleep .gusse-svg { animation: breathe 4s ease-in-out infinite; transform-origin: 50% 100%; }
.zzz text { animation: zzz 2.4s ease-in-out infinite; }
.zzz text:nth-child(2) { animation-delay: .4s; } .zzz text:nth-child(3) { animation-delay: .8s; }
.sweat { animation: sweat 1.6s ease-in infinite; }
.stars { animation: spin 2s linear infinite; transform-origin: 100px 30px; }

/* Effets de loot */
.particle { position: absolute; left: 50%; top: 45%; width: 9px; height: 9px; border-radius: 50%; pointer-events: none; animation: burst 1.2s cubic-bezier(.1, .8, .3, 1) forwards; }
.p-rare { background: var(--rare); } .p-epique { background: var(--epique); }
.p-legendaire { background: var(--legendaire); width: 12px; height: 12px; box-shadow: 0 0 10px var(--legendaire); }
.loot-rare .gusse-svg, .loot-epique .gusse-svg { animation: jump .6s ease-out; }
.loot-legendaire .gusse-svg { animation: jump .6s ease-out 3; filter: drop-shadow(0 0 16px var(--legendaire)); }
.legend-flash { position: fixed; inset: 0; pointer-events: none; z-index: 40; background: radial-gradient(circle, color-mix(in srgb, var(--legendaire) 45%, transparent), transparent 70%); animation: flash 1.6s ease-out forwards; }

@keyframes swing { 0%, 100% { transform: rotate(8deg); } 45% { transform: rotate(-38deg); } 55% { transform: rotate(-38deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.015, .985); } }
@keyframes zzz { 0% { opacity: 0; transform: translate(0, 6px); } 40% { opacity: 1; } 100% { opacity: 0; transform: translate(6px, -10px); } }
@keyframes sweat { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(18px); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes floatup { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-26px); opacity: 0; } }
@keyframes toastin { from { transform: translateY(20px) scale(.95); opacity: 0; } }
@keyframes shine { to { background-position: -150% 0; } }
@keyframes burst { from { transform: translate(-50%, -50%) scale(1); opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.3); opacity: 0; } }
@keyframes jump { 30% { transform: translateY(-14px) scale(1.04); } 60% { transform: translateY(0); } }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Mobile */
@media (max-width: 820px) {
  .game { grid-template-columns: 1fr; padding: .7rem; }
  .creator { grid-template-columns: 1fr; }
  .creator-left { position: static; }
  .creator-preview { width: 170px; }
  .creator-row { grid-template-columns: 1fr; gap: .25rem; }
  .rares { grid-template-columns: repeat(4, 1fr); }
  .board-row { grid-template-columns: 2rem 36px 1fr auto; }
  .board-row > .muted { grid-column: 3 / -1; font-size: .78rem; }
  .equip-top { grid-template-columns: 100px 1fr; }
  .j { grid-template-columns: 1fr; gap: 0; }
}
