/* ============ Poker Night — felt & gold theme ============ */

:root {
  /* surfaces */
  --bg: #08130d;
  --felt: #0c2a1c;
  --felt-edge: #061009;
  --surface: #12211a;
  --surface-2: #1a2c23;
  --surface-3: #22392e;
  --border: #2c4638;
  --border-soft: #24382d;

  /* text */
  --text: #f3efe2;
  --muted: #9fb3a6;
  --dim: #6f847a;

  /* accents */
  --gold: #e7bd5c;
  --gold-deep: #c99f43;
  --gold-glow: rgba(231, 189, 92, 0.35);
  --win: #4ce08a;
  --loss: #ff6b6b;
  --info: #63b3ff;

  --tap: 48px;
  --radius: 16px;
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 10px 34px rgba(0, 0, 0, 0.5);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  padding: 0;
}
html {
  background-color: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  background-image: radial-gradient(120% 70% at 50% -10%, var(--felt) 0%, var(--felt-edge) 55%, var(--bg) 100%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  font-variant-numeric: tabular-nums;
  overscroll-behavior-y: contain;
  touch-action: manipulation;
}

/* subtle card-suit watermark on the table */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle at 12% 20%, var(--gold-glow) 0, transparent 22%),
    radial-gradient(circle at 88% 8%, rgba(99, 179, 255, 0.12) 0, transparent 20%);
  opacity: 0.5;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px 120px;
}

/* ---------- typography ---------- */

h1 {
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 1.7rem;
  letter-spacing: 0.01em;
  margin: 10px 0 2px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ic {
  width: 1.1em;
  height: 1.1em;
  flex: none;
  vertical-align: -0.15em;
}
h1 .ic {
  width: 26px;
  height: 26px;
  color: var(--gold);
  filter: drop-shadow(0 0 10px var(--gold-glow));
}
.banner .ic {
  width: 18px;
  height: 18px;
}
h2 {
  font-size: 0.8rem;
  font-weight: 700;
  margin: 26px 0 10px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
p {
  margin: 8px 0;
}
.muted {
  color: var(--muted);
}

/* ---------- sticky topbar / stats ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  padding: 12px 0 14px;
  background: linear-gradient(var(--bg) 62%, transparent);
}
.stat {
  flex: 1;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
}
.stat b {
  display: block;
  font-size: 1.02rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat b.gold {
  color: var(--gold);
}

/* ---------- cards ---------- */

.card {
  position: relative;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  margin: 11px 0;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-glow), transparent);
}
.card .row,
.card.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.pname {
  font-weight: 650;
  font-size: 1.12rem;
  letter-spacing: 0.01em;
}
.pmeta {
  color: var(--muted);
  font-size: 0.86rem;
}
.pnote {
  margin-top: 3px;
  color: var(--gold);
  font-size: 0.8rem;
  font-style: italic;
  display: flex;
  align-items: flex-start;
  gap: 5px;
  line-height: 1.35;
}
.pnote .ic {
  width: 12px;
  height: 12px;
  flex: none;
  margin-top: 3px;
  opacity: 0.8;
}
.roster-chips {
  margin-top: 8px;
}
.roster-chips .chip {
  min-height: 40px;
  padding: 0 12px 0 10px;
  gap: 4px;
  font-weight: 550;
  font-size: 0.9rem;
}
.roster-chips .chip .ic {
  width: 14px;
  height: 14px;
  color: var(--gold);
}
.net-win {
  color: var(--win);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.net-loss {
  color: var(--loss);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

/* ---------- player head (avatar + name) ---------- */

.phead {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  flex: 1;
}
.pinfo {
  min-width: 0;
}
.pinfo .pname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pname.sm {
  font-size: 1rem;
}
.avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 750;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}
.crown {
  display: inline-flex;
  margin-right: 6px;
  color: var(--gold);
}
.crown .ic {
  width: 17px;
  height: 17px;
  filter: drop-shadow(0 0 6px var(--gold-glow));
}
.card-actions {
  display: flex;
  gap: 6px;
  flex: none;
}
.card.winner {
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 1px var(--gold-glow), var(--shadow-card);
}

/* inline rename field */
input.rename {
  min-height: 38px;
  font-weight: 650;
  font-size: 1.06rem;
  padding: 0 10px;
}

/* ---------- head row + timer pill ---------- */

.head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.timer {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 5px 11px;
  font-variant-numeric: tabular-nums;
}
.timer .ic {
  width: 14px;
  height: 14px;
  color: var(--gold);
}

/* ---------- sub-bar (round for everyone) ---------- */

.subbar {
  margin: 2px 0 10px;
}
.subbar .ic {
  color: var(--gold);
}

/* ---------- results stat strip ---------- */

.statstrip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--muted);
  font-size: 0.84rem;
  margin: 4px 0 6px;
}
.statstrip span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.statstrip .ic {
  width: 13px;
  height: 13px;
  color: var(--gold);
}

