/* ===========================================================================
 * styles.css — OPTCG Trainer
 * ======================================================================== */
:root {
  --bg: #0e1726;
  --bg2: #14213a;
  --panel: #1b2a4a;
  --panel2: #22335a;
  --ink: #eaf0ff;
  --muted: #9fb0d0;
  --gold: #ffce4d;
  --gold2: #e0a400;
  --red: #e23b4e;
  --red2: #ff6b78;
  --purple: #8b5cf6;
  --purple2: #b794ff;
  --green: #34d399;
  --blue: #38bdf8;
  --shadow: 0 6px 18px rgba(0,0,0,.35);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, #1c2c4d 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---- top bar ---- */
#topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; background: rgba(10,18,34,.7);
  border-bottom: 1px solid rgba(255,255,255,.08); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 30;
}
#topbar .brand { font-weight: 800; font-size: 20px; letter-spacing: .5px; }
#topbar .brand .accent { color: var(--gold); }
#topbar .spacer { flex: 1; }
.badge {
  background: var(--panel); border: 1px solid rgba(255,255,255,.1);
  padding: 5px 11px; border-radius: 999px; font-size: 13px; color: var(--muted);
}
.badge b { color: var(--ink); }
.btn {
  background: linear-gradient(180deg, var(--gold), var(--gold2));
  color: #2a1c00; border: none; padding: 8px 14px; border-radius: 10px;
  font-weight: 700; cursor: pointer; box-shadow: var(--shadow); font-size: 14px;
}
.btn:hover { filter: brightness(1.06); }
.btn.secondary { background: var(--panel); color: var(--ink); border: 1px solid rgba(255,255,255,.14); }
.btn.small { padding: 4px 9px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }

/* ---- layout ---- */
#layout { display: grid; grid-template-columns: 1fr 320px; gap: 12px; padding: 12px; }
#board { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.side { display: flex; flex-direction: column; gap: 10px; }

.playerstrip {
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0));
  border: 1px solid rgba(255,255,255,.08); border-radius: var(--radius); padding: 10px;
}
.playerstrip.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255,206,77,.25) inset; }
.playerstrip.opp { background: linear-gradient(180deg, rgba(226,59,78,.06), rgba(255,255,255,0)); }
.strip-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.strip-head .name { font-weight: 800; font-size: 15px; }
.strip-head .pill { font-size: 12px; color: var(--muted); background: rgba(0,0,0,.25); padding: 3px 9px; border-radius: 999px; }
.strip-head .pill b { color: var(--ink); }

