/* Coin Empire — Dark mode UI inspired by 1b2t.xyz aesthetic
   - Nunito font
   - Rounded borders (12-16px)
   - Dark background, light text
   - Purple/gold accent palette
   - Minimal, clean layout
*/

:root {
  --bg: #0e0e10;
  --bg-elev: #161618;
  --bg-elev-2: #1d1d21;
  --bg-hover: #232328;
  --border: #2a2a30;
  --border-strong: #3a3a44;
  --text: #e8e8ec;
  --text-muted: #8e8e9a;
  --text-dim: #6a6a78;
  --accent: #b388ff;
  --accent-2: #ffd700;
  --accent-hover: #c5a2ff;
  --success: #4ade80;
  --danger: #ef4444;
  --warning: #fbbf24;
  --info: #60a5fa;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.5);
  --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Nunito', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'SFMono-Regular', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
}

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

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(179, 136, 255, 0.18);
}

/* Layout */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

/* Header */
.header {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  font-size: 20px;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent-2), #ffaa00);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #1a1a1a;
  font-size: 16px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-balance {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.header-balance .coin-icon {
  width: 16px;
  height: 16px;
  background: var(--accent-2);
  border-radius: 50%;
  display: inline-block;
}

.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 14px;
  transition: all var(--transition);
}
.nav-link:hover {
  background: var(--bg-elev-2);
  color: var(--text);
}
.nav-link.active {
  background: var(--bg-elev-2);
  color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14px;
  transition: all var(--transition);
  border: 1px solid transparent;
  background: var(--bg-elev-2);
  color: var(--text);
  white-space: nowrap;
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  color: #1a1a1a;
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-success {
  background: var(--success);
  color: #0a1f0e;
}
.btn-success:hover {
  filter: brightness(1.1);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  filter: brightness(1.1);
}
.btn-ghost {
  background: transparent;
}
.btn-ghost:hover {
  background: var(--bg-elev-2);
}
.btn-block {
  width: 100%;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}
.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

/* Cards */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--text);
}

/* Game grid */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.game-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.game-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.game-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0;
  transition: opacity var(--transition);
}
.game-card:hover::before { opacity: 1; }

.game-card-icon {
  font-size: 36px;
  margin-bottom: 12px;
  display: block;
}
.game-card-name {
  font-weight: 800;
  font-size: 17px;
  margin-bottom: 4px;
}
.game-card-desc {
  color: var(--text-muted);
  font-size: 13px;
}

/* Main content */
.main {
  flex: 1;
  padding: 32px 0;
}

/* Hero section */
.hero {
  text-align: center;
  padding: 48px 0 32px;
}
.hero h1 {
  font-size: 38px;
  font-weight: 900;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  color: var(--text-muted);
  font-size: 16px;
  max-width: 600px;
  margin: 0 auto 24px;
}

/* Game play view */
.game-view {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}
@media (max-width: 900px) {
  .game-view { grid-template-columns: 1fr; }
}