/* ---------- card grid on wide screens ---------- */

@media (min-width: 620px) {
  #app {
    max-width: 760px;
  }
  .cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: start;
  }
  .cards .card {
    margin: 0;
  }
}

/* empty states */
.empty {
  padding: 22px 4px;
  text-align: center;
}

/* ---------- buttons ---------- */

button {
  position: relative;
  overflow: hidden;
  font: inherit;
  font-weight: 550;
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  color: var(--text);
  padding: 0 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s var(--ease-out), filter 0.15s, border-color 0.15s,
    box-shadow 0.15s;
  touch-action: manipulation;
}
button:active {
  transform: scale(0.955);
}
button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
button .ic {
  width: 18px;
  height: 18px;
}

button.primary {
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  border-color: var(--gold-deep);
  color: #241c07;
  font-weight: 700;
  box-shadow: 0 6px 18px var(--gold-glow);
}
button.primary:active {
  filter: brightness(0.95);
}
button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
button.danger {
  background: transparent;
  border-color: transparent;
  color: var(--loss);
}
button.wide {
  width: 100%;
}
button.sm {
  min-height: 44px;
  padding: 0 12px;
  font-size: 0.9rem;
  border-radius: 10px;
}
button.icon-only {
  min-height: 44px;
  min-width: 44px;
  padding: 0;
  border-radius: 10px;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.btn-row > button {
  flex: 1 1 auto;
}
.btn-row > button.icon-only {
  flex: 0 0 auto;
}
.btn-row > input {
  flex: 1 1 90px;
  width: auto;
  min-width: 0;
  min-height: 40px;
}

/* ripple */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.28;
  transform: scale(0);
  animation: ripple 0.6s var(--ease-out);
  pointer-events: none;
}
@keyframes ripple {
  to {
    transform: scale(2.4);
    opacity: 0;
  }
}

/* ---------- inputs ---------- */

