:root {
  color-scheme: dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  --bg: #090b14;
  --glass: rgba(255, 255, 255, .06);
  --glass2: rgba(255, 255, 255, .1);
  --line: rgba(255, 255, 255, .14);
  --tx: #eef0f8;
  --mut: #9aa1ba;
  --ac: #f0b955;
  --ac2: #7c8cff;
  --err: #ff7a8a;
  --ok: #6ee7b7;
  --suit-red: #e11d48;
  --suit-black: #111827;
}

*, *::before, *::after {
  box-sizing: inherit;
}

html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--tx);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Ambient Background Blobs */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .45;
  z-index: -1;
  pointer-events: none;
}

.b1 {
  width: 440px;
  height: 440px;
  background: #4b3fd9;
  top: -120px;
  left: -100px;
}

.b2 {
  width: 400px;
  height: 400px;
  background: #c9822a;
  bottom: -120px;
  right: -80px;
  opacity: .32;
}

.b3 {
  width: 320px;
  height: 320px;
  background: #12877a;
  top: 40%;
  left: 55%;
  opacity: .24;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 22px;
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .08);
}

.hide {
  display: none !important;
}

h1, h2, h3, h4 {
  margin: 0;
  letter-spacing: -.01em;
}

button, input, select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--ac);
  outline-offset: 2px;
}

.btn {
  border: 1px solid var(--line);
  background: var(--glass2);
  padding: .7rem 1.1rem;
  border-radius: 14px;
  cursor: pointer;
  transition: background .15s, transform .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(255, 255, 255, .17);
}

.btn:active {
  transform: scale(.98);
}

.btn.pri {
  background: linear-gradient(135deg, #f6c76a, #e39a35);
  color: #1b1305;
  border: 0;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(227, 154, 53, .3);
}

.btn.pri:hover {
  filter: brightness(1.07);
}

.btn.sm {
  padding: .4rem .8rem;
  border-radius: 10px;
  font-size: .85rem;
}

.btn.danger {
  background: rgba(255, 122, 138, .15);
  border-color: rgba(255, 122, 138, .35);
  color: var(--err);
}

.btn.danger:hover {
  background: rgba(255, 122, 138, .25);
}

input, select {
  width: 100%;
  padding: .75rem .9rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .28);
  outline: none;
  color: var(--tx);
  transition: border-color .15s;
}

input:focus, select:focus {
  border-color: var(--ac2);
}

select option {
  background: #14172a;
  color: var(--tx);
}

label {
  display: block;
  font-size: .85rem;
  color: var(--mut);
  margin: .9rem 0 .35rem;
}

.err {
  color: var(--err);
  font-size: .85rem;
  min-height: 1.3em;
  margin-top: .7rem;
}

/* ==================== 1. AUTH SCREEN (MASUK & NAMA) ==================== */
#auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}

.card {
  width: 100%;
  max-width: 420px;
  padding: 2.2rem 1.8rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: .9rem;
  margin-bottom: 1.4rem;
}

/* Card Tile Logo */
.tile-card {
  width: 38px;
  height: 60px;
  border-radius: 8px;
  background: #f4efe3;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px 6px;
  flex: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .45);
  transform: rotate(-8deg);
  border: 1px solid #d4ceb8;
  color: #171a2b;
}

.tile-card .tc-top {
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.tile-card .tc-mid {
  font-size: 18px;
  line-height: 1;
  align-self: center;
}

.tile-card .tc-bot {
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  align-self: flex-end;
}

.brand h1 {
  font-size: 1.75rem;
  font-weight: 800;
}

.brand p {
  margin: 0;
  color: var(--mut);
  font-size: .9rem;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, .28);
  border-radius: 14px;
  margin-bottom: .4rem;
}

.tabs button {
  border: 0;
  background: none;
  padding: .55rem;
  border-radius: 11px;
  cursor: pointer;
  color: var(--mut);
  font-weight: 600;
  transition: all .15s;
}

.tabs button.on {
  background: var(--glass2);
  color: var(--tx);
}

.card .btn.pri {
  width: 100%;
  margin-top: 1.1rem;
}

