:root {
  --bg: #1b2030;
  --bg-2: #232a3d;
  --panel: #2a3247;
  --panel-2: #323b54;
  --line: #3a4560;
  --text: #e8ecf6;
  --muted: #8f9ab5;
  --blue: #2f7bff;
  --blue-dark: #1747a8;
  --purple: #8b3dff;
  --purple-dark: #4d1a9e;
  --red: #ff2d55;
  --red-dark: #a3122f;
  --green: #2bd67b;
  --radius: 12px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, a, input, label { -webkit-tap-highlight-color: transparent; }
button, .btn, .side-btn, .bet-btn { touch-action: manipulation; }   /* no double-tap zoom delay */

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Rubik', system-ui, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.logo {
  font-family: 'Russo One', 'Rubik', sans-serif;
  font-size: 26px;
  letter-spacing: .5px;
  background: linear-gradient(90deg, var(--red), var(--purple) 50%, var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-decoration: none !important;
}

/* ---------- poker chip ---------- */
.chip {
  --c: var(--blue);
  --d: var(--blue-dark);
  width: 84px;
  height: 84px;
  flex: none;
  border-radius: 50%;
  position: relative;
  background: repeating-conic-gradient(var(--c) 0 30deg, #f4f6fb 30deg 45deg);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .35), inset 0 0 0 3px rgba(0, 0, 0, .15);
}
.chip::before {
  content: '';
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--c), var(--d));
  border: 3px dashed rgba(255, 255, 255, .55);
}
.chip::after {
  content: '';
  position: absolute;
  inset: 30px;
  background: rgba(255, 255, 255, .9);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}
.chip.red { --c: var(--red); --d: var(--red-dark); }
.chip.blue::after { clip-path: polygon(25% 7%, 75% 7%, 100% 50%, 75% 93%, 25% 93%, 0 50%); }
.chip.purple { --c: var(--purple); --d: var(--purple-dark); box-shadow: 0 0 22px rgba(139, 61, 255, .7), 0 6px 14px rgba(0,0,0,.35); }
.chip.purple::after { clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); inset: 26px; }

.chip.sm { width: 26px; height: 26px; box-shadow: 0 2px 4px rgba(0,0,0,.3); }
.chip.sm::before { inset: 4px; border-width: 1px; }
.chip.sm::after { inset: 9px; }

/* ---------- forms / auth ---------- */
.auth-page {
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(600px 400px at 15% 20%, rgba(47, 123, 255, .18), transparent 70%),
    radial-gradient(600px 400px at 85% 80%, rgba(255, 45, 85, .15), transparent 70%),
    radial-gradient(500px 300px at 50% 50%, rgba(139, 61, 255, .12), transparent 70%),
    var(--bg);
}