input[type="text"],
input[type="number"],
input[type="search"],
input[type="date"],
input[type="email"],
input[type="password"],
input[type="tel"],
select {
  font: inherit;
  width: 100%;
  min-height: var(--tap);
  -webkit-appearance: none;
  appearance: none;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  padding: 0 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select {
  padding-right: 36px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23e7bd5c' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
input::placeholder {
  color: var(--dim);
}
input:focus,
select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
[hidden] {
  display: none !important;
}
label {
  display: block;
  margin: 14px 0 5px;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

/* ---------- buy-in chips (poker-chip look) ---------- */

.chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0;
}
.chip {
  min-height: 46px;
  border-radius: 999px;
  padding: 0 15px;
  font-weight: 650;
  color: var(--text);
  background: radial-gradient(circle at 50% 35%, var(--surface-3), var(--surface));
  border: 2px dashed var(--border);
  box-shadow: var(--shadow-card);
  transition: transform 0.14s var(--ease-out), border-color 0.15s, color 0.15s,
    background 0.15s;
}
.chip.on {
  color: #241c07;
  background: radial-gradient(circle at 50% 35%, var(--gold), var(--gold-deep));
  border-color: #f4dca0;
  border-style: solid;
  box-shadow: 0 6px 18px var(--gold-glow);
}

/* ---------- banners ---------- */

.banner {
  border-radius: 12px;
  padding: 13px 15px;
  margin: 13px 0;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid;
  display: flex;
  align-items: center;
  gap: 8px;
}
.banner.warn {
  background: rgba(231, 189, 92, 0.1);
  border-color: var(--gold-deep);
  color: var(--gold);
}
.banner.ok {
  background: rgba(76, 224, 138, 0.1);
  border-color: var(--win);
  color: var(--win);
}
.banner.info {
  background: rgba(99, 179, 255, 0.1);
  border-color: var(--info);
  color: var(--info);
}
.banner.ok.flash {
  animation: okflash 0.7s var(--ease-out);
}
@keyframes okflash {
  0% {
    box-shadow: 0 0 0 0 rgba(76, 224, 138, 0.5);
  }
  100% {
    box-shadow: 0 0 0 14px rgba(76, 224, 138, 0);
  }
}

/* ---------- settlement lines ---------- */

.settle-line {
  position: relative;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 12px;
  padding: 13px 15px;
  margin: 9px 0;
  font-size: 1.05rem;
  box-shadow: var(--shadow-card);
}
.settle-line b {
  color: var(--gold);
  font-weight: 700;
}
.settle-line.tappable {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.settle-line.tappable:active {
  transform: scale(0.99);
}
.settle-line .sl-check {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--dim);
}
.settle-line.done {
  opacity: 0.55;
  border-left-color: var(--win);
}
.settle-line.done .sl-check {
  color: var(--win);
}
.settle-line.done span {
  text-decoration: line-through;
  text-decoration-color: var(--dim);
}
.lb-row.tappable {
  cursor: pointer;
  border-radius: 10px;
  margin: 0 -6px;
  padding: 9px 6px;
}
.lb-row.tappable:active {
  background: var(--surface-2);
}

/* ---------- kitty / shared expense ---------- */

.kitty-card .row {
  margin-bottom: 4px;
}
.kitty-rows {
  margin-top: 10px;
  border-top: 1px solid var(--border-soft);
}
.kitty-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  font-size: 0.95rem;
}
.kitty-row input[type='checkbox'] {
  width: 18px;
  height: 18px;
  min-height: 0;
  flex: none;
  accent-color: var(--gold);
}
.kitty-row .kr-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kitty-row input.sm {
  flex: none;
  width: 96px;
  text-align: right;
}
.kitty-foot {
  margin-top: 10px;
}
.kitty-summary .kr-line {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.95rem;
}
.kitty-summary .kr-line:last-of-type {
  border-bottom: 0;
}
.kitty-summary .pmeta {
  margin-top: 6px;
}

/* ---------- segmented control ---------- */

.seg {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin: 10px 0 4px;
}
.seg-btn {
  flex: 1;
  min-height: 40px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 9px;
}
.seg-btn.on {
  background: rgba(231, 189, 92, 0.14);
  border-color: var(--gold-deep);
  color: var(--gold);
}

/* ---------- tournament ---------- */

.card.sub {
  margin-top: 0;
  background: rgba(0, 0, 0, 0.22);
}
.struct-row {
  margin-top: 6px;
}

.tclock-wrap {
  text-align: center;
  background: radial-gradient(120% 90% at 50% 0%, var(--surface-3), var(--surface));
  border: 1px solid var(--gold-deep);
  border-radius: var(--radius);
  padding: 20px 16px 16px;
  margin: 8px 0 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--gold-glow) inset;
}
.tclock-wrap.paused {
  border-color: var(--border);
  box-shadow: var(--shadow-card);
}
.tclock-wrap.brk {
  border-color: var(--info);
}
.tc-level {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}
.tc-blinds {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.tc-time {
  font-family: "Fraunces", Georgia, serif;
  font-size: 3.6rem;
  font-weight: 600;
  line-height: 1.05;
  margin: 6px 0 10px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.tclock-wrap.paused .tc-time {
  color: var(--muted);
}
.tc-ctrls {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.tc-ctrls .sm.primary {
  min-width: 120px;
}
.tc-next {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.card.tp-out {
  opacity: 0.6;
}
.card.tp-out .btn-row {
  margin-top: 8px;
}

.struct-lv .row {
  margin-bottom: 6px;
}
.struct-lv.brk {
  border-left: 3px solid var(--info);
}
.lv-fields {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: end;
}
.lv-fields > span {
  display: flex;
  flex-direction: column;
}
.lv-fields label {
  margin: 0 0 3px;
  font-size: 0.68rem;
}
.lv-fields input {
  min-height: 38px;
}

/* ---------- bottom action bar ---------- */

.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(8, 19, 13, 0.4), var(--surface) 55%);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.actionbar > button {
  flex: 1;
}
.actionbar > button.primary {
  flex: 1.6;
}

/* ---------- history ---------- */

.lb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.lb-row .rank {
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  width: 1.4em;
  flex: none;
  text-align: center;
}
.lb-row:first-of-type .rank {
  color: var(--gold);
}
.hist-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(8px);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 999px;
  z-index: 50;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-pop);
  animation: toastin 0.22s var(--ease-out) forwards, toastout 0.25s var(--ease-in) 1.5s forwards;
}
@keyframes toastin {
  to {
    transform: translateX(-50%) translateY(0);
  }
}
@keyframes toastout {
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
}

/* ---------- floating +amount ---------- */

.floatup {
  position: fixed;
  z-index: 60;
  transform: translate(-50%, -50%);
  color: var(--gold);
  font-weight: 800;
  font-size: 1.1rem;
  text-shadow: 0 2px 10px var(--gold-glow);
  pointer-events: none;
  animation: floatup 0.9s var(--ease-out) forwards;
}
@keyframes floatup {
  0% {
    opacity: 0;
    transform: translate(-50%, -20%) scale(0.8);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -180%) scale(1);
  }
}