/* ==================== 2. MAIN LOBBY SCREEN (#app) ==================== */
#app {
  max-width: 1060px;
  margin: 0 auto;
  padding: 1.2rem;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .8rem 1.1rem;
  margin-bottom: 1.2rem;
}

.top .brand {
  margin: 0;
}

.top .tile-card {
  width: 24px;
  height: 38px;
  padding: 3px 4px;
  border-radius: 5px;
}

.top .tile-card .tc-top {
  font-size: 8px;
}

.top .tile-card .tc-mid {
  font-size: 12px;
}

.top .tile-card .tc-bot {
  font-size: 7px;
}

.who {
  display: flex;
  align-items: center;
  gap: .7rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--ac2), #b46bff);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

.grid {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 1.2rem;
  align-items: start;
}

@media (max-width: 820px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.panel {
  padding: 1.4rem;
}

.panel h2 {
  font-size: 1.15rem;
  margin-bottom: .3rem;
  font-weight: 700;
}

.sub {
  color: var(--mut);
  font-size: .9rem;
  margin: 0 0 1rem;
}

.modes {
  display: grid;
  gap: 1.2rem;
}

.row {
  display: flex;
  gap: .6rem;
}

.row > * {
  flex: 1;
}

.row .btn {
  flex: none;
}

.sep {
  display: flex;
  align-items: center;
  gap: .8rem;
  color: var(--mut);
  font-size: .8rem;
  margin: 1rem 0;
}

.sep::before, .sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.code-in {
  text-transform: uppercase;
  letter-spacing: .35em;
  text-align: center;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}

th {
  font-weight: 500;
  color: var(--mut);
  text-align: left;
  padding: .4rem .5rem;
  font-size: .82rem;
}

td {
  padding: .6rem .5rem;
  border-top: 1px solid var(--line);
}

td:last-child, th:last-child {
  text-align: right;
}

.rk {
  width: 2rem;
  font-weight: 700;
  color: var(--mut);
}

tr.r1 .rk {
  color: #f6c76a;
}

tr.r2 .rk {
  color: #cfd4e6;
}

tr.r3 .rk {
  color: #d99a6c;
}

tr.me td {
  background: rgba(124, 140, 255, .14);
}

.pts {
  font-weight: 700;
  color: var(--ac);
}

/* ==================== 3. WAITING ROOM SCREEN (#room) ==================== */
#room {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.2rem;
}

.rc {
  padding: 1.8rem;
  text-align: center;
}

.codebox {
  display: inline-flex;
  gap: .45rem;
  margin: .8rem 0 .4rem;
}

.codebox span {
  width: 48px;
  height: 60px;
  display: grid;
  place-items: center;
  font-size: 1.7rem;
  font-weight: 800;
  border-radius: 12px;
  background: rgba(0, 0, 0, .35);
  border: 1px solid var(--line);
  color: var(--ac);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .4);
}

.slots {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .7rem;
  margin: 1.4rem 0;
  text-align: left;
}

.slot {
  padding: .8rem 1rem;
  border-radius: 16px;
  border: 1px dashed var(--line);
  display: flex;
  align-items: center;
  gap: .7rem;
  min-height: 62px;
  color: var(--mut);
  background: rgba(255, 255, 255, .02);
}

.slot.on {
  border-style: solid;
  background: var(--glass);
  color: var(--tx);
  border-color: rgba(240, 185, 85, .4);
}

.slot .av {
  width: 32px;
  height: 32px;
  font-size: .85rem;
  flex: none;
}

.slot .pinfo {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.slot .pname {
  font-weight: 700;
  font-size: .92rem;
  color: var(--tx);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot .prole {
  font-size: .75rem;
  color: var(--mut);
}

.tag {
  margin-left: auto;
  font-size: .75rem;
  padding: .15rem .5rem;
  border-radius: 99px;
  background: rgba(240, 185, 85, .18);
  color: var(--ac);
  font-weight: 600;
}

.hint {
  font-size: .85rem;
  color: var(--mut);
}

.trow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .7rem;
  margin: -.4rem 0 1rem;
  color: var(--mut);
  font-size: .9rem;
}

.trow select {
  width: auto;
}

/* ==================== 4. GAME ARENA SCREEN (#game) ==================== */
body.ingame {
  overflow: hidden;
}

#game {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: clamp(6px, 1vw, 12px);
  height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.1vh, 12px);
  overflow: hidden;
}