/* decorative layer: clipped so the chips never widen the page on phones */
.floating-chips { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.floating-chips .chip {
  position: absolute;
  opacity: .25;
  filter: blur(1px);
  animation: float 9s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-24px) rotate(40deg); }
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  background: rgba(42, 50, 71, .92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.auth-card .logo { display: block; text-align: center; font-size: 34px; margin-bottom: 6px; }
.auth-card h1 { font-size: 20px; text-align: center; margin: 0 0 4px; font-weight: 600; }
.auth-card .sub { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.chip-row { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.input-wrap { position: relative; }
.field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 123, 255, .25); }
.toggle-pw {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; font-size: 12px; padding: 6px;
}
.toggle-pw:hover { color: var(--text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px;
  border: 0; border-radius: 10px;
  font: inherit; font-weight: 700; font-size: 15px;
  color: #fff; cursor: pointer;
  background: var(--blue);
  transition: transform .08s, filter .15s, opacity .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.block { width: 100%; margin-top: 6px; }
.btn.gradient { background: linear-gradient(90deg, var(--blue), var(--purple)); }
.btn.ghost { background: var(--panel-2); color: var(--text); font-weight: 500; }

.row-between { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin: -4px 0 12px; }
.switch { text-align: center; color: var(--muted); font-size: 14px; margin-top: 18px; }

.msg { font-size: 14px; padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; display: none; }
.msg.show { display: block; }
.msg.error { background: rgba(255, 45, 85, .12); border: 1px solid rgba(255, 45, 85, .4); color: #ff8aa1; }
.msg.success { background: rgba(43, 214, 123, .12); border: 1px solid rgba(43, 214, 123, .4); color: #7ff0b2; }

.inbox {
  background: var(--bg-2);
  border: 1px dashed var(--purple);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--muted);
}
.inbox strong { color: var(--text); }
.inbox .code { font-family: 'Russo One', monospace; font-size: 26px; letter-spacing: 6px; color: #fff; margin: 6px 0 2px; }

.hidden { display: none !important; }

/* ---------- game layout ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.nav { display: flex; gap: 6px; flex: 1; }
.nav a {
  color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 14px;
  padding: 8px 14px; border-radius: 8px; letter-spacing: .5px;
}
.nav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.nav a.active { color: var(--blue); background: rgba(47, 123, 255, .1); }

.wallet {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 6px 6px 6px 14px; border-radius: 10px; font-weight: 700;
}
.wallet .label { color: var(--muted); font-weight: 500; font-size: 13px; }
.wallet .amount { color: var(--green); font-size: 16px; min-width: 70px; text-align: right; transition: color .3s; }
.wallet .amount.flash-up { color: #9dffcb; }
.wallet .amount.flash-down { color: var(--red); }
.coin {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; margin-right: 4px;
  background: radial-gradient(circle at 35% 30%, #ffe680, #e0a800);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .15);
}

.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  padding: 4px 8px; border-radius: 8px;
}
.user-btn:hover, .user-btn.open { background: var(--panel); }
.user-btn .caret { color: var(--muted); font-size: 12px; transition: transform .15s; }
.user-btn.open .caret { transform: rotate(180deg); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff;
}
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  width: 220px; max-width: calc(100vw - 24px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px; box-shadow: 0 14px 40px rgba(0, 0, 0, .45);
  transform-origin: top right; animation: menu-in .14s ease-out;
}
.dropdown.closing { animation: menu-out .12s ease-in forwards; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
@keyframes menu-out { to { opacity: 0; transform: translateY(-6px) scale(.97); } }
.dropdown-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.dropdown-who { min-width: 0; }
.dropdown-name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.dropdown-sep { height: 1px; background: var(--line); margin: 4px 0; }
/* links and buttons in the menu look identical */
.dropdown a, .dropdown button {
  display: flex; align-items: center; box-sizing: border-box; width: 100%; text-align: left;
  background: none; border: 0; color: var(--text); text-decoration: none;
  font: inherit; font-size: 15px; font-weight: 500; line-height: 1.4;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
}
.dropdown a:hover, .dropdown button:hover, .dropdown a:focus-visible, .dropdown button:focus-visible { background: var(--panel-2); text-decoration: none; outline: none; }
.dropdown a[aria-current="page"] { color: var(--blue); background: rgba(47, 123, 255, .1); }
.dropdown a[aria-current="page"]::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--blue); margin-left: auto; }
.dropdown button.danger { color: #ff8aa1; }
.dropdown button.danger:hover { background: rgba(255, 45, 85, .12); }

main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }

.wheel-wrap {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 0;
  overflow: hidden;
}
.wheel-wrap::before, .wheel-wrap::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 120px; z-index: 2; pointer-events: none;
}
.wheel-wrap::before { left: 0; background: linear-gradient(90deg, var(--bg-2), transparent); }
.wheel-wrap::after { right: 0; background: linear-gradient(-90deg, var(--bg-2), transparent); }
.strip { display: flex; gap: 16px; will-change: transform; }
.strip .chip.win { animation: pop .6s ease-out; outline: 4px solid #fff; outline-offset: 4px; }
@keyframes pop { 50% { transform: scale(1.15); } }
.marker {
  position: absolute; left: 50%; top: 6px; bottom: 6px; width: 4px; margin-left: -2px;
  background: #fff; border-radius: 4px; z-index: 3;
  box-shadow: 0 0 12px rgba(255, 255, 255, .8);
}
.marker::before, .marker::after {
  content: ''; position: absolute; left: 50%; margin-left: -8px;
  border: 8px solid transparent;
}
.marker::before { top: -6px; border-top-color: #fff; }
.marker::after { bottom: -6px; border-bottom-color: #fff; }

.countdown {
  position: absolute; inset: 0; z-index: 4;
  display: grid; place-items: center; pointer-events: none;
}
.countdown span {
  background: rgba(27, 32, 48, .88); border: 1px solid var(--line);
  padding: 10px 22px; border-radius: 999px; font-weight: 700; font-size: 18px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.countdown .bar {
  position: absolute; left: 0; bottom: 0; height: 4px;
  background: linear-gradient(90deg, var(--blue), var(--purple), var(--red));
}

.history { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 4px 22px; }
.history .label { color: var(--muted); font-size: 13px; white-space: nowrap; }
.history-chips { display: flex; justify-content: flex-end; gap: 6px; min-height: 26px; overflow: hidden; }
.history-chips .chip.new { animation: roll-in .45s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes roll-in { from { transform: translateX(28px) scale(.4); opacity: 0; } }

.controls {
  display: flex; gap: 8px; max-width: 720px; margin: 0 auto 22px; flex-wrap: wrap;
}
.amount-box {
  flex: 1 1 220px; display: flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px;
}
.amount-box input {
  flex: 1; background: none; border: 0; color: var(--text); font: inherit; font-size: 16px; font-weight: 600;
  padding: 12px 0; outline: none; min-width: 0;
}
.amount-box:focus-within { border-color: var(--blue); }
.controls .btn.ghost { padding: 10px 14px; font-size: 14px; }

.columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.col { min-width: 0; }
.bet-btn {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border: 0; border-radius: 10px; cursor: pointer;
  font: inherit; font-weight: 700; color: #fff; font-size: 15px;
  transition: transform .08s, filter .15s;
}
.bet-btn:hover { filter: brightness(1.15); }
.bet-btn:active { transform: translateY(1px); }
.bet-btn:disabled { filter: grayscale(.6) brightness(.7); cursor: not-allowed; }
.bet-btn .left { display: flex; align-items: center; gap: 10px; }
.bet-btn .mult { font-size: 13px; opacity: .9; }
.bet-btn.blue { background: linear-gradient(90deg, var(--blue-dark), var(--blue)); }
.bet-btn.purple { background: linear-gradient(90deg, var(--purple-dark), var(--purple)); }
.bet-btn.red { background: linear-gradient(90deg, var(--red-dark), var(--red)); }

.col-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin: 10px 4px 8px; }
.col-meta b { color: var(--text); }
.bet-list {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  min-height: 220px; max-height: 320px; overflow-y: auto; padding: 6px;
  transition: opacity .3s, box-shadow .3s;
}
.bet-list.lost { opacity: .4; }
.bet-list.won { box-shadow: 0 0 0 2px var(--green), 0 0 24px rgba(43, 214, 123, .3); }
.bet-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; font-size: 14px;
}
.bet-row.me { background: rgba(47, 123, 255, .14); }
.bet-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bet-row .amt { font-weight: 700; }
.bet-list.won .amt { color: var(--green); }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 13px; }
.chance { text-align: center; color: var(--muted); font-size: 12px; margin-top: 8px; }

/* ---------- coinflip page ---------- */
.muted { color: var(--muted); font-size: 13px; }
.btn.small { padding: 8px 14px; font-size: 13px; }
.btn.join { background: var(--green); color: #0d2a1a; }

.cf-create {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
}
.cf-create .amount-box { flex: 1 1 180px; }
.cf-create .btn.ghost { padding: 10px 14px; font-size: 14px; }
.side-pick { display: flex; gap: 6px; padding: 0 4px; }
.side-btn {
  width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
  background: var(--bg-2); border: 2px solid var(--line); cursor: pointer; transition: border-color .15s, transform .1s;
}
.side-btn .chip.sm { width: 30px; height: 30px; }
.side-btn:hover { transform: translateY(-1px); }
.side-btn.selected[data-side="red"] { border-color: var(--red); box-shadow: 0 0 14px rgba(255, 45, 85, .4); }
.side-btn.selected[data-side="blue"] { border-color: var(--blue); box-shadow: 0 0 14px rgba(47, 123, 255, .4); }
.badge { background: var(--blue); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; }

.cf-stats { display: flex; gap: 22px; color: var(--muted); font-size: 13px; margin: 14px 4px; flex-wrap: wrap; }
.cf-stats b { color: var(--text); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 6px; box-shadow: 0 0 8px var(--green); }

.cf-list { display: flex; flex-direction: column; gap: 8px; }
.cf-empty { background: var(--panel); border: 1px dashed var(--line); border-radius: 14px; }
.cf-row {
  display: grid; grid-template-columns: minmax(260px, 1.4fr) 1fr 140px auto; gap: 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px;
}
.cf-row.mine { border-color: rgba(47, 123, 255, .5); }
.cf-row.flipping { border-color: var(--purple); box-shadow: 0 0 18px rgba(139, 61, 255, .25); }
.cf-row.done { opacity: .6; }
.cf-players { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cf-player { display: flex; align-items: center; gap: 8px; position: relative; min-width: 0; flex: 1; }
.cf-player .avatar { width: 38px; height: 38px; }
.cf-player .side-badge { position: absolute; left: 24px; top: 22px; width: 18px; height: 18px; }
.cf-player .side-badge::before { inset: 3px; }
.cf-player .side-badge::after { inset: 6px; }
.cf-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 4px; }
.avatar.empty { background: var(--bg-2); border: 2px dashed var(--line); color: var(--muted); padding: 0; }
.vs { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.cf-items { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.item-tile {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #fff; overflow: hidden; flex: none;
}
.item-tile img { width: 100%; height: 100%; object-fit: contain; }
.cf-value b { color: var(--green); font-size: 16px; }
.cf-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.cf-live { color: #c9a6ff; font-weight: 700; font-size: 14px; }
.cf-result { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }

/* modals */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(10, 13, 22, .7); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 16px;
}
.modal {
  position: relative; width: 100%; max-width: 620px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5); animation: slidein .2s ease-out;
}
.modal h2 { margin: 0 0 6px; font-size: 20px; }
.modal-sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 8px;
  background: var(--panel-2); border: 0; color: var(--muted); cursor: pointer; font-size: 14px;
}
.modal-close:hover { color: var(--text); }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; color: var(--muted); font-size: 14px; }

.flip-stage { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; margin: 22px 0 10px; }
.flip-player {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 18px 10px; min-width: 0;
  transition: border-color .3s, opacity .3s, box-shadow .3s;
}
.flip-player .avatar.big { width: 56px; height: 56px; font-size: 22px; }
.flip-player .name { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.flip-player .val { color: var(--green); font-weight: 700; }
.flip-player.winner { border-color: var(--green); box-shadow: 0 0 24px rgba(43, 214, 123, .3); }
.flip-player.loser { opacity: .45; }
.flip-center { display: flex; flex-direction: column; align-items: center; gap: 14px; perspective: 800px; }
.flip-coin { width: 130px; height: 130px; position: relative; transform-style: preserve-3d; }
.flip-coin.idle { animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { translate: 0 -8px; } }
.flip-coin .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flip-coin .face.back { transform: rotateY(180deg); }
.flip-coin .chip { display: block; width: 130px; height: 130px; }
.flip-coin .chip::before { inset: 16px; border-width: 4px; }
.flip-coin .chip::after { inset: 46px; }
.flip-status { min-height: 22px; font-weight: 600; text-align: center; }
.flip-status b { color: var(--green); }
.flip-pot { text-align: center; color: var(--muted); }
.flip-pot b { color: var(--text); font-size: 18px; }

.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.item-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px;
  background: var(--bg-2); border: 2px solid var(--line); border-radius: 12px; cursor: pointer;
  color: var(--text); font: inherit;
}
.item-card .item-tile { width: 56px; height: 56px; font-size: 20px; }
.item-card .name { font-size: 13px; font-weight: 600; }
.item-card .val { font-size: 13px; color: var(--green); }
.item-card.selected { border-color: var(--blue); box-shadow: 0 0 14px rgba(47, 123, 255, .35); }
.item-empty { grid-column: 1 / -1; line-height: 1.7; border: 1px dashed var(--line); border-radius: 12px; }

/* ---------- leaderboard page ---------- */
.page-head { margin: 0 0 22px; }
.page-head h1 { font-family: 'Russo One', 'Rubik', sans-serif; font-weight: 400; font-size: 28px; margin: 0 0 4px; }
.page-head p { color: var(--muted); margin: 0; font-size: 14px; }

.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 14px; align-items: end; margin-bottom: 22px; }
.podium-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px 14px; text-align: center; position: relative; min-width: 0;
}
.podium-card .avatar { width: 52px; height: 52px; font-size: 20px; margin: 0 auto 10px; }
.podium-card .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-card .bal { color: var(--green); font-weight: 700; margin-top: 6px; }
.podium-card .place {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #1b2030;
}
.podium-card.p1 { padding: 30px 14px; border-color: #e0b400; box-shadow: 0 0 30px rgba(224, 180, 0, .18); }
.podium-card.p1 .place { background: #ffd23f; }
.podium-card.p2 .place { background: #cfd6e4; }
.podium-card.p3 .place { background: #e0975a; }
.podium-card.me .name { color: var(--blue); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px 20px; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); font-size: 15px; }
.lb-row:last-child { border-bottom: 0; }
.lb-row .rank { width: 34px; color: var(--muted); font-weight: 700; }
.lb-row .name { flex: 1; min-width: 0; display: flex; align-items: center; }
.lb-row .name .n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .bal { font-weight: 700; }
.lb-row.me { background: rgba(47, 123, 255, .1); border-radius: 8px; }
.lb-row.me .name { color: var(--blue); font-weight: 700; }
.lb-row .you { flex: none; font-size: 11px; background: var(--blue); color: #fff; padding: 2px 6px; border-radius: 6px; margin-left: 6px; }

.refill {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: -8px auto 20px; color: var(--muted); font-size: 14px;
}

.toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 50; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--blue);
  padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.4);
  font-weight: 600; animation: slidein .25s ease-out; max-width: 320px;
}
.toast.win { border-left-color: var(--green); }
.toast.loss, .toast.error { border-left-color: var(--red); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }

/* ---------- tablets ---------- */
@media (max-width: 1024px) {
  .topbar { gap: 14px; padding: 12px 20px; }
  .nav a { padding: 8px 10px; }
  .user-btn .uname { display: none; }
  .cf-row { grid-template-columns: minmax(220px, 1.4fr) 1fr auto; }
  .cf-row .cf-items { display: none; }
}

/* ---------- phones and small tablets ---------- */
@media (max-width: 760px) {
  /* top bar: logo, wallet and avatar on one row, nav as an even row below */
  .topbar {
    flex-wrap: wrap; gap: 8px 10px;
    padding: 10px max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
    padding-top: max(10px, env(safe-area-inset-top));
  }
  .logo { font-size: 22px; }
  .wallet { margin-left: auto; padding: 5px 10px; }
  .wallet .label { display: none; }
  .wallet .amount { min-width: 0; font-size: 15px; }
  .user-btn { padding: 4px; gap: 4px; min-height: 40px; }
  .nav { order: 3; flex-basis: 100%; gap: 4px; margin: 0 -4px; }
  .nav a {
    flex: 1; text-align: center; padding: 11px 4px; font-size: 13px; letter-spacing: .3px;
    border-radius: 8px 8px 0 0; border-bottom: 2px solid transparent; white-space: nowrap;
  }
  .nav a.active { border-bottom-color: var(--blue); }

  main { padding: 18px max(16px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .page-head h1 { font-size: 24px; }

  /* 16px stops iOS zooming into inputs */
  .field input, .amount-box input, input { font-size: 16px; }
  .toggle-pw { min-height: 40px; min-width: 52px; padding: 0 10px; right: 2px; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; }
  .dropdown { width: 240px; }
  .dropdown a, .dropdown button { padding: 12px 12px; }

  /* roulette */
  .chip { width: 72px; height: 72px; }
  .chip::before { inset: 9px; }
  .chip::after { inset: 26px; }
  .chip.purple::after { inset: 22px; }
  .chip.sm { width: 24px; height: 24px; }
  .chip.sm::before { inset: 4px; }
  .chip.sm::after { inset: 8px; }
  .wheel-wrap { padding: 16px 0; }
  .wheel-wrap::before, .wheel-wrap::after { width: 40px; }
  .countdown span { font-size: 16px; padding: 8px 18px; }
  .history { margin: 12px 2px 16px; }
  .controls { display: grid; grid-template-columns: repeat(3, 1fr); }
  .controls .amount-box { grid-column: 1 / -1; }
  .controls .btn.ghost { padding: 10px 6px; }
  .columns { grid-template-columns: 1fr; }
  .bet-list { min-height: 0; max-height: 240px; }

  /* coinflip create bar: amount, quick buttons, side + items, place bet */
  .cf-create { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .cf-create .amount-box { grid-column: 1 / -1; }
  .cf-create .btn.ghost { padding: 10px 6px; }
  .cf-create .side-pick { grid-column: span 1; justify-content: center; padding: 0; }
  .cf-create #betItemsBtn { grid-column: span 2; }
  .cf-create #placeBtn { grid-column: 1 / -1; }
  .cf-stats { gap: 8px 18px; }
  .cf-row { grid-template-columns: 1fr auto; gap: 12px; padding: 12px; }
  .cf-row .cf-players { grid-column: 1 / -1; }
  .cf-actions { flex-wrap: wrap; }

  /* game windows become bottom sheets */
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal {
    max-width: none; max-height: 92dvh; border-radius: 18px 18px 0 0; border-bottom: 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); animation: sheet .22s ease-out;
  }
  .modal-close { width: 40px; height: 40px; top: 10px; right: 10px; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot .btn { flex: 1; }
  .flip-stage { grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0 8px; }
  .flip-center { grid-column: 1 / -1; order: -1; }
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }

  /* leaderboard */
  .podium { grid-template-columns: 1fr; gap: 10px; }
  .podium-card, .podium-card.p1 { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px 12px 48px; }
  .podium-card.p1 { order: -1; }
  .podium-card .avatar { width: 40px; height: 40px; font-size: 16px; margin: 0; }
  .podium-card .name { flex: 1; min-width: 0; }
  .podium-card .bal { margin: 0; }
  .podium-card .place { top: 50%; left: 12px; transform: translateY(-50%); }
  .panel { padding: 4px 12px; }
  .lb-row { font-size: 14px; gap: 10px; }
  .lb-row .rank { width: 26px; }

  /* toasts drop in from the top so they never cover bottom sheets or the bet buttons */
  .toast-wrap { left: 12px; right: 12px; top: calc(10px + env(safe-area-inset-top)); bottom: auto; }
  .toast { max-width: none; animation-name: dropin; }
}
@keyframes dropin { from { transform: translateY(-20px); opacity: 0; } }
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }

/* ---------- small phones (iPhone SE, Galaxy Fold) ---------- */
@media (max-width: 380px) {
  .logo { font-size: 20px; }
  .nav a { font-size: 12px; letter-spacing: 0; }
  .auth-card { padding: 26px 18px; }
  .auth-card .logo { font-size: 30px; }
  .chip { width: 64px; height: 64px; }
  .chip::before { inset: 8px; border-width: 2px; }
  .chip::after { inset: 23px; }
  .chip.purple::after { inset: 19px; }
  .chip.sm { width: 22px; height: 22px; }
  .flip-coin, .flip-coin .chip { width: 104px; height: 104px; }
  .flip-coin .chip::before { inset: 13px; border-width: 3px; }
  .flip-coin .chip::after { inset: 37px; }
  .flip-player { padding: 14px 6px; }
  .flip-player .avatar.big { width: 46px; height: 46px; font-size: 18px; }
  .cf-player .avatar { width: 34px; height: 34px; }
  .cf-player .side-badge { left: 20px; top: 19px; }
  .settings-card { padding: 16px; }
  .profile { gap: 12px; }
}

/* ---------- settings ---------- */
.settings-pane { display: flex; flex-direction: column; gap: 16px; max-width: 620px; }

.settings-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; }
.settings-card h2 { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.settings-card p { margin: 0; }
.settings-card .hint, .hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.settings-card .msg { margin-top: -4px; }
.settings-card .field input { background: var(--bg-2); }

.profile { display: flex; align-items: center; gap: 16px; }
.avatar.lg { width: 56px; height: 56px; font-size: 24px; flex: none; }
.profile-name { font-size: 20px; font-weight: 700; }
.profile-meta { color: var(--muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.profile > div { min-width: 0; }

.play-money { border-color: rgba(43, 214, 123, .4); background: linear-gradient(135deg, rgba(43, 214, 123, .08), var(--panel)); }
.play-money p, .play-money li { color: var(--text); font-size: 14px; line-height: 1.55; }
.play-money ul { margin: 8px 0 0; padding-left: 20px; }


/* ---------- legal page ---------- */
.back-link { margin-left: auto; }
.legal-doc { max-width: 780px; }
.legal-doc section { scroll-margin-top: 90px; margin-top: 36px; }   /* clear the sticky top bar */
.legal-doc section > h2 { font-family: 'Russo One', 'Rubik', sans-serif; font-weight: 400; font-size: 22px; margin: 0 0 6px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.legal-doc h3 { font-size: 15px; margin: 22px 0 6px; }
.legal-doc p, .legal-doc li { color: #c6cde0; font-size: 15px; line-height: 1.65; }
.legal-doc ul { padding-left: 20px; margin: 6px 0; }
.legal-doc code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.odds-table { border-collapse: collapse; margin: 8px 0; min-width: 280px; }
.odds-table th, .odds-table td { text-align: left; padding: 8px 18px 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.odds-table th { color: var(--muted); font-weight: 500; font-size: 13px; }
.odds-table .dot { box-shadow: none; }
.odds-table .dot.blue { background: var(--blue); }
.odds-table .dot.red { background: var(--red); }
.odds-table .dot.purple { background: var(--purple); }

.legal-toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.legal-toc a {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 9px 14px; border-radius: 999px; font-size: 14px; font-weight: 500;
}
.legal-toc a:hover { border-color: var(--blue); text-decoration: none; }

.legal-note { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 4px 0 12px; }
.legal-footer { text-align: center; font-size: 12.5px; margin: 10px 0 0; }
.legal-footer a { color: var(--muted); display: inline-block; padding: 8px; }

@media (max-width: 760px) {
  .settings-pane { max-width: none; }
  .settings-card .btn { width: 100%; }
  .back-link { order: 2; }
  .legal-doc section { scroll-margin-top: 130px; }
  .legal-doc p, .legal-doc li { font-size: 15px; }
  .odds-table { width: 100%; min-width: 0; }
  .switch a, .row-between a { display: inline-block; padding: 8px 2px; }
}

/* respect "reduce motion" settings */
@media (prefers-reduced-motion: reduce) {
  .dropdown, .dropdown.closing, .modal, .toast, .history-chips .chip.new { animation: none; }
  .user-btn .caret { transition: none; }
}