/* ---------- number pop ---------- */

.pop {
  animation: pop 0.4s var(--ease-out);
}
@keyframes pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.16);
    color: var(--gold);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- confetti ---------- */

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  overflow: hidden;
}
.confetti span {
  position: absolute;
  top: -8vh;
  font-size: 1.4rem;
  color: var(--gold);
  animation: fall linear forwards;
}
.confetti span.red {
  color: var(--loss);
}
@keyframes fall {
  to {
    transform: translateY(112vh) translateX(var(--drift, 0)) rotate(var(--rot, 180deg));
    opacity: 0;
  }
}

/* ---------- currency field + picker sheet ---------- */

.field-btn {
  justify-content: flex-start;
  gap: 10px;
  padding: 0 14px;
  font-weight: 550;
}
.field-btn .ic {
  margin-left: auto;
  color: var(--muted);
}
.cur-sym {
  flex: none;
  min-width: 1.4em;
  text-align: center;
  color: var(--gold);
  font-weight: 700;
}
.cur-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cur-code {
  flex: none;
  color: var(--dim);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 10, 7, 0.6);
  backdrop-filter: blur(3px);
  animation: fadein 0.2s var(--ease-out);
}
.sheet {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-pop);
  animation: sheetup 0.26s var(--ease-out);
}
.sheet-wrap.closing .sheet {
  animation: sheetdown 0.2s var(--ease-in) forwards;
}
.sheet-wrap.closing .sheet-backdrop {
  animation: fadeout 0.2s var(--ease-in) forwards;
}
@keyframes sheetup {
  from {
    transform: translateY(100%);
  }
}
@keyframes sheetdown {
  to {
    transform: translateY(100%);
  }
}
@keyframes fadein {
  from {
    opacity: 0;
  }
}
@keyframes fadeout {
  to {
    opacity: 0;
  }
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sheet-head b {
  font-size: 1.05rem;
}
.sheet-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  margin: 0 -6px;
  padding: 0 6px;
}
.currency-row {
  width: 100%;
  justify-content: flex-start;
  gap: 12px;
  min-height: 48px;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  border-radius: 0;
  background: transparent;
  padding: 0 6px;
  text-align: left;
}
.currency-row:active {
  background: var(--surface-2);
}
.currency-row.on {
  color: var(--gold);
}
.currency-row.on .cur-code {
  color: var(--gold-deep);
}
.currency-row .cur-name {
  flex: 1;
}

/* ============ study tools ============ */

