:root {
  --bg: #07100b;
  --bg2: #0c1711;
  --card: #101d16;
  --card2: #15261d;
  --line: #1f3a2b;
  --text: #e4f5ea;
  --muted: #84a593;
  --accent: #39ff88;
  --accent-dim: #1f9c55;
  --accent-glow: rgba(57, 255, 136, 0.45);
  --calm: #4fd1c5;
  --danger: #ff5a6e;
  --warn: #ffc857;
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #12301f 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  padding-top: 6px;
}
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.center { justify-content: center; text-align: center; }
.grow { flex: 1; }

/* Timer bar */
#timerbar { position: fixed; inset: 0 0 auto 0; height: 6px; background: rgba(255,255,255,.04); z-index: 50; }
#timerfill {
  height: 100%; width: 100%; transform-origin: right center; transform: scaleX(0);
  background: linear-gradient(90deg, var(--calm), var(--accent));
  box-shadow: 0 0 12px rgba(79, 209, 197, .5);
}
#timerbar.low #timerfill { background: #ff7a88; animation: pulse 1s ease-in-out infinite; box-shadow: 0 0 14px rgba(255, 90, 110, .6); }
#timerbar.flash { animation: barflash .45s ease-out; }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes barflash { 0% { background: rgba(255, 90, 110, .9); height: 14px; } 100% { background: rgba(255,255,255,.04); height: 6px; } }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; max-width: 1280px; margin: 0 auto; }
.brand { font-weight: 900; font-size: 1.45rem; letter-spacing: -.02em; }
.brand span, h1 span { color: var(--accent); text-shadow: 0 0 18px var(--accent-glow); }
.top-right { display: flex; gap: 12px; align-items: center; }
.me { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; cursor: pointer; }
.me:hover { border-color: var(--accent-dim); }
.me:disabled { cursor: default; border-color: var(--line); }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.conn.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.conn.off { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

main { max-width: 1280px; margin: 0 auto; padding: 0 22px 60px; }

/* Cards and controls */
.card { background: linear-gradient(180deg, var(--card), var(--bg2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.narrow { max-width: 440px; margin: 9vh auto 0; }
.btn {
  border: 1px solid var(--line); background: var(--card2); border-radius: 10px; padding: 9px 16px; cursor: pointer;
  transition: transform .08s, border-color .15s, background .15s, box-shadow .15s; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent-dim); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #032312; font-weight: 800; box-shadow: 0 0 22px rgba(57,255,136,.25); }
.btn.primary:hover:not(:disabled) { box-shadow: 0 0 30px rgba(57,255,136,.45); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.big { padding: 13px 26px; font-size: 1.05rem; }
.btn.small { padding: 5px 10px; font-size: .85rem; }
input[type=text], input[type=number], input:not([type]), textarea {
  background: #08130d; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; outline: none; width: 100%;
}
input:focus, textarea:focus { border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgba(57,255,136,.12); }
input:disabled, textarea:disabled { opacity: .65; }
textarea { resize: vertical; min-height: 54px; }
input[type=checkbox] { accent-color: var(--accent); width: 17px; height: 17px; }
.error { background: rgba(255, 90, 110, .1); border: 1px solid rgba(255, 90, 110, .4); color: #ffb3bd; padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }

/* Name screen */
.name-screen h1 { font-size: 2.6rem; font-weight: 900; letter-spacing: -.03em; }
.name-screen form { display: flex; gap: 10px; margin-top: 18px; }

/* Lobby browser */
.browser { max-width: 900px; margin: 3vh auto 0; display: grid; gap: 16px; }
.code-join { max-width: 320px; }
.code-join input { text-transform: uppercase; letter-spacing: .15em; }
.lobby-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.lobby-card { text-align: left; cursor: pointer; display: grid; gap: 6px; transition: border-color .15s, transform .12s, box-shadow .15s; }
.lobby-card:hover:not(.ingame) { border-color: var(--accent-dim); transform: translateY(-2px); box-shadow: 0 6px 24px rgba(57,255,136,.08); }
.lobby-card.ingame { opacity: .45; cursor: not-allowed; filter: grayscale(.6); }
.lobby-card .lname { font-weight: 700; font-size: 1.05rem; }
.lobby-card .lprompt { color: var(--muted); font-size: .88rem; min-height: 1.2em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.tag.green { color: var(--accent); border-color: var(--accent-dim); }
.empty { grid-column: 1 / -1; color: var(--muted); text-align: center; padding: 30px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* Settings form */
.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 14px 0 18px; }
.field { display: grid; gap: 5px; font-size: .88rem; color: var(--muted); }
.field.full { grid-column: 1 / -1; }
.field .inline { display: flex; gap: 10px; align-items: center; }
.field .inline input[type=number] { max-width: 90px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: .92rem; }
.check input[type=number] { width: 70px; padding: 5px 8px; }

/* Lobby */
.lobby { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; position: relative; }
.code { font-family: var(--mono); letter-spacing: .18em; background: #08130d; border: 1px solid var(--line); padding: 4px 10px; border-radius: 8px; color: var(--accent); }
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plist li.lrow { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #0a1510; border: 1px solid var(--line); border-radius: 10px; }
.plist .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crown { color: var(--warn); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.dot.off { background: #4a5b52; }
.you { color: var(--accent); font-size: .75rem; }
.overlay {
  position: fixed; inset: 0; background: rgba(4, 10, 7, .82); backdrop-filter: blur(6px); z-index: 40;
  display: grid; place-content: center; text-align: center; gap: 8px; padding: 20px;
}
.overlay p { margin: 0; font-size: 1.15rem; }
.spinner { width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; box-shadow: 0 0 30px var(--accent-glow); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Game */
.game { display: grid; grid-template-columns: 250px minmax(0, 1fr) 270px; gap: 16px; align-items: start; }
.side { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--line) transparent; scrollbar-gutter: stable; }
.side::-webkit-scrollbar { width: 6px; height: 0; }
.side::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
.side::-webkit-scrollbar-track { background: transparent; }
.lots-side { position: static; max-height: none; overflow: hidden; }
.base { display: flex; gap: 12px; align-items: center; padding: 10px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(16, 29, 22, .6); margin-bottom: 16px; }
.base .be { font-size: 2rem; }
.base b { display: block; }
.stage { min-width: 0; }
.lotcard { text-align: center; padding: 26px 22px; position: relative; overflow: hidden; }
.lotcard .le { font-size: 4.2rem; line-height: 1.1; filter: drop-shadow(0 0 18px rgba(57,255,136,.25)); }
.lotcard .ln { font-size: 1.6rem; font-weight: 800; margin: 8px 0 4px; }
.lotcard .ld { color: var(--muted); max-width: 520px; margin: 0 auto; }
.lotcard .lv { margin-top: 12px; color: var(--muted); font-size: .9rem; }
.lotcard .lv b { color: var(--text); }
.lotcard .lnum { position: absolute; top: 12px; left: 14px; font-size: .8rem; color: var(--muted); }
.lotcard.enter { animation: cardin .45s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes cardin { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.stamp {
  position: absolute; inset: 0; display: grid; place-content: center; background: rgba(4, 12, 8, .72);
  font-size: 1.7rem; font-weight: 900; letter-spacing: .02em; animation: stamp .35s ease-out;
}
.stamp.sold { color: var(--accent); text-shadow: 0 0 20px var(--accent-glow); }
.stamp.unsold { color: var(--muted); }
.stamp small { display: block; font-size: 1rem; color: var(--text); font-weight: 600; margin-top: 4px; }
@keyframes stamp { from { opacity: 0; transform: scale(1.3); } }

.pricebox { position: relative; text-align: center; margin: 22px 0 8px; min-height: 104px; }
.price { font-size: 4rem; font-weight: 900; font-family: var(--mono); letter-spacing: -.04em; color: var(--accent); text-shadow: 0 0 26px var(--accent-glow); display: inline-block; }
.price.bump { animation: bump .28s ease-out; }
@keyframes bump { 40% { transform: scale(1.18); } }
.leader { color: var(--muted); min-height: 1.4em; }
.leader b { color: var(--text); }
.leader.slide { animation: slidein .3s ease-out; }
@keyframes slidein { from { opacity: 0; transform: translateX(-24px); } }
#floaters { position: absolute; inset: 0; pointer-events: none; }
.floater {
  position: absolute; left: 50%; top: 30%; font-weight: 900; font-size: 1.6rem; color: var(--accent);
  text-shadow: 0 0 14px var(--accent), 0 0 30px var(--accent-glow); animation: floatup 1s ease-out forwards; white-space: nowrap;
}
.floater small { font-size: .8rem; color: var(--text); text-shadow: none; display: block; font-weight: 600; }
@keyframes floatup { from { opacity: 1; transform: translate(-50%, 0) scale(.8); } 20% { transform: translate(-50%, -12px) scale(1.15); } to { opacity: 0; transform: translate(-50%, -90px) scale(1); } }

.controls { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-top: 8px; }
.btn.bid {
  font-size: 2rem; font-weight: 900; padding: 20px; background: var(--accent); color: #032312; border-color: var(--accent);
  box-shadow: 0 0 30px rgba(57,255,136,.3); border-radius: 16px;
}
.btn.bid:hover:not(:disabled) { box-shadow: 0 0 44px rgba(57,255,136,.55); }
.btn.skip { font-size: 1.2rem; font-weight: 700; border-radius: 16px; }
.mymoney { text-align: center; margin-top: 14px; font-size: 1.05rem; }
.mymoney b { color: var(--accent); font-family: var(--mono); font-size: 1.3rem; }
.hint { text-align: center; color: var(--muted); min-height: 1.4em; margin-top: 4px; font-size: .9rem; }

.grid-lots { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.mini { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: left; display: grid; gap: 3px; position: relative; transition: border-color .15s, transform .12s, box-shadow .2s, opacity .2s; }
.mini .me2 { font-size: 1.8rem; }
.mini .mn { font-weight: 700; line-height: 1.25; }
.mini .md { color: var(--muted); font-size: .8rem; }
.mini .mv { font-family: var(--mono); color: var(--accent); font-weight: 700; }
.mini.pickable { cursor: pointer; }
.mini.pickable:hover { border-color: var(--accent); transform: translateY(-2px); }
.mini.cant { opacity: .4; }
.mini.taken { border-color: var(--accent); box-shadow: 0 0 22px rgba(57,255,136,.35); }
.mini.taken::after { content: "✓"; position: absolute; top: 8px; right: 10px; color: var(--accent); font-weight: 900; }
.mini.glow { animation: glow 1.2s ease-out; }
@keyframes glow { 0% { box-shadow: 0 0 0 rgba(57,255,136,0); transform: scale(1); } 25% { box-shadow: 0 0 40px rgba(57,255,136,.9); transform: scale(1.05); } 100% { box-shadow: 0 0 22px rgba(57,255,136,.35); transform: scale(1); } }
.mini.gone { opacity: .35; }
.stage-head { text-align: center; margin-bottom: 14px; }
.stage-head .big { font-size: 1.4rem; font-weight: 800; }
.stage-head .big b { color: var(--accent); }

/* Lot sidebar */
.lotlist { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.lotrow { display: flex; gap: 8px; align-items: center; min-width: 0; padding: 6px 8px; border-radius: 8px; font-size: .88rem; border: 1px solid transparent; }
.lotrow .le { font-size: 1.15rem; width: 1.5em; text-align: center; flex: none; }
.lotrow .lnm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lotrow .lst { font-size: .78rem; color: var(--muted); text-align: right; white-space: nowrap; }
.lotrow.sold .lst { color: var(--accent); }
.lotrow.unsold { opacity: .45; }
.lotrow.current { border-color: var(--accent-dim); background: rgba(57,255,136,.07); }
.lotsec { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin: 10px 0 4px; }

/* Player accordion */
.acc li { background: #0a1510; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.acc .ahead { display: flex; width: 100%; gap: 8px; align-items: center; padding: 9px 10px; background: none; border: 0; cursor: pointer; text-align: left; }
.acc .ahead:hover { background: rgba(57,255,136,.04); }
.acc .amoney { font-family: var(--mono); color: var(--accent); }
.acc .acount { font-size: .75rem; color: var(--muted); }
.acc .chev { color: var(--muted); transition: transform .25s; font-size: .8rem; }
.acc li.open .chev { transform: rotate(90deg); }
.acc .abody { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .28s ease; }
.acc li.open .abody { grid-template-rows: 1fr; }
.acc .abody > div { overflow: hidden; }
.acc .abody ul { list-style: none; margin: 0; padding: 0 10px 10px 28px; display: grid; gap: 3px; font-size: .85rem; }
.acc .abody .none { color: var(--muted); font-size: .85rem; padding: 0 10px 10px 28px; }
.acc .akick { padding: 0 10px 10px 28px; }
.acc li.leading { border-color: var(--accent-dim); box-shadow: 0 0 14px rgba(57,255,136,.15); }
.acc li.skipped .pname { opacity: .45; text-decoration: line-through; }

/* Results */
.results { display: grid; gap: 18px; }
.results-head { text-align: center; }
.results-head h2 { font-size: 1.8rem; }
.builds { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.build { display: grid; gap: 10px; align-content: start; animation: cardin .45s ease-out both; }
.build.mine { border-color: var(--accent-dim); }
.build.voted { border-color: var(--accent); box-shadow: 0 0 24px rgba(57,255,136,.3); }
.build .bh { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.build .bname { font-weight: 800; font-size: 1.1rem; }
.build .bbase { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: #0a1510; }
.build .bbase .be { font-size: 1.7rem; }
.build ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: .9rem; }
.build ul li { display: flex; gap: 8px; }
.build .bstats { font-size: .82rem; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.build .bstats b { color: var(--text); font-family: var(--mono); }
.votes-badge { font-family: var(--mono); color: var(--accent); font-weight: 800; }

.podium { display: flex; justify-content: center; align-items: flex-end; gap: 14px; min-height: 240px; margin: 10px 0; }
.pod { display: grid; justify-items: center; gap: 8px; width: 150px; }
.pod .pn { font-weight: 800; text-align: center; overflow-wrap: anywhere; }
.pod .pv { color: var(--muted); font-size: .85rem; }
.pod .block {
  width: 100%; border-radius: 12px 12px 4px 4px; display: grid; place-content: center; font-size: 2.2rem; font-weight: 900;
  background: linear-gradient(180deg, rgba(57,255,136,.35), rgba(57,255,136,.05)); border: 1px solid var(--accent-dim);
  animation: rise .7s cubic-bezier(.2, .9, .3, 1.1) both; transform-origin: bottom;
}
.pod.p1 .block { height: 170px; box-shadow: 0 0 40px rgba(57,255,136,.35); }
.pod.p2 .block { height: 120px; animation-delay: .15s; }
.pod.p3 .block { height: 85px; animation-delay: .3s; }
@keyframes rise { from { transform: scaleY(0); opacity: 0; } }
.ranklist { max-width: 420px; margin: 0 auto; width: 100%; }

/* AI images */
img[data-zoom] { cursor: zoom-in; }
.bthumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; border: 1px solid var(--line); }
.hero { display: block; width: min(260px, 70%); aspect-ratio: 1; margin: 0 auto 12px; border-radius: 16px; object-fit: cover; border: 1px solid var(--line); box-shadow: 0 10px 40px rgba(0,0,0,.4); }
span.hero, span.bthumb { display: grid; place-content: center; }
.imgwait { background: linear-gradient(110deg, #0c1a13 30%, #17301f 50%, #0c1a13 70%); background-size: 250% 100%; animation: shimmer 1.4s linear infinite; border-radius: 12px; }
.imgwait span { font-size: 1.6rem; opacity: .7; }
span.hero.imgwait span { font-size: 4rem; }
.imgwait.big { aspect-ratio: 1; display: grid; place-content: center; text-align: center; gap: 6px; color: var(--muted); }
.imgwait.big span { font-size: 2.6rem; }
@keyframes shimmer { to { background-position: -150% 0; } }
.bimg img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); animation: cardin .5s ease-out; }
.imgfail { color: var(--muted); font-size: .82rem; text-align: center; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; }
.podpics { display: flex; gap: 6px; justify-content: center; }
.podimg { width: 96px; height: 96px; border-radius: 12px; object-fit: cover; border: 1px solid var(--accent-dim); }
.pod.p1 .podimg { width: 130px; height: 130px; box-shadow: 0 0 30px rgba(57,255,136,.35); }
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(3, 8, 5, .9); display: grid; place-content: center; justify-items: center; gap: 10px; cursor: zoom-out; padding: 20px; }
.lightbox img { max-width: min(92vw, 820px); max-height: 82vh; border-radius: 16px; box-shadow: 0 0 60px rgba(57,255,136,.25); }
.lb-cap { color: var(--muted); }

/* Toasts, popup, rain */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; width: min(92vw, 420px); pointer-events: none; }
.toast { background: rgba(16, 29, 22, .96); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; text-align: center; box-shadow: 0 8px 30px rgba(0,0,0,.45); animation: toastin .25s ease-out; }
.toast.err { border-color: rgba(255,90,110,.5); color: #ffc2ca; }
.toast.good { border-color: var(--accent-dim); }
.toast.out { animation: toastout .3s ease-in forwards; }
@keyframes toastin { from { opacity: 0; transform: translateY(12px); } }
@keyframes toastout { to { opacity: 0; transform: translateY(12px); } }
.popup {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 70; text-align: center;
  background: rgba(10, 24, 16, .97); border: 2px solid var(--accent); border-radius: 20px; padding: 26px 40px;
  box-shadow: 0 0 60px rgba(57,255,136,.45); animation: popin .4s cubic-bezier(.2, .9, .3, 1.4); pointer-events: none;
}
.popup .pe { font-size: 3.4rem; }
.popup .pt { font-size: 1.5rem; font-weight: 900; color: var(--accent); }
.popup .ps { color: var(--muted); }
.popup.out { animation: popout .35s ease-in forwards; }
@keyframes popin { from { opacity: 0; transform: translate(-50%, -50%) scale(.6); } }
@keyframes popout { to { opacity: 0; transform: translate(-50%, -50%) scale(.9); } }
#rain { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 65; }

/* Responsive */
@media (max-width: 1080px) {
  .game { grid-template-columns: minmax(0, 1fr) 260px; }
  .game > .lots-side { grid-column: 1 / -1; order: 3; position: static; max-height: none; }
}
@media (max-width: 760px) {
  main { padding: 0 12px 40px; }
  .top { padding: 12px; }
  .lobby, .game { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .price { font-size: 3.2rem; }
  .lotcard .le { font-size: 3.2rem; }
  .podium { gap: 8px; }
  .pod { width: 31%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
