/* Sanlam Planning Poker styles */
:root {
  --blue: #0075C9;
  --blue-dark: #005A9C;
  --navy: #002B5C;
  --sky: #7FB8E6;
  --ice: #E8F2FB;
  --bg: #F4F7FB;
  --card: #FFFFFF;
  --ink: #102A43;
  --muted: #5B6B7F;
  --line: #D9E3EE;
  --green: #1E9E62;
  --amber: #E8A317;
  --red: #D64545;
  --felt: #0B4F8A;
  --felt-2: #0A6AB5;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(0, 43, 92, 0.10);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: linear-gradient(90deg, var(--navy), var(--blue)); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand .word { font-weight: 800; letter-spacing: .18em; font-size: 17px; }
.brand .sub { font-size: 12px; opacity: .85; letter-spacing: .04em; }
.room-meta { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.room-meta .rname { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.16); color: #fff; white-space: nowrap; }
.pill.code { font-family: ui-monospace, Consolas, monospace; letter-spacing: .12em; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.pill.off .dot { background: var(--red); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tbtn { border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.10); color: #fff; border-radius: 10px; padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.tbtn:hover { background: rgba(255,255,255,.22); }
.tbtn.active { background: #fff; color: var(--navy); }

#banner .demo { background: #FFF6DD; color: #6B4E00; border-bottom: 1px solid #F1DC9C; padding: 8px 20px; font-size: 13px; text-align: center; }

/* ---------- Buttons and forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 700; cursor: pointer; background: var(--blue); color: #fff; transition: transform .08s, background .15s, box-shadow .15s; }
.btn:hover { background: var(--blue-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: #A9BCCF; cursor: not-allowed; }
.btn.ghost { background: var(--ice); color: var(--blue-dark); }
.btn.ghost:hover { background: #D6E8F7; }
.btn.green { background: var(--green); }
.btn.green:hover { background: #18834F; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(30,158,98,.55); } 70% { box-shadow: 0 0 0 14px rgba(30,158,98,0); } 100% { box-shadow: 0 0 0 0 rgba(30,158,98,0); } }
label.field { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.input:focus { outline: 2px solid var(--sky); border-color: var(--blue); }
textarea.input { min-height: 70px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.seg { display: inline-flex; background: var(--ice); padding: 3px; border-radius: 10px; gap: 2px; width: 100%; }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--blue-dark); }
.seg button.on { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.08); color: var(--navy); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin: 6px 0; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--blue); }

/* ---------- Home ---------- */
.home { max-width: 1100px; margin: 0 auto; padding: 32px 20px 60px; }
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 30px; align-items: center; margin-bottom: 28px; }
.hero h1 { font-size: 38px; line-height: 1.1; margin: 0 0 12px; color: var(--navy); }
.hero p { color: var(--muted); font-size: 17px; margin: 0 0 8px; }
.hero-art { width: 100%; max-width: 440px; justify-self: center; }
.hero-art .fan > g { transform-origin: 220px 300px; animation: fanIn .9s cubic-bezier(.2,.8,.2,1) both; }
@keyframes fanIn { from { transform: rotate(0deg) translateY(40px); opacity: 0; } }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0 28px; }
.step { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); font-size: 13px; }
.step b { display: flex; align-items: center; gap: 8px; color: var(--navy); font-size: 14px; margin-bottom: 4px; }
.step .num { width: 24px; height: 24px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 12px; }
.forms { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.panel h2 { margin: 0 0 4px; font-size: 19px; color: var(--navy); }
.panel h3 { margin: 0 0 8px; font-size: 15px; color: var(--navy); }
.panel .actions { margin-top: 16px; }

/* ---------- Room layout ---------- */
.room { display: grid; grid-template-columns: 330px 1fr; gap: 18px; padding: 18px; max-width: 1500px; margin: 0 auto; }
.queue { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 92px); display: flex; flex-direction: column; padding: 16px; }
.queue-list { overflow-y: auto; margin: 10px -6px 0; padding: 0 6px; flex: 1; min-height: 120px; }
.progress { margin-top: 12px; }
.progress .bar { height: 8px; border-radius: 99px; background: var(--ice); overflow: hidden; }
.progress .bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--green)); border-radius: 99px; transition: width .5s; }
.progress .lbl { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.qitem { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 10px; border-radius: 10px; border: 1px solid transparent; cursor: default; margin-bottom: 6px; background: #FAFCFE; }
.qitem.clickable { cursor: pointer; }
.qitem.clickable:hover { border-color: var(--sky); background: var(--ice); }
.qitem.current { border-color: var(--blue); background: var(--ice); box-shadow: inset 4px 0 0 var(--blue); }
.qitem .k { font-size: 12px; font-weight: 700; color: var(--blue-dark); display: flex; gap: 6px; align-items: center; }
.qitem .s { grid-column: 1 / -1; font-size: 13px; line-height: 1.3; }
.qitem .sp { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--ice); color: var(--blue-dark); align-self: start; }
.qitem .sp.done { background: #DDF4E8; color: var(--green); }
.qitem .sp.saved { background: var(--green); color: #fff; }
.tag { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: #EEF2F6; color: var(--muted); }
.tag.rfr { background: #FFF1D6; color: #8A5A00; }
.empty { text-align: center; color: var(--muted); padding: 24px 10px; font-size: 14px; }
.empty svg { width: 90px; display: block; margin: 0 auto 8px; opacity: .9; }

.stage { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.story { padding: 18px 20px; }
.story .top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.story .key { font-weight: 800; color: var(--blue); text-decoration: none; font-size: 15px; }
.story h2 { margin: 2px 0 6px; font-size: 21px; color: var(--navy); }
.story .desc { white-space: pre-wrap; color: #334E68; font-size: 14px; max-height: 92px; overflow: hidden; position: relative; }
.story .desc.open { max-height: none; }
.story .desc:not(.open)::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 36px; background: linear-gradient(transparent, #fff); }
.linkbtn { border: 0; background: none; color: var(--blue); cursor: pointer; padding: 4px 0; font-weight: 600; font-size: 13px; }
.warn { background: #FFF6DD; border: 1px solid #F1DC9C; color: #6B4E00; padding: 8px 12px; border-radius: 10px; font-size: 13px; margin-top: 8px; }

/* ---------- Poker table ---------- */
.table-wrap { position: relative; height: 470px; padding: 0; overflow: hidden; }
.felt { position: absolute; left: 50%; top: 50%; width: 62%; height: 52%; transform: translate(-50%, -50%); border-radius: 999px; background: radial-gradient(ellipse at 50% 40%, var(--felt-2), var(--felt) 70%); box-shadow: inset 0 0 0 10px #083A66, inset 0 0 0 13px #2C8AD6, 0 18px 40px rgba(0, 43, 92, .35); display: grid; place-items: center; text-align: center; color: #fff; }
.felt .center { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; }
.felt .status { font-size: 14px; opacity: .92; }
.felt .bigv { font-size: 13px; letter-spacing: .1em; text-transform: uppercase; opacity: .8; }
.felt .final { font-size: 44px; font-weight: 800; line-height: 1; }
.felt-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.felt .btn.ghost { background: rgba(255,255,255,.16); color: #fff; }
.felt .btn.ghost:hover { background: rgba(255,255,255,.28); }
.timer { position: relative; width: 74px; height: 74px; }
.timer svg { width: 74px; height: 74px; transform: rotate(-90deg); }
.timer .t { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 16px; }
.timer.low .t { color: #FFD1D1; }
.seat { z-index: 2; position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 4px; width: 96px; transition: left .4s, top .4s; }
.seat .nm { font-size: 12px; font-weight: 600; max-width: 96px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.seat.offline { opacity: .45; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; position: relative; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.avatar .crown { position: absolute; top: -9px; right: -7px; font-size: 14px; }
.pcard { width: 50px; height: 70px; perspective: 600px; }
.pcard .inner { position: relative; width: 100%; height: 100%; transition: transform .7s cubic-bezier(.3,1.4,.5,1); transform-style: preserve-3d; }
.pcard.flipped .inner { transform: rotateY(180deg); }
.pcard .face { position: absolute; inset: 0; border-radius: 8px; backface-visibility: hidden; display: grid; place-items: center; font-weight: 800; }
.pcard .back { background: repeating-linear-gradient(45deg, var(--blue) 0 6px, var(--blue-dark) 6px 12px); border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.2); }
.pcard .back::after { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.75); }
.pcard .front { background: #fff; color: var(--navy); font-size: 22px; transform: rotateY(180deg); border: 2px solid var(--blue); box-shadow: 0 3px 8px rgba(0,0,0,.2); }
.pcard .front.hi { background: #FFF1D6; border-color: var(--amber); }
.pcard .front.lo { background: #E6F6EE; border-color: var(--green); }
.pcard.empty .face { display: none; }
.pcard.empty { border: 2px dashed #B9CBDD; border-radius: 8px; }
.pcard.voted .inner { animation: drop .35s ease-out; }
@keyframes drop { from { transform: translateY(-16px) scale(1.1); opacity: .2; } }
.watchers { position: absolute; left: 14px; bottom: 10px; font-size: 12px; color: var(--muted); }

/* ---------- Hand of cards ---------- */
.hand { position: sticky; bottom: 0; z-index: 10; padding: 12px 16px 14px; background: rgba(255,255,255,.97); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(0,43,92,.08); }
.hand.mini .row { display: none; }
.hand.mini { padding: 8px 16px; position: static; box-shadow: none; }
.hand .row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.hand .hint { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.hand.mini .hint { margin-bottom: 0; }
.dcard { width: 62px; height: 88px; border-radius: 10px; border: 2px solid var(--blue); background: #fff; color: var(--navy); font-size: 24px; font-weight: 800; cursor: pointer; position: relative; box-shadow: 0 4px 10px rgba(0,43,92,.12); transition: transform .15s, box-shadow .15s, background .15s; }
.dcard::before, .dcard::after { content: attr(data-v); position: absolute; font-size: 11px; font-weight: 700; color: var(--blue); }
.dcard::before { top: 4px; left: 6px; }
.dcard::after { bottom: 4px; right: 6px; transform: rotate(180deg); }
.dcard:hover:not(:disabled) { transform: translateY(-8px); box-shadow: 0 10px 18px rgba(0,43,92,.2); }
.dcard.sel { background: var(--blue); color: #fff; transform: translateY(-14px); box-shadow: 0 12px 22px rgba(0,117,201,.4); }
.dcard.sel::before, .dcard.sel::after { color: #fff; }
.dcard:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Results ---------- */
.results { padding: 18px 20px; animation: rise .5s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.results-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 18px; align-items: start; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar { transition: height .6s; }
.gauge { text-align: center; }
.gauge svg { width: 100%; max-width: 220px; }
.gauge .lbl { font-weight: 700; margin-top: -6px; }
.statlist { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--ice); border-radius: 10px; padding: 8px 10px; }
.stat .v { font-size: 20px; font-weight: 800; color: var(--navy); }
.stat .l { font-size: 12px; color: var(--muted); }
.talk { margin-top: 10px; font-size: 13px; background: #FAFCFE; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.decide { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: end; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-width: 42px; padding: 7px 10px; border-radius: 9px; border: 2px solid var(--line); background: #fff; font-weight: 800; cursor: pointer; color: var(--navy); }
.chip.on { border-color: var(--blue); background: var(--blue); color: #fff; }
.chip.sug { border-color: var(--green); }
.savebox { background: var(--ice); border-radius: 12px; padding: 12px 14px; margin-top: 14px; display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.saved-ok { display: flex; align-items: center; gap: 10px; color: var(--green); font-weight: 700; }

/* ---------- People ---------- */
.people { padding: 14px 16px; }
.people .list { display: flex; flex-wrap: wrap; gap: 8px; }
.person { display: flex; align-items: center; gap: 6px; background: #FAFCFE; border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px 3px 3px; font-size: 13px; }
.person .avatar { width: 26px; height: 26px; font-size: 11px; }
.person .x { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 2px; font-size: 13px; }
.person .x:hover { color: var(--blue); }

/* ---------- Summary ---------- */
.summary { max-width: 1200px; margin: 0 auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; gap: 12px; align-items: center; }
.tile .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--ice); }
.tile .v { font-size: 26px; font-weight: 800; color: var(--navy); line-height: 1; }
.tile .l { font-size: 13px; color: var(--muted); }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ok { color: var(--green); font-weight: 700; }

/* ---------- Toast and confetti ---------- */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 12px; box-shadow: var(--shadow); transition: transform .3s; z-index: 50; max-width: 90vw; font-size: 14px; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
#confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .results-grid { grid-template-columns: 1fr 1fr; }
  .results-grid .chart { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .room { grid-template-columns: 1fr; padding: 12px; }
  .queue { position: static; max-height: 420px; }
  .hero, .forms { grid-template-columns: 1fr; }
  .steps, .tiles { grid-template-columns: 1fr 1fr; }
  .table-wrap { height: 420px; }
  .felt { width: 54%; height: 44%; }
  .room-meta .rname { max-width: 60vw; }
}
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; position: static; }
  .tbtn { padding: 6px 9px; }
  .results-grid, .steps, .tiles { grid-template-columns: 1fr; }
  .dcard { width: 48px; height: 68px; font-size: 19px; }
  .hand .row { gap: 6px; }
  .seat { width: 70px; }
  .pcard { width: 38px; height: 54px; }
  .decide, .savebox { grid-template-columns: 1fr; }
  .hero h1 { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.sumchart { max-width: 760px; }