.gtop {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .6rem;
  padding: .1rem .3rem;
}

.gt-l {
  display: flex;
  align-items: baseline;
  gap: .7rem;
  min-width: 0;
}

.gt-l h1 {
  margin: 0;
  font-size: clamp(20px, 2.6vw, 28px);
  letter-spacing: .3px;
  font-weight: 800;
}

.gt-l span {
  color: var(--mut);
  font-size: .9rem;
  white-space: nowrap;
}

.gt-r {
  display: flex;
  gap: .4rem;
}

/* Opponents in Game */
.opps {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .6rem;
}

.opp {
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .4rem .7rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .045);
  transition: all .2s ease;
}

.opp.on {
  border-color: rgba(240, 185, 85, .9);
  box-shadow: 0 0 0 1px rgba(240, 185, 85, .25), 0 8px 24px rgba(240, 185, 85, .12);
  background: rgba(240, 185, 85, .08);
}

.opp-l {
  display: flex;
  align-items: center;
  gap: 8px;
}

.opp b {
  font-size: .88rem;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.opp .status-desc {
  font-size: .76rem;
  color: var(--mut);
}

.av2 {
  position: relative;
  width: 38px;
  height: 38px;
  flex: none;
}

.av2 .face {
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--ac2), #b46bff);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, .3);
}

.av2 svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.av2 circle {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
}

.av2 .trk {
  stroke: rgba(255, 255, 255, .1);
}

.av2 .prg {
  stroke: var(--ac);
  stroke-dasharray: 106.8;
  stroke-dashoffset: 0;
  opacity: 0;
  transition: stroke-dashoffset .2s linear;
}

.opp.on .av2 .prg {
  opacity: 1;
}

.opp-stats {
  display: flex;
  gap: 6px;
  align-items: center;
}

.stat-chip {
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .3);
  border: 1px solid var(--line);
  text-align: center;
  font-size: .78rem;
  min-width: 48px;
}

.stat-chip .lbl {
  display: block;
  font-size: 9px;
  color: var(--mut);
  text-transform: uppercase;
}

.stat-chip .val {
  font-weight: 700;
  color: var(--tx);
}

.stat-chip.dead .val {
  color: var(--err);
}

/* Center Table: Carpet Felt & 7 Spades Suit Rows */
.felt {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(6px, 1.2vh, 12px);
  padding: clamp(8px, 1.2vw, 16px);
  border-radius: clamp(16px, 1.8vw, 24px);
  overflow: hidden;
}

.table-board {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px;
}

/* 4 Suit Rows on Table */
.suit-track {
  display: grid;
  grid-template-columns: 84px repeat(13, 1fr);
  gap: 4px;
  align-items: center;
  background: rgba(0, 0, 0, .22);
  border: 1px solid rgba(255, 255, 255, .05);
  border-radius: 10px;
  padding: 3px 6px;
}

.suit-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
}

.suit-badge .s-sym {
  font-size: 20px;
  line-height: 1;
}

.suit-badge.red .s-sym {
  color: var(--suit-red);
}

.suit-badge.black .s-sym {
  color: #fff;
}

.suit-badge-info {
  display: flex;
  flex-direction: column;
}

.suit-badge-info .s-name {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
}

.suit-badge-info .s-cnt {
  font-size: 9.5px;
  color: var(--mut);
}

/* Slot on Table */
.board-slot {
  height: 48px;
  border-radius: 6px;
  border: 1px dashed rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .02);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all .15s ease;
}

.board-slot.center-seven {
  border-color: rgba(240, 185, 85, .45);
  background: rgba(240, 185, 85, .05);
}

.board-slot.open-next {
  border-color: var(--ok);
  background: rgba(110, 231, 183, .08);
}

.board-slot .slot-ph {
  font-size: 9px;
  color: rgba(255, 255, 255, .2);
  font-weight: 700;
}