.game-canvas {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bet-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bet-amount-row {
  display: flex;
  gap: 8px;
}
.bet-amount-row input { flex: 1; }
.bet-quick {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.bet-quick button {
  flex: 1;
  min-width: 60px;
  padding: 6px 8px;
  font-size: 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 700;
  transition: all var(--transition);
}
.bet-quick button:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

/* Game-specific styles */
.coinflip-coin {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-2), #c8a000);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  font-weight: 900;
  color: #1a1a1a;
  margin: 24px 0;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.3);
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.coinflip-coin.flipping {
  animation: flip 0.8s ease-out;
}
@keyframes flip {
  0% { transform: rotateY(0); }
  100% { transform: rotateY(1800deg); }
}

.coinflip-choices {
  display: flex;
  gap: 12px;
  margin: 16px 0;
}
.choice-btn {
  flex: 1;
  padding: 16px;
  background: var(--bg-elev-2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition);
}
.choice-btn:hover { border-color: var(--accent); }
.choice-btn.selected {
  border-color: var(--accent);
  background: rgba(179, 136, 255, 0.15);
  color: var(--accent);
}

/* Dice */
.dice-canvas {
  width: 100%;
  max-width: 500px;
  margin: 24px 0;
}
.dice-track {
  position: relative;
  height: 60px;
  background: linear-gradient(90deg,
    var(--success) 0%,
    var(--success) var(--target, 50%),
    var(--bg-elev-2) var(--target, 50%),
    var(--bg-elev-2) 100%);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.dice-marker {
  position: absolute;
  top: -10px;
  width: 4px;
  height: 80px;
  background: var(--text);
  border-radius: 2px;
  transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px rgba(255,255,255,0.4);
}
.dice-roll {
  text-align: center;
  font-size: 48px;
  font-weight: 900;
  margin: 16px 0;
  font-family: var(--mono);
}
.dice-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
}
.dice-slider-row input[type=range] { flex: 1; padding: 0; }
.dice-target {
  font-weight: 800;
  min-width: 60px;
  text-align: center;
  background: var(--bg-elev-2);
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Crash */
.crash-canvas {
  width: 100%;
  max-width: 600px;
  height: 300px;
  background: var(--bg-elev-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  margin: 16px 0;
}
.crash-multiplier {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 64px;
  font-weight: 900;
  font-family: var(--mono);
  text-shadow: 0 0 30px rgba(179, 136, 255, 0.6);
}
.crash-multiplier.crashed { color: var(--danger); }
.crash-multiplier.running { color: var(--success); }

/* Mines */
.mines-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-width: 400px;
  margin: 16px auto;
}
.mine-tile {
  aspect-ratio: 1;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
  cursor: pointer;
  transition: all var(--transition);
}
.mine-tile:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}
.mine-tile.revealed {
  background: var(--bg-elev);
  cursor: default;
}
.mine-tile.revealed.safe { color: var(--success); }
.mine-tile.revealed.mine { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.mine-tile.disabled { opacity: 0.5; cursor: not-allowed; }

/* Limbo */
.limbo-display {
  font-size: 80px;
  font-weight: 900;
  font-family: var(--mono);
  margin: 24px 0;
  text-align: center;
  text-shadow: 0 0 30px rgba(179, 136, 255, 0.6);
}
.limbo-display.win { color: var(--success); }
.limbo-display.loss { color: var(--danger); }

/* Plinko */
.plinko-canvas {
  width: 100%;
  max-width: 500px;
  margin: 16px auto;
  background: var(--bg-elev-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* History */
.history-table {
  width: 100%;
  border-collapse: collapse;
}
.history-table th, .history-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.history-table th {
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.history-table tr:hover {
  background: var(--bg-elev-2);
}
.history-table .positive { color: var(--success); }
.history-table .negative { color: var(--danger); }

/* Auth forms */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 64px);
  padding: 32px 0;
}
.auth-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-title {
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 4px;
  text-align: center;
}
.auth-subtitle {
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
  font-size: 14px;
}
.auth-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  background: var(--bg-elev-2);
  padding: 4px;
  border-radius: var(--radius-sm);
}
.auth-tab {
  flex: 1;
  padding: 10px;
  border-radius: 6px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.auth-tab.active {
  background: var(--bg);
  color: var(--text);
}

/* Toast */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 360px;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.info { border-color: var(--info); color: var(--info); }
@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 24px;
  font-weight: 900;
  font-family: var(--mono);
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elev);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.data-table th, .data-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.data-table th {
  background: var(--bg-elev-2);
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
}
.data-table tr:last-child td { border-bottom: none; }

/* Admin layout */
.admin-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  min-height: calc(100vh - 64px);
}
@media (max-width: 800px) {
  .admin-grid { grid-template-columns: 1fr; }
}
.admin-nav {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  height: fit-content;
  position: sticky;
  top: 80px;
}
.admin-nav-item {
  display: block;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
  transition: all var(--transition);
  cursor: pointer;
}
.admin-nav-item:hover {
  background: var(--bg-elev-2);
  color: var(--text);
}
.admin-nav-item.active {
  background: var(--accent);
  color: #1a1a1a;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-admin { background: var(--accent); color: #1a1a1a; }
.badge-banned { background: var(--danger); color: #fff; }
.badge-active { background: var(--success); color: #0a1f0e; }

/* Loading & states */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title {
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 8px;
}
.modal-body {
  color: var(--text-muted);
  margin-bottom: 24px;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Mobile */
@media (max-width: 600px) {
  .header-inner { padding: 0 12px; }
  .container { padding: 0 12px; }
  .hero h1 { font-size: 28px; }
  .games-grid { grid-template-columns: 1fr 1fr; }
  .nav-link { padding: 6px 10px; font-size: 13px; }
  .crash-multiplier, .limbo-display { font-size: 56px; }
}

/* Provably fair widget */
.provably-widget {
  background: var(--bg-elev-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 12px;
  font-family: var(--mono);
  word-break: break-all;
}
.provably-widget .label {
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  font-family: var(--font);
}

/* Utility */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mono { font-family: var(--mono); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.hidden { display: none; }

/* Keyboard accessibility — focus ring on all interactive elements */
.btn:focus-visible,
.nav-link:focus-visible,
.game-card:focus-visible,
.choice-btn:focus-visible,
.mine-tile:focus-visible,
.admin-nav-item:focus-visible,
.auth-tab:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Crash multiplier color transition (smoother crash animation) */
.crash-multiplier {
  transition: color 200ms ease;
}

/* Header balance tabular numerals + mobile compactness */
.header-balance {
  font-variant-numeric: tabular-nums;
}
@media (max-width: 600px) {
  .header-balance { font-size: 13px; padding: 6px 10px; }
}
