/* Equation Hi-Lo — devilish dark theme */
:root {
  --bg: #0b0910;
  --bg2: #14101c;
  --panel: #191422;
  --panel2: #211a2d;
  --line: #2f2640;
  --text: #ece6f5;
  --muted: #9a8fae;
  --red: #e0344f;
  --red2: #8e1630;
  --gold: #e3b341;
  --green: #3fcf8e;
  --blue: #5aa9ff;
  --high: #ff7a45;
  --low: #4fb3ff;
  --swing: #c77dff;
  --r: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 15px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, #3a0f2a55, transparent 60%),
    radial-gradient(900px 500px at 100% 100%, #1b0f3a66, transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
.muted { color: var(--muted); }
.good { color: var(--green); }
.bad { color: #ff6b81; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }

/* ---------- buttons & fields */
.btn {
  border: 1px solid var(--line); background: var(--panel2); border-radius: 10px;
  padding: 9px 16px; font-weight: 600; transition: transform .08s, background .15s, border-color .15s;
}
.btn:hover:not(:disabled) { border-color: #4a3d63; background: #2a2139; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--red), var(--red2)); border-color: #ff5c77; box-shadow: 0 6px 18px #e0344f33; }
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #f04661, #a01a37); }
.btn.gold { background: linear-gradient(180deg, #f0c55a, #a87b17); color: #1a1205; border-color: #ffd66e; }
.btn.danger { background: transparent; border-color: #6b2333; color: #ff8b9d; }
.btn.ghost { background: transparent; }
.btn.big { padding: 13px 22px; font-size: 16px; }
.btn.tiny { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.opbtn { font-size: 22px; min-width: 52px; padding: 6px 12px; font-weight: 700; }
.btn.opbtn.sm { font-size: 18px; min-width: 40px; padding: 4px 8px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 6px; }
.link.sm { font-size: 12px; padding: 0 4px; }
.fld { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.fld input, .joinrow input {
  background: #0f0c15; border: 1px solid var(--line); border-radius: 10px; color: var(--text);
  padding: 10px 12px; font-size: 15px; width: 100%;
}
.fld input:focus, .joinrow input:focus { outline: 2px solid #e0344f66; border-color: var(--red); }
.fld small { color: #6e6582; font-size: 11px; }
.panel { background: linear-gradient(180deg, var(--panel), #15111d); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 12px; font-size: 17px; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

/* ---------- brand */
.brand { display: flex; align-items: center; gap: 12px; font-family: Cinzel, Georgia, serif; font-weight: 800; font-size: 40px; letter-spacing: .5px; }
.brand em { font-style: normal; color: var(--red); }
.brand .logo {
  width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; font-size: 34px;
  background: linear-gradient(145deg, #2a0e1c, #0d0a12); border: 1px solid #5a1a2e; color: var(--gold);
  box-shadow: inset 0 0 20px #e0344f44, 0 0 30px #e0344f22;
}
.brand.small { font-size: 20px; gap: 8px; }
.brand.small .logo { width: 32px; height: 32px; font-size: 20px; border-radius: 9px; }

/* ---------- home */
.home { max-width: 460px; margin: 0 auto; padding: 9vh 18px 40px; display: grid; gap: 16px; justify-items: center; text-align: center; }
.home .tag { color: var(--muted); margin: -4px 0 6px; }
.homebox { width: 100%; display: grid; gap: 14px; text-align: left; }
.or { text-align: center; color: var(--muted); font-size: 13px; position: relative; }
.or::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.or span { background: var(--panel); padding: 0 10px; position: relative; }
.joinrow { display: flex; gap: 10px; }
.joinrow input { letter-spacing: 6px; text-transform: uppercase; font-weight: 700; text-align: center; font-size: 18px; }
.notice { background: #2a1420; border: 1px solid #5a1a2e; padding: 10px 14px; border-radius: 10px; color: #ffc2cd; width: 100%; }

/* ---------- lobby */
.lobby { max-width: 1040px; margin: 0 auto; padding: 22px 18px 40px; display: grid; gap: 18px; }
.lobbyhead { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.roomcode { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); padding: 8px 14px; border-radius: 12px; }
.roomcode small { color: var(--muted); }
.roomcode b { font-size: 26px; letter-spacing: 6px; color: var(--gold); font-family: Cinzel, Georgia, serif; }
.cols { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; }
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.plist li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #120e18; }
.plist li.me { border-color: #5a1a2e; }
.plist .nm { font-weight: 600; flex: 1; }
.av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #3a1428; color: #ffb3c1; font-weight: 700; font-size: 14px; }
.av.bot { background: #1c2340; color: #9cc3ff; }
.x { background: none; border: 0; color: var(--muted); font-size: 16px; padding: 2px 6px; }
.x:hover { color: var(--red); }
.addbots { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.addbots span { color: var(--muted); font-size: 13px; margin-right: 4px; }
.setgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.lobbyfoot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.waiting { color: var(--muted); padding: 12px 0; }
.lobby .log { max-height: 220px; }

/* ---------- badges */
.bdg { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; padding: 2px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.bdg.ai { color: #9cc3ff; border-color: #2c3e66; }
.bdg.ai.hard { color: #ff9cb0; border-color: #6b2333; }
.bdg.ai.easy { color: #9be7c4; border-color: #22553f; }
.bdg.host { color: var(--gold); border-color: #6b5320; }
.bdg.dealer { color: #111; background: var(--gold); border-color: var(--gold); font-weight: 800; }
.bdg.off { color: #ff9cb0; border-color: #6b2333; }

/* ---------- cards */
.card {
  --c1: #f7d774; --c2: #a77b12; --ink: #2b1d00;
  position: relative; width: 58px; height: 80px; border-radius: 9px; flex: none;
  background: linear-gradient(150deg, var(--c1), var(--c2));
  color: var(--ink); display: grid; place-items: center; box-shadow: 0 4px 10px #0007, inset 0 1px 0 #fff6;
  border: 1px solid #0006;
}
.card .v { font-size: 34px; font-weight: 800; line-height: 1; font-family: Cinzel, Georgia, serif; }
.card .cn { position: absolute; bottom: 4px; font-size: 8.5px; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; opacity: .75; }
.card.c0 { --c1: #ffe07a; --c2: #b08414; --ink: #3a2700; }
.card.c1 { --c1: #f4f6f9; --c2: #9aa3ad; --ink: #23282e; }
.card.c2 { --c1: #f0a066; --c2: #8a4a1c; --ink: #2d1404; }
.card.c3 { --c1: #8a7860; --c2: #3e3427; --ink: #f1e6d4; }
.card.back { background: repeating-linear-gradient(45deg, #3a0f22, #3a0f22 6px, #24091a 6px, #24091a 12px); color: #ff8ba0; border-color: #6b2333; }
.card.back span { font-size: 26px; font-weight: 800; }
.card.hid { outline: 2px dashed #ff8ba0; outline-offset: 2px; }
.card .eye { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); background: #e0344f; color: #fff; font-size: 8.5px; padding: 1px 5px; border-radius: 99px; text-transform: uppercase; letter-spacing: .6px; }
.card.sm { width: 38px; height: 52px; border-radius: 7px; }
.card.sm .v { font-size: 21px; }
.card.sm .cn { font-size: 6.5px; bottom: 3px; }
.card.sm .eye { display: none; }
.cards { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ops { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.op { min-width: 28px; height: 28px; padding: 0 6px; border-radius: 7px; display: inline-grid; place-items: center; font-weight: 800; font-size: 16px; background: #0f0c15; border: 1px solid var(--line); }
.op.special { color: var(--gold); border-color: #6b5320; background: #1d160a; }
.op.gone { opacity: .35; text-decoration: line-through; }
.op sub { font-size: 9px; }

/* ---------- game layout */
.game { display: grid; grid-template-rows: auto 1fr auto; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; background: #0d0a12ee; backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tb-mid, .tb-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill { background: var(--panel2); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; font-size: 13px; color: var(--muted); }
.pill b { color: var(--text); }
.pill.phase { color: var(--text); font-weight: 600; border-color: #5a1a2e; background: #2a0f1d; }
.pill.phase.declare { border-color: #6b5320; background: #221a08; }
.pill.phase.showdown { border-color: #22553f; background: #0c2219; }
.timer { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: transparent; }
.timer i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--red), var(--gold)); transition: width .25s linear; }
.timer i.low { background: var(--red); }
.main { display: grid; grid-template-columns: 1fr 300px; gap: 16px; padding: 16px 18px; align-items: start; }
.table { display: grid; gap: 14px; }
.center { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; padding: 14px 18px; border-radius: var(--r); background: radial-gradient(ellipse at center, #3a1027 0%, #1a0d17 70%); border: 1px solid #4a1a2e; }
.pot small, .cinfo small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.pot b { font-size: 40px; font-family: Cinzel, Georgia, serif; color: var(--gold); line-height: 1; }
.cinfo { display: flex; gap: 22px; }
.cinfo b { font-size: 20px; }
.whoturn { margin-left: auto; color: var(--muted); }
.whoturn b { color: var(--text); }
.seats { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; }
.seat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: grid; gap: 4px; align-content: start; transition: border-color .2s, box-shadow .2s, opacity .2s; }
.seat.turn { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 24px #e3b34133; }
.seat.folded { opacity: .55; }
.seat.out { opacity: .35; filter: grayscale(1); }
.seat.winner { border-color: var(--green); box-shadow: 0 0 0 1px var(--green), 0 0 24px #3fcf8e33; }
.seat-h { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.seat-h .nm { font-weight: 700; }
.chips { margin-left: auto; font-weight: 800; color: var(--gold); display: inline-flex; align-items: center; gap: 5px; }
.chips::before { content: ''; width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe9a6, #b8860b); box-shadow: 0 0 0 2px #6b5320; }
.chips.big { font-size: 20px; }
.seat-f { font-size: 12px; color: var(--muted); margin-top: 4px; }
.seat-s { min-height: 20px; font-size: 13px; }
.st { color: var(--muted); }
.st.live { color: var(--gold); }
.st.ok { color: var(--green); }
.st.out { color: #ff8b9d; }
.side { font-size: 11px; font-weight: 800; letter-spacing: 1px; padding: 2px 8px; border-radius: 6px; display: inline-block; }
.side.high { background: #3a1a0c; color: var(--high); border: 1px solid #6b3215; }
.side.low { background: #0c2238; color: var(--low); border: 1px solid #154a6b; }
.side.swing { background: #2a1240; color: var(--swing); border: 1px solid #4d2470; }
.eq { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; margin-top: 3px; }
.eq.win, .win { color: var(--green); }
.won { display: inline-block; margin-top: 4px; color: var(--green); font-weight: 800; }

/* ---------- log */
.log { padding: 14px; max-height: calc(100vh - 140px); overflow: auto; position: sticky; top: 70px; }
.log h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.log ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.log li { padding-bottom: 6px; border-bottom: 1px solid #241d31; color: #d5cde3; }
.log li:first-child { color: #fff; }

/* ---------- my panel */
.mine { position: sticky; bottom: 0; z-index: 4; margin: 0 18px 14px; padding: 16px 18px; border-radius: var(--r); background: linear-gradient(180deg, #1d1527f2, #140f1cf8); border: 1px solid #5a1a2e; box-shadow: 0 -10px 40px #000a; backdrop-filter: blur(10px); display: grid; grid-template-columns: auto 1fr; gap: 6px 22px; align-items: start; }
.mine.myturn { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 -10px 40px #000a; }
.mine-h { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mine-h .nm { font-weight: 700; font-size: 16px; }
.mine-h .chips { margin-left: 0; }
.myhand .cards { gap: 8px; padding-top: 10px; }
.actions { min-width: 0; display: grid; gap: 10px; }
.hint { color: var(--muted); }
.hint.small { font-size: 12.5px; }
.prompt { font-size: 15px; }
.betbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.raise { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.raise input { width: 70px; background: #0f0c15; border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 7px 8px; text-align: center; font-weight: 700; }
.quick { display: inline-flex; gap: 4px; }

/* ---------- builder */
.declare { display: grid; gap: 10px; }
.declare.scratch { opacity: .92; }
.sidetabs { display: flex; gap: 8px; flex-wrap: wrap; }
.sidetab { background: #120e18; border: 1px solid var(--line); border-radius: 10px; padding: 6px 14px; text-align: left; display: grid; }
.sidetab small { color: var(--muted); font-size: 11px; }
.sidetab.high.on { border-color: var(--high); background: #2a140b; }
.sidetab.low.on { border-color: var(--low); background: #0b1e2e; }
.sidetab.swing.on { border-color: var(--swing); background: #1f0f30; }
.builder { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #110d17; display: grid; gap: 8px; }
.builder.high { border-left: 3px solid var(--high); }
.builder.low { border-left: 3px solid var(--low); }
.b-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.b-val { font-size: 14px; }
.b-val b { font-size: 18px; }
.slots { display: flex; align-items: flex-end; gap: 6px; flex-wrap: wrap; }
.nslot { display: grid; justify-items: center; gap: 3px; }
.slot { width: 44px; height: 58px; border-radius: 8px; display: grid; place-items: center; background: none; border: 1px dashed #4a3d63; color: #5d5175; font-size: 12px; padding: 0; position: relative; }
.slot.filled { border: 0; }
.slot.oslot { width: 36px; height: 36px; margin-bottom: 11px; font-size: 20px; font-weight: 800; }
.slot.empty { font-size: 11px; font-weight: 500; }
.slot.oslot.filled { background: #241c31; border: 1px solid #4a3d63; color: var(--text); }
.slot .rt { position: absolute; left: -10px; top: 50%; transform: translateY(-50%); color: var(--gold); font-weight: 900; font-size: 20px; z-index: 1; text-shadow: 0 0 6px #000; }
.rtog { width: 26px; height: 20px; border-radius: 6px; font-size: 12px; font-weight: 800; padding: 0; background: #1b1524; border: 1px solid var(--line); color: var(--muted); }
.rtog.on { background: #3a2b08; border-color: var(--gold); color: var(--gold); }
.rtog:disabled { opacity: .3; cursor: not-allowed; }
.tray { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding-top: 6px; border-top: 1px dashed #2c2339; }
.tray-c { background: none; border: 0; padding: 0; }
.tray-c:hover .card { transform: translateY(-3px); }
.tray-c .card { transition: transform .1s; }
.locked { display: grid; gap: 6px; justify-items: start; }

/* ---------- results */
.result { display: grid; gap: 8px; }
.rh { font-size: 15px; }
.tablewrap { overflow-x: auto; }
.result table { border-collapse: collapse; width: 100%; font-size: 13px; }
.result th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.result td { padding: 6px 8px; border-bottom: 1px solid #241d31; vertical-align: middle; }
.rcards { display: flex; gap: 3px; flex-wrap: nowrap; }
.rcards .card.sm { width: 28px; height: 38px; }
.rcards .card.sm .v { font-size: 15px; }
.rcards .card.sm .cn { display: none; }
.result tr.winrow td { background: #0c2219; }

/* ---------- overlay */
.overlay { position: fixed; inset: 0; background: #000b; display: grid; place-items: center; z-index: 20; padding: 18px; }
.over { width: min(460px, 100%); }
.over h2 { font-family: Cinzel, Georgia, serif; font-size: 26px; text-align: center; }
.rank { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; }
.rank li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: #120e18; border: 1px solid var(--line); }
.rank li:first-child { border-color: var(--gold); background: #221a08; }
.rank .pos { width: 24px; height: 24px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; font-weight: 800; font-size: 12px; }

/* ---------- dialog & toast */
dialog#rules { max-width: 640px; width: calc(100% - 28px); background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 22px 26px; box-shadow: var(--shadow); }
dialog#rules::backdrop { background: #000a; }
dialog#rules h2 { font-family: Cinzel, Georgia, serif; margin-top: 0; }
dialog#rules h3 { margin: 16px 0 4px; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--gold); }
dialog#rules li { margin: 4px 0; }
dialog#rules .x { position: absolute; top: 12px; right: 14px; }
.m { font-weight: 700; padding: 0 5px; border-radius: 4px; color: #111; }
.m.c0 { background: #f2cd5c; } .m.c1 { background: #d3d8de; } .m.c2 { background: #d38a52; } .m.c3 { background: #6b5d4a; color: #f1e6d4; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; z-index: 50; background: #3a1220; border: 1px solid var(--red); padding: 10px 18px; border-radius: 10px; transition: .2s; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.good { background: #0c2a1d; border-color: var(--green); }

/* ---------- responsive */
@media (max-width: 980px) {
  .main { grid-template-columns: 1fr; }
  .log { position: static; max-height: 240px; }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .brand { font-size: 30px; }
  .game { display: flex; flex-direction: column; }
  .topbar { order: 0; }
  .topbar .brand.small span:last-child { display: none; }
  .mine { order: 1; position: static; grid-template-columns: 1fr; margin: 8px 8px 0; padding: 12px; box-shadow: none; }
  .main { order: 2; }
  .main { padding: 12px 8px; }
  .seats { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .card { width: 50px; height: 70px; }
  .card .v { font-size: 28px; }
  .setgrid { grid-template-columns: 1fr; }
  .center { gap: 14px; }
  .pot b { font-size: 32px; }
}
