/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0a0a;
  --surface:   #161616;
  --border:    #2a2a2a;
  --text:      #f0f0f0;
  --muted:     #888;
  --accent:    #e8ff00;   /* sharp pool-table green-yellow */
  --win:       #22c55e;
  --lose:      #ef4444;
  --radius:    12px;
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ─── Screens ───────────────────────────────────────────────── */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  gap: 1rem;
}

.hidden { display: none !important; }

/* ─── Typography ────────────────────────────────────────────── */
.logo {
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: -2px;
  color: var(--accent);
}

.tagline {
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  align-self: flex-start;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  align-self: flex-start;
  margin-top: 1rem;
}

.hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-ghost {
  width: 100%;
  padding: 0.875rem 1.5rem;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  margin-top: 0.5rem;
}

.btn-primary:active, .btn-secondary:active, .btn-ghost:active { opacity: 0.7; }

.link-subtle {
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  margin-top: 0.5rem;
}

.link-subtle:hover { color: var(--text); }

/* ─── Forms ─────────────────────────────────────────────────── */
form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

input, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  padding: 0.75rem 1rem;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; font-family: var(--font); }

/* ─── Home action grid ──────────────────────────────────────── */
.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
}

.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-family: var(--font);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}

.action-card small {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
}

.action-card.win  { border-color: var(--win); }
.action-card.lose { border-color: var(--lose); }
.action-card:active { opacity: 0.75; }
.action-icon { font-size: 1.8rem; }

/* ─── QR Display ────────────────────────────────────────────── */
#qr-container {
  background: #fff;
  padding: 1.25rem;
  border-radius: var(--radius);
  display: inline-flex;
}

#qr-container canvas { display: block; }

.countdown {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 1px;
}

/* ─── Scanner ───────────────────────────────────────────────── */
#scanner-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius);
  background: #000;
  border: 2px solid var(--border);
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#scanner-overlay {
  position: absolute;
  inset: 20%;
  border: 2px solid var(--accent);
  border-radius: 8px;
  pointer-events: none;
}

#scanner-status {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ─── Leaderboard ───────────────────────────────────────────── */
#leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

#leaderboard-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid var(--border);
}

#leaderboard-table td {
  padding: 0.6rem 0.25rem;
  border-bottom: 1px solid var(--border);
}

#leaderboard-table tr:first-child td { color: var(--accent); font-weight: 700; }

/* ─── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.toast.error { border-color: var(--lose); color: var(--lose); }
.toast.success { border-color: var(--win); color: var(--win); }