/* tool header (back-chevron + title) */
.tool-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 2px;
}
.tool-head h1 {
  margin: 0;
}
.hr-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* home hub */
.cta {
  text-align: left;
}
.cta .pname {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.25rem;
  margin-bottom: 2px;
}
.cta button {
  margin-top: 14px;
}
.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 4px 0 14px;
}
.tool-tile {
  min-height: 96px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 14px;
  text-align: left;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px;
}
.tool-tile .tt-ic {
  color: var(--gold);
  margin-bottom: 4px;
}
.tool-tile .tt-ic .ic {
  width: 22px;
  height: 22px;
}
.tool-tile .tt-name {
  font-weight: 700;
  font-size: 0.98rem;
}
.tool-tile .tt-desc {
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.3;
}

/* generic field layout inside tool cards */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.field-grid.two {
  grid-template-columns: 1fr 1fr;
}
.field-grid > div {
  min-width: 0;
}
.field-grid label {
  margin-top: 0;
}
label.check {
  display: flex;
  align-items: center;
  gap: 9px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9rem;
  color: var(--muted);
  margin: 14px 0 0;
}
label.check input {
  width: 18px;
  height: 18px;
  min-height: 0;
  flex: none;
  accent-color: var(--gold);
}
.card-pick {
  display: flex;
  gap: 6px;
}
.card-pick select {
  padding: 0 8px;
  background-position: right 8px center;
  padding-right: 24px;
}
.board-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* notes / bullet lists */
.notes {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.note {
  display: flex;
  gap: 9px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
}
.note:last-child {
  border-bottom: 0;
}
.note b {
  color: var(--text);
  flex: none;
  min-width: 62px;
}

/* big single result (BB calc, equity %) */
.big-result {
  margin-top: 14px;
  padding: 18px;
  border-radius: 14px;
  background: rgba(231, 189, 92, 0.09);
  border: 1px solid var(--gold-deep);
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.big-result.empty {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border-color: var(--border);
}
.big-result.t-win {
  color: var(--win);
  border-color: var(--win);
  background: rgba(76, 224, 138, 0.1);
}
.big-result.t-loss {
  color: var(--loss);
  border-color: var(--loss);
  background: rgba(255, 107, 107, 0.1);
}

/* range grid */
.range-grid {
  border-collapse: collapse;
  font-size: 10px;
  margin: 8px auto 0;
  font-variant-numeric: tabular-nums;
}
.range-grid th,
.range-grid td {
  width: 30px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  text-align: center;
  padding: 0;
  user-select: none;
}
.range-grid th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-weight: 700;
}
.rg-fold {
  background: rgba(0, 0, 0, 0.25);
  color: var(--dim);
}
.rg-open {
  background: rgba(231, 189, 92, 0.85);
  color: #241c07;
  font-weight: 700;
}
.rg-mix {
  background: rgba(76, 224, 138, 0.28);
  color: #bff3d3;
  font-weight: 600;
}
.rg-call {
  background: rgba(99, 179, 255, 0.28);
  color: #cfe6ff;
  font-weight: 600;
}
.range-grid.editable td.rg {
  cursor: pointer;
}
.legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--muted);
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend .sw {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.sw-open {
  background: var(--gold);
}
.sw-mix {
  background: rgba(76, 224, 138, 0.5);
}
.sw-call {
  background: rgba(99, 179, 255, 0.55);
}
.sw-fold {
  background: rgba(255, 255, 255, 0.12);
}

/* action result line */
.result-line {
  margin-top: 14px;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}
.rl-raise {
  background: rgba(76, 224, 138, 0.14);
  border-color: var(--win);
  color: #bff3d3;
}
.rl-mix {
  background: rgba(231, 189, 92, 0.12);
  border-color: var(--gold-deep);
  color: var(--gold);
}
.rl-call {
  background: rgba(99, 179, 255, 0.14);
  border-color: var(--info);
  color: #b9dbff;
}
.rl-fold,
.rl-error {
  background: rgba(255, 107, 107, 0.1);
  border-color: var(--loss);
  color: #ffc2c2;
}

/* hand preview */
.hand-big {
  font-size: 2.4rem;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.hand-box {
  margin-top: 12px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  text-align: center;
}
.hand-box .hand-big {
  font-size: 1.5rem;
}

/* stat boxes (odds, equity, sessions totals) */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.stat-box {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px;
  text-align: center;
}
.stat-box .sb-val {
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.stat-box .sb-lbl {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 3px;
}
.stat-box.t-win .sb-val {
  color: var(--win);
}
.stat-box.t-loss .sb-val {
  color: var(--loss);
}
.stat-box.t-gold .sb-val {
  color: var(--gold);
}
.banner.loss {
  background: rgba(255, 107, 107, 0.1);
  border-color: var(--loss);
  color: #ffc2c2;
}

/* SPR */
.spr-num {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--gold);
  text-align: center;
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
}
.spr-guide {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 6px 12px;
  margin-top: 14px;
  font-size: 0.86rem;
  color: var(--muted);
}
.spr-guide b {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* reference / player-type tables */
.ref-table,
.sess-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.ref-table th,
.sess-table th {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 9px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.ref-table td,
.sess-table td {
  padding: 9px 9px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--muted);
  vertical-align: top;
  line-height: 1.5;
}
.ref-table tr:last-child td,
.sess-table tr:last-child td {
  border-bottom: 0;
}
.rt-key {
  color: var(--gold);
  font-weight: 700;
  white-space: nowrap;
}
.ptype-stats {
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 600;
}
.adjust-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  margin: 1px;
}
.adjust-tag.t-win {
  background: rgba(76, 224, 138, 0.15);
  color: #9ff0c1;
}
.adjust-tag.t-red {
  background: rgba(255, 107, 107, 0.12);
  color: #ffb3b3;
}
.adjust-tag.t-blue {
  background: rgba(99, 179, 255, 0.15);
  color: #b9dbff;
}
.adjust-tag.t-gold {
  background: rgba(231, 189, 92, 0.14);
  color: #f2d69a;
}

/* quiz */
.quiz-card {
  text-align: center;
}
.quiz-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 0;
}
.quiz-ans {
  font-weight: 700;
  border: 1px solid var(--border);
}
.qa-open {
  border-color: rgba(76, 224, 138, 0.4);
  color: var(--win);
}
.qa-fold {
  border-color: rgba(255, 107, 107, 0.4);
  color: var(--loss);
}
.quiz-fb {
  margin-top: 12px;
  padding: 12px;
  border-radius: 11px;
  font-weight: 700;
  font-size: 0.92rem;
}
.fb-ok {
  background: rgba(76, 224, 138, 0.15);
  color: #9ff0c1;
}
.fb-bad {
  background: rgba(255, 107, 107, 0.12);
  color: #ffb3b3;
}
.fb-mix {
  background: rgba(231, 189, 92, 0.13);
  color: var(--gold);
}
.score-big {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--gold);
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.score-row {
  display: flex;
  justify-content: space-around;
  margin-top: 14px;
  text-align: center;
}
.score-row b {
  display: block;
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}
.score-row span {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.streak {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(231, 189, 92, 0.1);
  border: 1px solid var(--gold-deep);
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 700;
}
.center {
  text-align: center;
}

/* equity bar */
.eq-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  margin: 10px 0 4px;
}
.eq-bar i {
  height: 100%;
  background: var(--win);
}
.eq-bar i.tie {
  background: var(--dim);
}
.eq-bar i.vil {
  background: var(--loss);
}

/* inner tabs (study) */
.inner-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.inner-tab {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
}
.inner-tab.on {
  background: rgba(231, 189, 92, 0.14);
  border-color: var(--gold-deep);
  color: var(--gold);
}
.concept-item {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px;
  margin-bottom: 10px;
}
.concept-item:last-child {
  margin-bottom: 0;
}
.concept-hd {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 4px;
}

/* charts */
.chart-lbl {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 10px 0 6px;
}
canvas.chart {
  display: block;
  width: 100%;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
}

/* ---------- view transitions ---------- */

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.28s;
}

