:root {
  --bg: #0f1115;
  --panel: #171a21;
  --line: #000;
  --border: #2a2f3a;
  --red: #e03a2f;
  --green: #4caf3a;
  --yellow: #e8c93a;
  --text: #e8e8e8;
  --muted: #9aa0ab;
  color-scheme: dark;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  line-height: 1.7;
}

h1, h2 { font-family: "Press Start 2P", monospace; letter-spacing: 1px; }
h1 { font-size: 18px; color: var(--red); }
h2 { font-size: 13px; color: var(--yellow); margin-top: 28px; }

a { color: var(--yellow); }

img { max-width: 100%; }
[hidden] { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 4px solid var(--red);
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-size: 16px;
  color: var(--text);
  white-space: nowrap;
}
.logo { width: 28px; height: 28px; image-rendering: pixelated; }
.dotbet { color: var(--red); }

.marquee {
  flex: 1;
  overflow: hidden;
  border: 2px solid var(--border);
  background: #000;
  padding: 6px 0;
  min-width: 200px;
}
.marquee-track {
  display: inline-block;
  white-space: nowrap;
  padding-left: 100%;
  color: var(--green);
  font-size: 10px;
  animation: marquee 18s linear infinite;
}
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

.userbar { display: flex; align-items: center; gap: 12px; font-size: 10px; white-space: nowrap; }
.balance { color: var(--green); }
.username { color: var(--yellow); }
.admin-link {
  border: 2px solid var(--yellow);
  padding: 4px 6px;
  text-decoration: none;
  color: var(--yellow);
}
.logout-form { margin: 0; }

button {
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  border: 2px solid #000;
  background: var(--panel);
  color: var(--text);
  padding: 8px 10px;
  box-shadow: 3px 3px 0 #000;
}
button:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 #000; }
button:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 #000; }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--red); color: #fff; border-color: #000; }
.btn-danger { background: #3a1414; color: var(--red); }
.btn-solo { background: var(--yellow); color: #0b0d11; border-color: #000; }

main { padding: 20px 16px 40px; max-width: 1100px; margin: 0 auto; }

/* auth pages */
.auth-card {
  max-width: 380px;
  margin: 40px auto;
  background: var(--panel);
  border: 4px solid #000;
  box-shadow: 6px 6px 0 #000;
  padding: 24px;
}
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 10px; color: var(--muted); }
input[type="text"], input[type="password"] {
  font-family: inherit;
  font-size: 12px;
  background: #0b0d11;
  border: 2px solid var(--border);
  color: var(--text);
  padding: 8px;
}
.error { color: var(--red); border: 2px solid var(--red); padding: 8px; font-size: 10px; }
.switch { font-size: 10px; color: var(--muted); margin-top: 16px; }

/* wheel page */
.wheel-page { display: flex; gap: 24px; align-items: flex-start; }
.wheel-area { flex: 2; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.wheel-wrap { position: relative; width: 100%; max-width: 500px; }
#wheel-canvas { width: 100%; height: auto; display: block; border: 4px solid #000; box-shadow: 6px 6px 0 #000; background: var(--panel); }
.pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 22px solid var(--red);
  z-index: 2;
  filter: drop-shadow(2px 2px 0 #000);
}
.btn-spin { font-size: 14px; padding: 14px 28px; }

.waiting { font-size: 11px; color: var(--muted); }

.bet-slip {
  width: 100%;
  max-width: 500px;
  border: 3px solid var(--border);
  background: var(--panel);
  padding: 14px;
}
.bet-slip h2 { margin-top: 0; }
.bet-slip-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bet-slip-form select, .bet-slip-form input[type="number"] {
  font-family: inherit;
  font-size: 11px;
  background: #0b0d11;
  border: 2px solid var(--border);
  color: var(--text);
  padding: 8px;
}
.bet-slip-form input[type="number"] { width: 90px; }
.my-bet { color: var(--yellow); font-size: 11px; }

.result-card {
  border: 4px solid var(--green);
  background: var(--panel);
  box-shadow: 6px 6px 0 #000;
  padding: 16px;
  text-align: center;
  color: var(--green);
  font-size: 14px;
}
.payout-list { font-size: 10px; margin-top: 8px; }

/* Don Doner easter egg */
.don-doner-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  text-align: center;
  background: #1a0000;
  animation: donerFlash 0.5s steps(2) infinite;
}
@keyframes donerFlash {
  0%, 100% { background: #1a0000; }
  50% { background: #4a0000; }
}
.don-doner-headline {
  position: relative;
  z-index: 2;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(20px, 6vw, 34px);
  color: var(--yellow);
  text-shadow: 4px 4px 0 #000;
  animation: donerShake 0.3s steps(3) infinite, donerPulse 0.6s ease-in-out infinite;
}
@keyframes donerShake {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-3px, 2px) rotate(-2deg); }
  50% { transform: translate(3px, -2px) rotate(2deg); }
  75% { transform: translate(-2px, -3px) rotate(-1deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}
@keyframes donerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
.don-doner-sub { position: relative; z-index: 2; font-size: 14px; color: var(--green); }
.don-doner-sub2 { position: relative; z-index: 2; font-size: 11px; color: var(--muted); }
.don-doner-overlay .payout-list { position: relative; z-index: 2; color: var(--text); max-height: 30vh; overflow-y: auto; }

.doner-fall {
  position: absolute;
  top: -100px;
  z-index: 1;
  animation-name: donerFall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes donerFall {
  from { transform: translateY(0); }
  to { transform: translateY(115vh); }
}
.doner-spin {
  display: block;
  image-rendering: pixelated;
  animation-name: donerSpin;
  animation-timing-function: steps(8);
  animation-iteration-count: infinite;
}
@keyframes donerSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.don-doner-overlay.reduced,
.don-doner-overlay.reduced .don-doner-headline {
  animation: none;
}
@media (prefers-reduced-motion: reduce) {
  .don-doner-overlay { animation: none; }
  .don-doner-headline { animation: none; }
  .doner-fall, .doner-spin { animation: none; display: none; }
}

.side-panel { flex: 1; min-width: 220px; }
.restaurant-list, .spin-list, .leaderboard { list-style: none; padding: 0; margin: 8px 0; }
.restaurant-list li, .spin-list li, .leaderboard li {
  border: 2px solid var(--border);
  background: var(--panel);
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.odds { color: var(--yellow); }
.spin-list .time { color: var(--muted); display: block; font-size: 9px; margin-top: 4px; }
.leaderboard li.rank.me { border-color: var(--green); }
.medal { margin-right: 4px; }

.odds-icon { width: 20px; height: 20px; image-rendering: pixelated; vertical-align: middle; margin-right: 6px; }
.bet-icon { width: 20px; height: 20px; image-rendering: pixelated; vertical-align: middle; margin-right: 6px; }
.winner-icon { display: block; width: 96px; height: 96px; image-rendering: pixelated; margin: 0 auto 8px; }

/* admin page */
.admin-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 10px; }
.admin-table th, .admin-table td { border: 2px solid var(--border); padding: 8px; text-align: left; }
.admin-table .code { color: var(--yellow); }
.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; font-size: 10px; }
.thumb { width: 24px; height: 24px; image-rendering: pixelated; display: block; }
.image-form { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.image-form input[type="file"] { font-size: 9px; max-width: 140px; color: var(--muted); }

footer {
  text-align: center;
  font-size: 9px;
  color: var(--muted);
  padding: 20px;
  border-top: 2px solid var(--border);
}

@media (max-width: 700px) {
  .wheel-page { flex-direction: column; }
  .topbar { flex-direction: column; align-items: stretch; }
  main { padding: 16px; }
}