/* Table Card: Ivory Dominskuy Finish */
.tcard {
  width: 100%;
  height: 100%;
  background: #f4efe3;
  border-radius: 5px;
  border: 1px solid #d4ceb8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 2px 3px;
  animation: popIn .18s cubic-bezier(.16, 1, .3, 1);
  position: relative;
}

.tcard.is-seven {
  box-shadow: 0 0 0 1.5px var(--ac), 0 0 12px rgba(240, 185, 85, .4);
}

.tcard.last-played {
  box-shadow: 0 0 0 2px var(--ac), 0 0 16px rgba(240, 185, 85, .55);
}

.tcard.red {
  color: var(--suit-red);
}

.tcard.black {
  color: var(--suit-black);
}

.tcard .tc-rank-sm {
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1;
  align-self: flex-start;
}

.tcard .tc-suit-center {
  font-size: 15px;
  line-height: 1;
}

.tcard .tc-rank-bot {
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1;
  align-self: flex-end;
}

/* Status Banner & Timer */
.gstat {
  flex: none;
  text-align: center;
  font-weight: 600;
  min-height: 2em;
  line-height: 1.3;
  font-size: .92rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.gstat.mine {
  color: var(--ac);
}

.gstat.warn {
  color: var(--err);
}

.tbar {
  flex: none;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .12);
  overflow: hidden;
  margin: 0 4px;
}

#tfill {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--ac);
  transition: width .2s linear;
}

/* Hand Cards Area */
.mycnt {
  flex: none;
  text-align: center;
  font-size: .85rem;
  color: var(--mut);
}

.mycnt b {
  display: inline-grid;
  place-items: center;
  min-width: 1.7em;
  height: 1.7em;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--ac);
  color: #1b1305;
  margin: 0 .25em;
  font-size: .9em;
}

.hand {
  flex: none;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(4px, .8vw, 8px);
  padding: 8px 2px 2px 2px;
  min-height: 94px;
  overflow-x: auto;
  overflow-y: visible;
}

.hcard {
  flex: 0 0 58px;
  height: 84px;
  background: #f4efe3;
  border-radius: 8px;
  border: 1px solid #d4ceb8;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .4);
  padding: 4px 5px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  transition: transform .15s, box-shadow .15s, opacity .15s;
  cursor: not-allowed;
  opacity: .5;
}

.hcard.red {
  color: var(--suit-red);
}

.hcard.black {
  color: var(--suit-black);
}

.hcard .hc-top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
}

.hcard .hc-rank {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.hcard .hc-suit-sm {
  font-size: 10px;
  margin-top: 1px;
}

.hcard .hc-center {
  font-size: 21px;
  align-self: center;
  line-height: 1;
}

.hcard .hc-bot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 8.5px;
  color: #64748b;
  font-weight: 700;
}

/* Playable & Burnable Hand Card States */
.hcard.can-play {
  opacity: 1;
  cursor: pointer;
  transform: translateY(-8px);
  box-shadow: 0 0 0 2px var(--ac), 0 8px 18px rgba(240, 185, 85, .35);
}

.hcard.can-play:hover {
  transform: translateY(-16px) scale(1.05);
  box-shadow: 0 0 0 3px var(--ac), 0 12px 24px rgba(240, 185, 85, .5);
}

.hcard.can-play::before {
  content: 'PASANG';
  position: absolute;
  top: -8px;
  right: 2px;
  background: var(--ac);
  color: #1b1305;
  font-size: 7.5px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: .3px;
}

.hcard.can-burn {
  opacity: 1;
  cursor: pointer;
  transform: translateY(-6px);
  box-shadow: 0 0 0 2px var(--err), 0 6px 14px rgba(255, 122, 138, .35);
}

.hcard.can-burn:hover {
  transform: translateY(-14px) scale(1.05);
  box-shadow: 0 0 0 3px var(--err), 0 10px 20px rgba(255, 122, 138, .5);
}

.hcard.can-burn::before {
  content: 'MATIKAN';
  position: absolute;
  top: -8px;
  right: 2px;
  background: var(--err);
  color: #fff;
  font-size: 7.5px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
}

