/* Restrained Dracula palette, same colours as the bot's embeds. */
:root {
  --bg: #282a36;
  --surface: #2f3241;
  --surface-2: #383a4a;
  --border: #44475a;
  --text: #f8f8f2;
  --muted: #9aa0bf;
  --purple: #bd93f9;
  --green: #50fa7b;
  --red: #ff5555;
  --yellow: #f1fa8c;
  --cyan: #8be9fd;
  --radius: 10px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

h1 {
  font-size: 1.6rem;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

h3 {
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.good {
  color: var(--green);
}

.bad {
  color: var(--red);
}

/* --- Layout -------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.nav a,
.tabs a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}

.nav a:hover,
.tabs a:hover {
  color: var(--text);
}

.nav a.active,
.tabs a.active {
  color: var(--bg);
  background: var(--purple);
}

.account {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.user,
.player {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.player span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex: none;
  background: var(--surface-2);
}

.pill {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--yellow);
  font-weight: 600;
  white-space: nowrap;
}

.main {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  flex: 1;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.notice {
  background: var(--surface-2);
  border-left: 3px solid var(--red);
  padding: 0.6rem 1.25rem;
}

.grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid.three {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  min-width: 0;
}

.grid > .card {
  margin-bottom: 0;
}

.card.narrow {
  max-width: 520px;
}

.card.error {
  border-color: var(--red);
}

.hero {
  padding: 2rem 0;
}

/* --- Controls ------------------------------------------------------------------ */

button,
.button {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button:hover:not(:disabled),
.button:hover {
  border-color: var(--purple);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.primary,
.button.primary {
  background: var(--purple);
  border-color: var(--purple);
  color: var(--bg);
  font-weight: 600;
}

button.ghost {
  background: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

input,
select {
  font: inherit;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  min-width: 0;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin: 1rem 0;
}

.controls input[type='number'] {
  width: 9rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.field-label .hint {
  font-size: 0.8rem;
  opacity: 0.8;
}

.button-row {
  display: flex;
  gap: 0.5rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* --- Statistics ---------------------------------------------------------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  display: flex;
  flex-direction: column;
}

.tile-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.tile-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.tile.good .tile-value {
  color: var(--green);
}

.tile.bad .tile-value {
  color: var(--red);
}

.table-wrap {
  overflow-x: auto;
  scrollbar-color: var(--border) transparent;
}

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

th,
td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 500;
}

.leaderboard {
  counter-reset: rank;
}

.leaderboard,
.game-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  counter-increment: rank;
}

.leaderboard li::before {
  content: counter(rank);
  color: var(--muted);
  width: 1.5rem;
  flex: none;
}

.leaderboard .player {
  flex: 1;
}

.leaderboard .value {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.game-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.1rem 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.game-line .game-result {
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
}

.game-line .game-meta {
  grid-column: 1 / -1;
  font-size: 0.8rem;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  padding-bottom: 1.25rem;
}

.bar {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
}

.bar-fill {
  background: var(--purple);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}

.bar-label {
  position: absolute;
  bottom: -1.25rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
}

/* --- Games --------------------------------------------------------------------- */

.result {
  min-height: 3rem;
  margin-top: 0.5rem;
}

.outcome {
  font-weight: 700;
  font-size: 1.05rem;
}

.coin,
.pocket,
.wheel {
  font-size: 2.5rem;
  font-weight: 700;
}

.wheel.spinning {
  display: inline-block;
  animation: spin 0.6s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .wheel.spinning {
    animation: none;
  }
}

.pocket.red {
  color: var(--red);
}

.pocket.green {
  color: var(--green);
}

.reels {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.35rem 0;
}

.reel {
  font-size: 2rem;
  width: 3rem;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.combo {
  margin-left: 0.5rem;
  font-size: 0.9rem;
}

.pay-table ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
}

.pay-table li {
  display: flex;
  gap: 0.75rem;
  padding: 0.2rem 0;
}

.pay-table .emoji {
  width: 1.5rem;
}

.mines-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 1rem 0;
}

.mines-grid {
  display: grid;
  gap: 6px;
  max-width: 380px;
  margin: 1rem 0;
}

.tile-btn {
  aspect-ratio: 1;
  font-size: 1.4rem;
  padding: 0;
}

.tile-btn.safe {
  background: color-mix(in srgb, var(--green) 25%, var(--surface-2));
  opacity: 1;
}

.tile-btn.hit {
  background: var(--red);
  opacity: 1;
}

.tile-btn.mine,
.tile-btn.dim {
  opacity: 0.55;
}

@media (max-width: 640px) {
  .topbar {
    padding: 0.6rem 1rem;
  }

  .nav {
    order: 3;
    flex-basis: 100%;
  }
}