/* ---------- installed / standalone ---------- */

@media (display-mode: standalone) {
  #app {
    padding-top: 6px;
  }
}

/* ---------- landscape phones ---------- */

@media (orientation: landscape) and (max-height: 460px) {
  #app {
    padding-bottom: 88px;
  }
  h1 {
    font-size: 1.35rem;
    margin: 4px 0;
  }
  h2 {
    margin: 14px 0 8px;
  }
  .topbar {
    padding: 8px 0 10px;
  }
}

/* ---------- account + sync ---------- */

.home-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.home-head h1 {
  margin: 0;
}
.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}
.sync-pill .sp-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.sp-synced {
  color: var(--win);
}
.sp-syncing {
  color: var(--gold);
}
.sp-offline {
  color: var(--muted);
}
.sp-error {
  color: var(--loss);
}
.account-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.account-body label {
  margin-top: 4px;
}

/* ---------- plan / upsell ---------- */

.plan-badge {
  flex: none;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.plan-badge.pro {
  color: #0b1f16;
  background: var(--gold);
  border-color: var(--gold);
}
.pro-card {
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 1px var(--gold-glow);
}
.pro-list {
  margin: 8px 0;
  padding-left: 20px;
}
.pro-list li {
  margin: 5px 0;
  color: var(--text);
}
.cap-notice {
  font-size: 0.86rem;
}
.code-fallback {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.code-fallback summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}
.code-fallback[open] summary {
  margin-bottom: 8px;
}
.code-fallback input {
  margin-bottom: 8px;
}

/* ---------- live table ---------- */

.live-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--gold-deep);
  border-radius: 12px;
  padding: 8px 10px;
  margin: 6px 0 10px;
  font-size: 0.88rem;
}
.live-bar > span {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
.live-bar > span b {
  color: var(--gold);
  letter-spacing: 0.12em;
  font-size: 0.95rem;
}
.live-bar .ic {
  width: 16px;
  height: 16px;
}
.live-bar button {
  flex: none;
  padding: 5px 9px;
}
.live-start {
  margin: 6px 0 10px;
}
.join-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 2rem;
  letter-spacing: 0.28em;
  color: var(--gold);
  text-align: center;
  padding: 8px 0 4px;
}