/* ==================== 5. MODALS & POPUPS ==================== */
/* Game Result Modal (#gres) */
#gres {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 6, 12, .65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 50;
  padding: 1rem;
  overflow: auto;
}

#gres .box {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 480px;
  padding: 1.8rem;
  text-align: center;
}

#gres .box.win {
  border-color: rgba(255, 209, 102, .7);
  box-shadow: 0 0 0 1px rgba(255, 209, 102, .3), 0 18px 60px rgba(255, 209, 102, .25);
  animation: winpop .6s cubic-bezier(.2, 1.4, .4, 1);
}

#gres .box.win h2 {
  color: #ffd166;
  text-shadow: 0 0 24px rgba(255, 209, 102, .6);
  font-size: 1.6rem;
}

#gres .box.lose h2 {
  color: #b9c6de;
  font-size: 1.5rem;
}

.rrow {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem 0;
  border-top: 1px solid var(--line);
  text-align: left;
  font-size: .92rem;
}

.rrow .nm {
  flex: 1;
  min-width: 0;
}

.rrow .dead-cards-preview {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: .25rem;
}

.mini-dead-pill {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .4);
  border: 1px solid var(--line);
  font-size: 10px;
  font-weight: 700;
}

.mini-dead-pill.red {
  color: var(--err);
}

.mini-dead-pill.black {
  color: #e2e8f0;
}

/* Sound Settings Modal (#sov) */
#sov {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 6, 12, .62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 60;
  padding: 1rem;
}

#sov .sbox {
  width: 100%;
  max-width: 390px;
  padding: 1.5rem;
}

.srow {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin: .9rem 0;
}

.srow label {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 9rem;
  margin: 0;
  color: var(--tx);
  font-weight: 600;
}

.srow input[type=range] {
  flex: 1;
  padding: 0;
  accent-color: #f0b955;
}

.srow input[type=checkbox] {
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: #f0b955;
}

.srow output {
  width: 3rem;
  text-align: right;
  font-weight: 600;
  color: var(--ac);
}

/* Help Modal (#hov) */
#hov {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 6, 12, .65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 60;
  padding: 1rem;
}

#hov .hbox {
  width: 100%;
  max-width: 580px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: .92rem;
  color: var(--mut);
}

#hov h2 {
  color: var(--tx);
  font-size: 1.3rem;
}

#hov h3 {
  color: var(--ac);
  font-size: 1.05rem;
  margin-top: .4rem;
}

#hov p {
  margin: 0;
  line-height: 1.5;
}

#hov ul {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#hov li strong {
  color: var(--tx);
}

/* Connection Bar (#conn) */
#conn {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: calc(9px + env(safe-area-inset-top, 0px)) 14px 9px;
  font-weight: 600;
  font-size: 14px;
  transform: translateY(-110%);
  transition: transform .3s ease;
  pointer-events: none;
}

#conn.show {
  transform: none;
}

#conn .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: connsp .8s linear infinite;
}

#conn.warn {
  background: rgba(255, 209, 102, .95);
  color: #2a1f00;
}

#conn.good {
  background: rgba(66, 211, 146, .95);
  color: #06261a;
}

#conn.good .dot {
  animation: none;
  border-top-color: currentColor;
  background: currentColor;
}

/* Toast Floating Bar (#toast) */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.4rem + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  padding: .7rem 1.2rem;
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
  z-index: 90;
  max-width: 90vw;
  text-align: center;
  font-weight: 600;
  font-size: .92rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, .4);
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Animations */
@keyframes popIn {
  from { transform: scale(.75); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes winpop {
  from { opacity: 0; transform: scale(.6); }
}

@keyframes connsp {
  to { transform: rotate(360deg); }
}

/* Falling Cards Confetti (.cf) */
.cf {
  position: fixed;
  top: -60px;
  width: var(--w);
  height: calc(var(--w) * 1.45);
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, .85);
  z-index: 45;
  pointer-events: none;
  animation: cfall var(--t) linear var(--d) infinite;
}

@keyframes cfall {
  0% { transform: translate(0, 0) rotate(0); }
  100% { transform: translate(var(--x), calc(100vh + 120px)) rotate(var(--r)); }
}
