:root {
  --sq: 64px;
  --bg: #120f1a; --panel: #1c1828; --panel2: #241f33; --line: #352e4a;
  --text: #ece8f5; --dim: #9b94b0; --gold: #e6bd55; --purple: #b896ff; --red: #ff6b6b; --green: #5fd48a;
  --common: #a9b2c4; --rare: #5aa9ff; --legendary: #f2a83a;
  --light: #ecdcbd; --dark: #ab815b;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(ellipse at 50% -10%, #2a2142 0%, var(--bg) 60%) fixed;
  color: var(--text); font: 14px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif;
}
.hidden { display: none !important; }
button {
  font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
button:hover:not(:disabled) { background: #2f2843; border-color: #4a4166; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--gold); color: #1d1606; border-color: var(--gold); font-weight: 600; }
button.primary:hover:not(:disabled) { background: #f2cd6c; }
button.link { background: none; border: none; color: var(--gold); text-decoration: underline; padding: 4px; }
input {
  font: inherit; color: var(--text); background: #120f1a; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.dim { color: var(--dim); }
.bad { color: var(--red); }
.ok { color: var(--green); }

/* ---- menu */
#menu { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.menu-box {
  width: min(440px, 94vw); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px;
  display: flex; flex-direction: column; gap: 10px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.logo { font-size: 64px; line-height: 1; color: var(--gold); text-shadow: 0 0 24px rgba(230, 189, 85, .45); font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", serif; }
h1 { margin: 0; font-size: 30px; letter-spacing: .5px; }
.tag { margin: 0 0 8px; color: var(--dim); }
button.big { width: 100%; padding: 12px; font-size: 15px; }
.sep { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; margin: 6px 0; }
.sep::before, .sep::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.join { display: flex; gap: 8px; }
.join input { flex: 1; text-transform: uppercase; letter-spacing: 4px; text-align: center; font-size: 16px; }
.msg { margin: 0; min-height: 1em; color: var(--red); font-size: 13px; }

/* ---- game layout */
#game { display: flex; gap: 18px; justify-content: center; align-items: flex-start; padding: 12px; min-height: 100vh; }
#game.waiting #boardCol { display: none; }
#boardCol { display: flex; flex-direction: column; gap: 8px; width: calc(var(--sq) * 8); }
#boardWrap { border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 4px #3a2c22, 0 14px 40px rgba(0, 0, 0, .55); }
#board { display: grid; grid-template-columns: repeat(8, var(--sq)); grid-template-rows: repeat(8, var(--sq)); }

/* ---- squares */
.sq { position: relative; display: flex; align-items: center; justify-content: center; user-select: none; }
.sq.light { background-color: var(--light); }
.sq.dark { background-color: var(--dark); }
.sq.last { background-image: linear-gradient(rgba(255, 214, 64, .42), rgba(255, 214, 64, .42)); }
.sq.sel { background-image: linear-gradient(rgba(70, 160, 255, .55), rgba(70, 160, 255, .55)); }
.sq.check { background-image: radial-gradient(circle, rgba(255, 30, 30, .95) 0%, rgba(255, 30, 30, .55) 38%, rgba(255, 30, 30, 0) 72%); }
.sq.can, .sq.dest, .sq.target { cursor: pointer; }
.sq.can:hover { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .45); }
.sq.dest::after {
  content: ''; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(28, 18, 40, .38); z-index: 3; pointer-events: none;
}
.sq.dest.cap::after { width: 88%; height: 88%; background: none; border: calc(var(--sq) * .075) solid rgba(28, 18, 40, .4); }
.sq.dest:hover { background-image: linear-gradient(rgba(70, 160, 255, .3), rgba(70, 160, 255, .3)); }
#board.aiming .sq:not(.target):not(.picked) { filter: brightness(.6) saturate(.7); }
.sq.target { background-image: linear-gradient(rgba(180, 130, 255, .35), rgba(180, 130, 255, .35)); box-shadow: inset 0 0 0 2px rgba(200, 160, 255, .9); }
.sq.target:hover { background-image: linear-gradient(rgba(180, 130, 255, .65), rgba(180, 130, 255, .65)); }
.sq.picked { box-shadow: inset 0 0 0 4px var(--gold); }
.cf, .cr { position: absolute; font-size: calc(var(--sq) * .17); font-weight: 700; pointer-events: none; z-index: 1; }
.cf { right: 4px; bottom: 1px; }
.cr { left: 4px; top: 1px; }
.sq.light .cf, .sq.light .cr { color: var(--dark); }
.sq.dark .cf, .sq.dark .cr { color: var(--light); }

/* ---- pieces */
.pc {
  position: relative; z-index: 2; font-size: calc(var(--sq) * .8); line-height: 1; pointer-events: none;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", "Apple Symbols", serif;
}
.pc.w { color: #fffaf0; text-shadow: 1px 0 0 #1a1410, -1px 0 0 #1a1410, 0 1px 0 #1a1410, 0 -1px 0 #1a1410, 1px 1px 0 #1a1410, -1px -1px 0 #1a1410, 1px -1px 0 #1a1410, -1px 1px 0 #1a1410, 0 4px 5px rgba(0, 0, 0, .45); }
.pc.b { color: #221a26; text-shadow: 1px 0 0 #f3e9d8aa, -1px 0 0 #f3e9d8aa, 0 1px 0 #f3e9d8aa, 0 -1px 0 #f3e9d8aa, 0 4px 5px rgba(0, 0, 0, .4); }
.pc.frozen { filter: drop-shadow(0 0 5px #6fd0ff) drop-shadow(0 0 2px #6fd0ff); }
.pc.w.frozen { color: #d6f3ff; }
.pc.b.frozen { color: #1d3346; }
.pc.shielded { filter: drop-shadow(0 0 6px #ffd45e); }
.pc.bonus { animation: pulse .9s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.1); filter: drop-shadow(0 0 8px #ff5050); } }
.badge { position: absolute; top: 2px; right: 3px; font-style: normal; font-size: calc(var(--sq) * .24); line-height: 1; z-index: 4; pointer-events: none; }
.badge.sh { color: #ffcf4a; text-shadow: 0 0 3px #000; }
.badge.fr { left: 3px; right: auto; color: #8fdcff; text-shadow: 0 0 3px #003; top: auto; bottom: 2px; }
.badge.bo { top: auto; bottom: 2px; color: #ffcf4a; text-shadow: 0 0 3px #000, 0 0 6px #f2a83a; }
.badge.ha { left: 3px; right: auto; color: #ff8f5a; text-shadow: 0 0 3px #000; font-weight: 900; }
.trap { position: absolute; z-index: 1; font-size: calc(var(--sq) * .62); line-height: 1; opacity: .8; pointer-events: none; font-weight: 700; }
.trap.w { color: #fff3e0; text-shadow: 0 0 8px #ff3030, 0 0 2px #ff3030; }
.trap.b { color: #2b0c0c; text-shadow: 0 0 8px #ff3030, 0 0 2px #ff3030; }

/* ---- player panels */
.pcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; transition: border-color .2s, box-shadow .2s; }
.pcard.turn { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 18px -6px var(--gold); }
.ph { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.ph b { font-size: 15px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; }
.dot.w { background: #fffaf0; box-shadow: 0 0 0 1px #000; }
.dot.b { background: #221a26; box-shadow: 0 0 0 1px #aaa; }
.who { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.flag { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--gold); font-weight: 700; }
.capd { margin-left: auto; font-size: 19px; letter-spacing: -3px; font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", serif; }
.capd.w { color: #fffaf0; text-shadow: 0 0 1px #000; }
.capd.b { color: #0e0a10; text-shadow: 0 0 1px #aaa, 0 0 2px #aaa; }
.prow { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 5px; min-height: 26px; }
.lbl { width: 66px; flex: none; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); }
.lbl small { letter-spacing: 0; }
.none { color: var(--dim); font-size: 12px; font-style: italic; }
.chip, .card {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 9px 3px 7px; border-radius: 999px;
  border: 1px solid var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--text); cursor: help;
}
.chip i, .card i { font-style: normal; color: var(--c); font-size: 14px; }
.card { border-radius: 7px; padding: 4px 10px 4px 8px; opacity: .55; cursor: default; }
.card.live { opacity: 1; cursor: pointer; box-shadow: 0 0 10px -3px var(--c); }
.card.live:hover { background: color-mix(in srgb, var(--c) 30%, transparent); transform: translateY(-1px); }
.card.on { opacity: 1; outline: 2px solid var(--gold); outline-offset: 1px; background: color-mix(in srgb, var(--gold) 25%, transparent); }
.common { --c: var(--common); }
.rare { --c: var(--rare); }
.legendary { --c: var(--legendary); }

/* ---- side panel */
#side {
  width: 340px; flex: none; display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; position: sticky; top: 12px; max-height: calc(100vh - 24px);
}
#net p { margin: 0 0 6px; }
#net .code { font-family: Consolas, monospace; letter-spacing: 2px; color: var(--gold); font-size: 15px; }
#net .link { display: flex; gap: 6px; margin-bottom: 6px; }
#net .link input { flex: 1; min-width: 0; font-size: 12px; }
#net .dim { font-size: 12px; }
#status { font-size: 18px; font-weight: 700; }
#status.mine { color: var(--gold); }
#status.over { color: var(--purple); }
#prompt:empty { display: none; }
#prompt p { margin: 0 0 8px; }
#prompt .dim { margin: 0; font-size: 13px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
#moves {
  flex: 1 1 auto; min-height: 140px; overflow-y: auto; background: #15121f; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px; font-size: 13px;
}
#moves p { margin: 4px; }
.mv { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 3px 5px; border-radius: 5px; }
.mv.cur { background: #231d33; }
.mv .n { color: var(--dim); width: 30px; flex: none; }
.it.draft { color: var(--gold); }
.it.card { color: var(--purple); }
.it.bonus { color: #ff9a9a; }
.it.skip { color: var(--dim); font-style: italic; }
.it.undone { text-decoration: line-through; opacity: .5; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; }
.tools button { flex: 1 1 30%; padding: 6px 8px; font-size: 13px; }

/* ---- dialogs */
#overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(8, 6, 14, .72); backdrop-filter: blur(3px); animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
#dialog {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; max-height: 92vh; overflow-y: auto;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6); animation: rise .2s ease-out;
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
#dialog.wide { width: min(880px, 96vw); }
#dialog.small { width: min(440px, 94vw); text-align: center; }
#dialog h2 { margin: 0 0 14px; font-size: 22px; }
#dialog h2.big { font-size: 34px; color: var(--gold); }
#dialog h3 { margin: 18px 0 8px; color: var(--gold); }
#dialog .btns { justify-content: center; margin-top: 14px; }
.offers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.offer {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 18px 14px 16px;
  border: 2px solid var(--c); border-radius: 14px; background: linear-gradient(180deg, color-mix(in srgb, var(--c) 22%, var(--panel2)), var(--panel2) 70%);
  transition: transform .15s, box-shadow .15s;
}
.offer:hover:not(:disabled) { transform: translateY(-4px); box-shadow: 0 10px 30px -8px var(--c); background: linear-gradient(180deg, color-mix(in srgb, var(--c) 32%, var(--panel2)), var(--panel2) 70%); border-color: var(--c); }
.offer .oi { font-size: 40px; line-height: 1.1; color: var(--c); text-shadow: 0 0 18px var(--c); font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "Segoe UI Emoji", serif; }
.offer .on { font-size: 18px; font-weight: 700; }
.offer .ok { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--c); }
.offer .od { font-size: 13px; color: #d6d0e4; }
.offer.legendary { animation: shine 2.2s ease-in-out infinite; }
@keyframes shine { 50% { box-shadow: 0 0 26px -4px var(--legendary); } }
.picks { display: flex; justify-content: center; gap: 10px; }
.pick { width: 76px; height: 76px; font-size: 56px; line-height: 1; padding: 0; background: var(--light); border: 2px solid var(--dark); }
.pick:hover:not(:disabled) { background: #fff1d4; border-color: var(--gold); }
.pick.pc { pointer-events: auto; }
ul.rules { padding-left: 20px; margin: 8px 0; }
ul.rules li { margin: 4px 0; }
ul.auglist { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
ul.auglist li { border-left: 3px solid var(--c); background: var(--panel2); padding: 8px 10px; border-radius: 0 8px 8px 0; font-size: 13px; }
ul.auglist .ri { color: var(--c); margin-right: 6px; font-size: 16px; }
ul.auglist small { color: var(--c); }

/* ---- tooltip and toasts */
#tip {
  position: fixed; z-index: 60; max-width: 270px; background: #0f0c17; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; pointer-events: none; box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
#tip b { display: block; }
#tip small { display: block; color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; margin-bottom: 3px; }
#toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  background: #261f37; border: 1px solid var(--line); border-left: 4px solid var(--text); border-radius: 8px; padding: 8px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5); animation: drop .2s ease-out; transition: opacity .4s, transform .4s; max-width: 92vw;
}
.toast.gold { border-left-color: var(--gold); }
.toast.bad { border-left-color: var(--red); }
.toast.purple { border-left-color: var(--purple); }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes drop { from { opacity: 0; transform: translateY(-10px); } }

/* ---- narrow screens: the side panel goes under the board */
@media (max-width: 899px) {
  #game { flex-direction: column; align-items: center; padding: 8px; gap: 10px; }
  #side { width: calc(var(--sq) * 8); max-width: 100%; position: static; max-height: none; }
  #moves { max-height: 220px; }
  .offers { grid-template-columns: 1fr; }
  ul.auglist { grid-template-columns: 1fr; }
  .lbl { width: 54px; }
}