/* ---------- install banner ---------- */

.install-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--gold-deep);
  box-shadow: 0 0 0 1px var(--gold-glow);
  border-radius: 14px;
  padding: 10px 10px 10px 12px;
  margin: 4px 0 14px;
  animation: fadein 0.3s var(--ease-out);
}
.install-banner .ib-ic {
  flex: none;
  color: var(--gold);
  display: grid;
  place-items: center;
}
.install-banner .ib-ic .ic {
  width: 22px;
  height: 22px;
}
.ib-text {
  flex: 1;
  min-width: 0;
}
.ib-title {
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.25;
}
.ib-sub {
  color: var(--muted);
  font-size: 0.78rem;
}
.install-banner .ib-cta {
  flex: none;
  padding: 6px 11px;
  font-size: 0.85rem;
}
.install-banner .ib-x {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.install-banner .ib-x .ic {
  width: 16px;
  height: 16px;
}
.ios-steps {
  margin: 4px 0;
  padding-left: 22px;
  line-height: 1.7;
}
.ios-steps li {
  margin: 8px 0;
}
.ios-share-glyph {
  display: inline-grid;
  place-items: center;
  vertical-align: -5px;
  color: var(--gold);
}
.ios-share-glyph .ic {
  width: 18px;
  height: 18px;
}

/* ---------- sound toggle ---------- */

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  cursor: pointer;
}
.switch-row .pname.sm {
  display: flex;
  align-items: center;
  gap: 8px;
}
input.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  position: relative;
  transition: background 0.18s var(--ease-out);
  cursor: pointer;
}
input.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.18s var(--ease-out);
}
input.switch:checked {
  background: var(--gold-deep);
}
input.switch:checked::after {
  transform: translateX(18px);
  background: #0b1f16;
}
input.switch:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- share image + QR sheets ---------- */

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.share-img-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.share-img {
  width: 100%;
  max-width: 420px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--felt-edge);
}
.qr-box {
  width: 100%;
  max-width: 320px;
  margin: 4px auto 0;
  padding: 14px;
  background: #fff;
  border-radius: 16px;
}
.qr-box svg {
  display: block;
  width: 100%;
  height: auto;
}
.qr-url {
  word-break: break-all;
  text-align: center;
  margin: 4px 0 0;
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}