.rows { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; }
.leaderbox, .lifebox, .donbox, .trashbox { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.zone-label { font-size: 10px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }

.charrow { display: flex; gap: 8px; flex-wrap: wrap; min-height: 132px; align-content: flex-start;
  background: rgba(0,0,0,.18); border-radius: 10px; padding: 8px; border: 1px dashed rgba(255,255,255,.08); }
.charrow.empty::after { content: "No Characters in play"; color: var(--muted); font-size: 12px; align-self: center; margin: auto; }

/* ---- cards ---- */
.card {
  width: 92px; min-height: 124px; border-radius: 10px; padding: 6px;
  background: linear-gradient(180deg, #243456, #1a2742);
  border: 2px solid rgba(255,255,255,.14); position: relative; cursor: default;
  display: flex; flex-direction: column; box-shadow: var(--shadow); user-select: none;
}
.card.Red { border-color: var(--red2); background: linear-gradient(180deg, #4a2230, #2a1622); }
.card.Purple { border-color: var(--purple2); background: linear-gradient(180deg, #36265a, #221a3c); }
.card.leader { width: 110px; min-height: 150px; border-width: 3px; }
.card .cost {
  position: absolute; top: -8px; left: -8px; width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #2a1c00;
  font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); border: 2px solid #fff3cf;
}
.card .cname { font-size: 11px; font-weight: 800; line-height: 1.1; margin-bottom: 3px; min-height: 24px; }
.card .ctype { font-size: 8.5px; color: var(--muted); margin-bottom: 3px; }
.card .ckeys { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 3px; }
.chip { font-size: 8px; font-weight: 700; padding: 1px 5px; border-radius: 999px; background: rgba(255,255,255,.14); }
.chip.kw { background: rgba(56,189,248,.25); color: #cdeeff; }
.chip.cnt { background: rgba(52,211,153,.22); color: #c5ffe7; }
.card .ctext { font-size: 8.5px; color: #d6e0f5; line-height: 1.25; flex: 1; overflow: hidden; }
.card .cbottom { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 4px; }
.card .cpow { font-weight: 800; font-size: 15px; }
.card .cpow small { font-size: 9px; color: var(--muted); font-weight: 600; }
.card .donpips { display: flex; gap: 2px; }
.card .donpip { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 4px var(--gold2); }
.card.rested { transform: rotate(90deg) scale(.86); margin: 14px 10px; opacity: .92; }
.card .actions { display: flex; gap: 4px; margin-top: 5px; }
.card .actions .btn { padding: 3px 6px; font-size: 10px; }

.card.playable { outline: 3px solid rgba(52,211,153,.7); outline-offset: 1px; cursor: pointer; }
.card.attacker-ready { box-shadow: 0 0 0 3px rgba(255,206,77,.6); }
.card.targetable { outline: 3px solid var(--red2); outline-offset: 1px; cursor: pointer; animation: pulse 1s infinite; }
.card.selected { box-shadow: 0 0 0 3px var(--blue); }
@keyframes pulse { 0%,100% { outline-color: var(--red2);} 50% { outline-color: #ffd0d6;} }

.cardback {
  width: 40px; height: 56px; border-radius: 7px; background: repeating-linear-gradient(45deg,#23365e,#23365e 6px,#1a2949 6px,#1a2949 12px);
  border: 1px solid rgba(255,255,255,.18); box-shadow: var(--shadow);
}

/* ---- life / don / hand counts ---- */
.lifestack { position: relative; width: 46px; height: 64px; }
.lifestack .lifecard { position: absolute; left: 0; width: 44px; height: 60px; border-radius: 7px;
  background: linear-gradient(180deg,#e23b4e,#9c1f2e); border: 1px solid #ff8e98; box-shadow: var(--shadow); }
.bignum { font-size: 22px; font-weight: 800; }
.donpool { display: flex; flex-wrap: wrap; gap: 3px; max-width: 120px; justify-content: center; }
.don { width: 16px; height: 16px; border-radius: 50%; background: linear-gradient(180deg,var(--gold),var(--gold2));
  border: 1px solid #fff3cf; box-shadow: 0 0 4px rgba(255,206,77,.5); font-size: 9px; color:#3a2a00; display:flex; align-items:center; justify-content:center; font-weight:800; }
.don.rested { background: #5a5f70; box-shadow: none; border-color: #7a8093; opacity: .8; }

.hand { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px; background: rgba(0,0,0,.22);
  border-radius: 12px; border: 1px solid rgba(255,255,255,.08); margin-top: 10px; min-height: 140px; }
.handlabel { font-size: 12px; color: var(--muted); margin: 4px 2px; display:flex; align-items:center; gap:8px;}

/* ---- side panel: log + hints ---- */
.panelcard { background: var(--panel); border: 1px solid rgba(255,255,255,.08); border-radius: var(--radius); padding: 12px; }
.panelcard h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
#hint { font-size: 14px; line-height: 1.45; }
#hint .tip { background: rgba(52,211,153,.12); border-left: 3px solid var(--green); padding: 8px 10px; border-radius: 6px; margin-top: 6px; }
#log { max-height: 360px; overflow-y: auto; font-size: 12.5px; line-height: 1.5; }
#log .l { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.l.phase { color: var(--gold); font-weight: 700; }
.l.attack { color: var(--red2); }
.l.block { color: var(--blue); }
.l.counter { color: var(--green); }
.l.damage { color: #ffb4bd; }
.l.ko { color: #ff8a98; font-weight: 700; }
.l.don { color: var(--gold); }
.l.effect { color: var(--purple2); }
.l.win { color: var(--gold); font-weight: 800; }
.l.play { color: #cfe3ff; }

/* ---- modals / overlays ---- */
.overlay { position: fixed; inset: 0; background: rgba(6,10,20,.72); display: flex; align-items: center;
  justify-content: center; z-index: 50; backdrop-filter: blur(3px); }
.modal { background: linear-gradient(180deg,#1d2c4d,#15203a); border: 1px solid rgba(255,255,255,.14);
  border-radius: 18px; padding: 22px; max-width: 560px; width: calc(100% - 40px); box-shadow: var(--shadow); }
.modal h2 { margin: 0 0 6px; }
.modal p { color: var(--muted); margin: 4px 0 14px; }
.options { display: flex; flex-direction: column; gap: 8px; }
.options .btn { text-align: left; }
.whoturn { font-size: 12px; color: var(--gold); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }

/* menu */
.menu-decks { display: flex; gap: 12px; margin: 10px 0; }
.deckpick { flex: 1; border: 2px solid rgba(255,255,255,.12); border-radius: 12px; padding: 12px; cursor: pointer; background: rgba(0,0,0,.2); }
.deckpick.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255,206,77,.25) inset; }
.deckpick h4 { margin: 0 0 4px; }
.deckpick.Red h4 { color: var(--red2); }
.deckpick.Purple h4 { color: var(--purple2); }
.deckpick p { font-size: 12px; margin: 0; color: var(--muted); }
.seg { display: inline-flex; background: rgba(0,0,0,.25); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { background: transparent; border: none; color: var(--muted); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 700; }
.seg button.sel { background: var(--gold); color: #2a1c00; }
.field { margin: 14px 0; }
.field label.lab { display:block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 700; }

.winbanner h1 { font-size: 34px; margin: 0 0 8px; color: var(--gold); }

/* cancel bar during target select */
#actionbar { position: sticky; bottom: 0; z-index: 25; display: none; }
#actionbar.show { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 10px;
  background: rgba(226,59,78,.18); border: 1px solid var(--red2); border-radius: 12px; }

@media (max-width: 980px) {
  #layout { grid-template-columns: 1fr; }
}
