*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0f0f0f;
  color: #e8e8e8;
  min-height: 100vh;
}

/* Auth screen */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  background: #1a1a1a;
  border: 0.5px solid #2e2e2e;
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}

.auth-card h1 { font-size: 28px; margin-bottom: 4px; text-align: center; }
.auth-sub { text-align: center; color: #888; font-size: 14px; margin-bottom: 1.5rem; }

.auth-tabs { display: flex; gap: 8px; margin-bottom: 1.25rem; }
.auth-tab {
  flex: 1; padding: 8px; border-radius: 8px;
  border: 0.5px solid #2e2e2e; background: transparent;
  color: #888; cursor: pointer; font-size: 14px; transition: all .15s;
}
.auth-tab.active { background: #2e2e2e; color: #e8e8e8; }

.auth-card input {
  width: 100%; padding: 10px 12px; margin-bottom: 10px;
  background: #111; border: 0.5px solid #2e2e2e;
  border-radius: 8px; color: #e8e8e8; font-size: 14px;
}
.auth-card input:focus { outline: none; border-color: #555; }

.primary-btn {
  width: 100%; padding: 11px; background: #e8e8e8; color: #0f0f0f;
  border: none; border-radius: 8px; font-size: 15px;
  font-weight: 600; cursor: pointer; transition: opacity .15s;
}
.primary-btn:hover { opacity: .85; }

.auth-error { color: #E24B4A; font-size: 13px; margin-top: 10px; text-align: center; min-height: 20px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: .75rem 1.5rem;
  border-bottom: 0.5px solid #1e1e1e;
  background: #111;
}
.topbar-logo { font-size: 16px; font-weight: 600; flex: 1; }
#topbar-user { font-size: 13px; color: #888; }
.signout-btn {
  font-size: 12px; padding: 5px 12px;
  background: transparent; border: 0.5px solid #2e2e2e;
  border-radius: 6px; color: #888; cursor: pointer;
}
.signout-btn:hover { border-color: #555; color: #e8e8e8; }

/* Game layout */
.wrap { padding: 1.5rem; max-width: 640px; margin: 0 auto; position: relative; overflow: hidden; }

.balance-bar { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 1rem; }
.metric { background: #1a1a1a; border-radius: 10px; padding: .75rem 1rem; }
.metric-label { font-size: 12px; color: #888; margin-bottom: 4px; }
.metric-value { font-size: 20px; font-weight: 500; }
.metric-value.green { color: #1D9E75; }
.metric-value.red { color: #E24B4A; }

.card {
  background: #1a1a1a; border: 0.5px solid #2e2e2e;
  border-radius: 14px; padding: 1.25rem; margin-bottom: 1rem;
  position: relative; transition: border-color .4s, box-shadow .4s;
}

.card.streak-5  { border-color: #f97316; box-shadow: 0 0 0 1px #f9731640, 0 0 18px 2px #f9731628; }
.card.streak-10 { border-color: #3b82f6; box-shadow: 0 0 0 1px #3b82f640, 0 0 22px 4px #3b82f630; }
.card.streak-20 { border-color: #a855f7; box-shadow: 0 0 0 1px #a855f740, 0 0 28px 6px #a855f730; }

@keyframes pulse-streak { 0%,100%{opacity:1} 50%{opacity:.65} }
.card.streak-5, .card.streak-10, .card.streak-20 { animation: pulse-streak 2s ease-in-out infinite; }

@keyframes shake {
  0%,100%{transform:translateX(0)} 15%{transform:translateX(-6px)}
  30%{transform:translateX(5px)} 45%{transform:translateX(-4px)}
  60%{transform:translateX(3px)} 75%{transform:translateX(-2px)} 90%{transform:translateX(1px)}
}
.card.shaking { animation: shake .45s ease-out; }

@keyframes win-flash {
  0%{background:#1a1a1a} 30%{background:#1D9E7514} 100%{background:#1a1a1a}
}
.card.win-flash { animation: win-flash .6s ease-out; }

.section-label { font-size: 12px; color: #888; margin-bottom: .5rem; letter-spacing: .04em; text-transform: uppercase; }

.roll-display { text-align: center; margin: 1.25rem 0; }
.roll-number { font-size: 64px; font-weight: 500; line-height: 1; transition: color .15s; }
.roll-number.win  { color: #1D9E75; }
.roll-number.lose { color: #E24B4A; }
.roll-number.idle { color: #555; }
.roll-result-text { font-size: 14px; margin-top: 6px; min-height: 20px; color: #888; }

.slider-row { margin-bottom: 1rem; }
.slider-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.slider-header span { font-size: 13px; color: #888; }
.slider-header strong { font-size: 15px; font-weight: 500; }
input[type=range] { width: 100%; accent-color: #1D9E75; }

.chance-bar { height: 6px; border-radius: 3px; background: #2e2e2e; margin-top: 6px; overflow: hidden; }
.chance-fill { height: 100%; background: #1D9E75; border-radius: 3px; transition: width .2s; }

.bet-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1rem; align-items: end; }
.bet-input-wrap input[type=number] {
  width: 100%; padding: 8px 10px; font-size: 15px;
  border: 0.5px solid #2e2e2e; border-radius: 8px;
  background: #111; color: #e8e8e8;
}

.bet-shortcuts { display: flex; gap: 6px; margin-top: 6px; }
.bet-shortcuts button {
  flex: 1; font-size: 11px; padding: 4px 0;
  background: #111; border: 0.5px solid #2e2e2e;
  border-radius: 6px; color: #888; cursor: pointer;
}
.bet-shortcuts button:hover { border-color: #555; color: #e8e8e8; }

.over-under { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1rem; }
.ou-btn {
  padding: 10px; border-radius: 8px; border: 0.5px solid #2e2e2e;
  background: #111; cursor: pointer; text-align: center;
  font-size: 14px; color: #888; transition: all .15s;
}
.ou-btn.active { background: #1a3a5c; border-color: #2a5a8c; color: #60a5fa; font-weight: 500; }

.roll-btn {
  width: 100%; padding: 12px; font-size: 16px; font-weight: 500;
  background: #1a1a1a; border: 0.5px solid #2e2e2e;
  border-radius: 8px; color: #e8e8e8; cursor: pointer;
  letter-spacing: .02em; transition: background .1s, transform .05s, box-shadow .3s, font-size .25s, padding .25s, border-color .3s;
}
.roll-btn:active  { transform: scale(.98); }
.roll-btn:hover   { background: #222; }
.roll-btn:disabled { opacity: .4; cursor: default; }
.roll-btn.bet-med  { font-size: 17px; padding: 14px 12px; border-color: #f97316aa; box-shadow: 0 0 10px 0 #f9731622; }
.roll-btn.bet-high { font-size: 18px; padding: 16px 12px; border-color: #ef4444aa; box-shadow: 0 0 16px 0 #ef444430; }
.roll-btn.bet-max  { font-size: 19px; padding: 17px 12px; border-color: #a855f7; box-shadow: 0 0 0 2px #a855f740, 0 0 22px 4px #a855f728; }

@keyframes max-pulse {
  0%,100% { box-shadow: 0 0 0 2px #a855f740, 0 0 22px 4px #a855f728; }
  50%      { box-shadow: 0 0 0 3px #a855f780, 0 0 32px 8px #a855f750; }
}
.roll-btn.bet-max { animation: max-pulse 1.2s ease-in-out infinite; }

.stats-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: 1rem; }
.stat-cell { text-align: center; }
.stat-val { font-size: 15px; font-weight: 500; }
.stat-lbl { font-size: 11px; color: #888; margin-top: 2px; }

.history { max-height: 140px; overflow-y: auto; }
.history-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 0.5px solid #2e2e2e; font-size: 13px; }
.history-row:last-child { border-bottom: none; }
.h-roll { font-weight: 500; min-width: 36px; }
.h-win  { color: #1D9E75; font-weight: 500; }
.h-lose { color: #E24B4A; font-weight: 500; }
.h-bal  { color: #888; font-size: 12px; }

.pf-note { font-size: 11px; color: #555; display: flex; align-items: center; gap: 6px; margin-top: .5rem; flex-wrap: wrap; }
.seed-hash { font-family: monospace; font-size: 10px; color: #555; word-break: break-all; }

.daily-bar-wrap { margin-bottom: 1rem; }
.daily-label-row { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 12px; color: #888; }
.daily-bar { height: 4px; background: #2e2e2e; border-radius: 2px; overflow: hidden; }
.daily-fill { height: 100%; background: #378ADD; border-radius: 2px; transition: width .3s; }

.effects-toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #888; margin-bottom: 1rem; user-select: none; cursor: pointer; }
.effects-toggle input { cursor: pointer; }

.face-wrap { position: relative; display: inline-block; font-size: 18px; line-height: 1; vertical-align: middle; margin-left: 4px; }
.face-temp { position: absolute; top: 0; left: 0; opacity: 0; transition: opacity .2s; pointer-events: none; }
.face-temp.show { opacity: 1; }

.bust-msg { text-align: center; padding: .75rem; font-size: 14px; color: #E24B4A; }
.coin-particle { position: fixed; font-size: 20px; pointer-events: none; z-index: 9999; will-change: transform, opacity; }

.streak-badge { font-size: 11px; font-weight: 500; padding: 2px 7px; border-radius: 10px; margin-left: 6px; vertical-align: middle; }
.streak-badge.s5  { background: #f9731622; color: #f97316; }
.streak-badge.s10 { background: #3b82f622; color: #3b82f6; }
.streak-badge.s20 { background: #a855f722; color: #a855f7; }

/* Leaderboard */
.lb-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 0.5px solid #2e2e2e; font-size: 13px; }
.lb-row:last-child { border-bottom: none; }
.lb-rank { font-size: 15px; min-width: 28px; }
.lb-name { flex: 1; font-weight: 500; }
.lb-stat { color: #888; font-size: 12px; }
.lb-bal  { font-weight: 500; color: #1D9E75; }

.guest-btn {
  width: 100%; padding: 11px; background: transparent;
  border: 0.5px solid #2e2e2e; border-radius: 8px;
  color: #888; font-size: 14px; cursor: pointer;
  margin-top: 8px; transition: border-color .15s, color .15s;
}
.guest-btn:hover { border-color: #555; color: #e8e8e8; }

.guest-banner {
  background: #1a1a0a; border-bottom: 0.5px solid #3a3a1a;
  padding: .6rem 1.5rem; font-size: 13px; color: #aaa; text-align: center;
}
.guest-banner a { color: #f97316; cursor: pointer; text-decoration: underline; }