/* =========================================================
   One Dollar Portal — Design System
   Base: charcoal
   Accent: amber / gold  (ties into the $1 money theme)
   ========================================================= */

/* ----- Google Fonts ------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ----- Custom Properties --------------------------------- */
:root {
  /* Backgrounds */
  --bg:        #161616;
  --surface-0: #1c1c1c;
  --surface-1: #222222;
  --surface-2: #2a2a2a;
  --surface-3: #333333;

  /* Borders */
  --border:    #2e2e2e;
  --border-hi: #3d3d3d;

  /* Text */
  --text:       #e6e6e6;
  --text-muted: #888888;
  --text-dim:   #555555;

  /* Accent: amber / gold */
  --accent:         #f59e0b;
  --accent-2:       #d97706;
  --accent-dim:     rgba(245, 158, 11, 0.10);
  --accent-glow:    rgba(245, 158, 11, 0.18);
  --accent-glow-sm: rgba(245, 158, 11, 0.07);

  /* Semantic */
  --danger:      #f87171;
  --danger-dim:  rgba(248, 113, 113, 0.12);
  --warning:     #fbbf24;
  --warning-dim: rgba(251, 191, 36, 0.12);
  --info:        #60a5fa;
  --info-dim:    rgba(96, 165, 250, 0.12);
  --success:     #34d399;
  --success-dim: rgba(52, 211, 153, 0.12);

  /* Geometry */
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 18px;

  /* Shadows */
  --shadow:        0 1px 2px rgba(0,0,0,0.6), 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:     0 2px 4px rgba(0,0,0,0.7), 0 8px 32px rgba(0,0,0,0.5);
  --shadow-accent: 0 4px 20px rgba(245, 158, 11, 0.22);

  /* Motion */
  --transition: 0.15s cubic-bezier(0.4, 0, 0.2, 1);

  /* Font */
  --font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4, h5, h6 { color: var(--text); font-weight: 700; line-height: 1.25; }

/* ----- Layout ------------------------------------------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-body {
  padding-top: 32px;
  padding-bottom: 48px;
}

/* ----- Nav ---------------------------------------------- */
.nav {
  background: var(--surface-0);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-brand {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent) !important;
  letter-spacing: -0.02em;
  margin-right: 12px;
}

.nav-links a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
}
.nav-links a:hover, .nav-links a.active {
  color: var(--text);
  background: var(--surface-2);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-user {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----- Buttons ------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font);
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* sizes */
.btn-sm  { font-size: 0.8rem;  padding: 5px 12px;  }
.btn-md  { font-size: 0.875rem; padding: 8px 18px;  }
.btn-lg  { font-size: 1rem;    padding: 12px 28px; }

/* default = btn-md */
.btn { font-size: 0.875rem; padding: 8px 18px; }

/* variants */
.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover {
  background: var(--accent-2);
  color: #000;
  box-shadow: var(--shadow-accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-hi);
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-hi);
}

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.2); }

/* ----- Cards -------------------------------------------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-sm { padding: 16px; border-radius: var(--radius); }
.card-lg { padding: 32px; }

/* ----- Forms -------------------------------------------- */
.form-group { margin-bottom: 20px; }

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow-sm);
}

/* ----- Flash Messages ----------------------------------- */
.flash-messages { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }

.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  border: 1px solid;
}

.flash.success  { background: var(--success-dim);  color: var(--success); border-color: rgba(52, 211, 153, 0.3); }
.flash.error    { background: var(--danger-dim);   color: var(--danger);  border-color: rgba(248, 113, 113, 0.3); }
.flash.warning  { background: var(--warning-dim);  color: var(--warning); border-color: rgba(251, 191, 36, 0.3); }
.flash.info     { background: var(--info-dim);     color: var(--info);    border-color: rgba(96, 165, 250, 0.3); }
.flash-close    { background: none; border: none; cursor: pointer; color: inherit; opacity: 0.6; font-size: 0.9rem; }
.flash-close:hover { opacity: 1; }

/* ----- Tables ------------------------------------------- */
.table-wrap { overflow-x: auto; }

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

thead th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: var(--surface-2); }

/* ----- Page headers ------------------------------------- */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 1.6rem; margin-bottom: 4px; }
.page-header p  { color: var(--text-muted); font-size: 0.9rem; }

/* ----- Badges ------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-success  { background: var(--success-dim);  color: var(--success); }
.badge-warning  { background: var(--warning-dim);  color: var(--warning); }
.badge-danger   { background: var(--danger-dim);   color: var(--danger); }
.badge-info     { background: var(--info-dim);     color: var(--info); }
.badge-accent   { background: var(--accent-dim);   color: var(--accent); }
.badge-muted    { background: var(--surface-3);    color: var(--text-muted); }

/* ----- Utility ------------------------------------------ */
.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.text-center { text-align: center; }

/* ----- Game Grid ---------------------------------------- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.game-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.game-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow), var(--shadow-accent);
  transform: translateY(-2px);
  color: inherit;
}

.game-card.coming-soon {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.game-card .game-icon { font-size: 2.2rem; line-height: 1; }
.game-card h3 { font-size: 1.1rem; margin: 0; }
.game-card p  { font-size: 0.875rem; color: var(--text-muted); flex: 1; }

.game-status {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  align-self: flex-start;
}

.game-card:not(.coming-soon) .game-status { background: var(--accent-dim); color: var(--accent); }
.coming-soon .game-status                 { background: var(--surface-3);  color: var(--text-dim); }

/* ----- Leaderboard -------------------------------------- */
.rank-1 td:first-child { color: var(--accent); font-weight: 700; }
.rank-2 td:first-child { color: #94a3b8; font-weight: 600; }
.rank-3 td:first-child { color: #cd7f32; font-weight: 600; }

.score-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
}

/* ----- Auth / simple page center ----------------------- */
.page-center {
  max-width: 420px;
  margin: 80px auto 0;
}

/* ----- Pass timer badge --------------------------------- */
.pass-timer {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
}
.pass-timer.expiring { color: var(--warning); border-color: var(--warning); }

/* ----- Game shell --------------------------------------- */
.game-shell { max-width: 720px; margin: 0 auto; }

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.game-header h2 { margin: 0; font-size: 1.25rem; }

.game-stats-bar {
  display: flex;
  margin-bottom: 24px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.game-stat {
  flex: 1;
  padding: 14px 16px;
  text-align: center;
  border-right: 1px solid var(--border);
}
.game-stat:last-child { border-right: none; }
.game-stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.game-stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
}

.game-panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 16px;
}

.game-over-card {
  text-align: center;
  background: var(--surface-1);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  padding: 40px;
}
.game-over-card h3 { font-size: 1.8rem; margin-bottom: 8px; }
.game-over-card .final-score { font-size: 2.4rem; font-weight: 900; color: var(--accent); margin: 12px 0; }
.game-over-card p { color: var(--text-muted); margin-bottom: 4px; }
.game-over-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
  flex-wrap: wrap;
}

.status-msg {
  text-align: center;
  margin-top: 16px;
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 22px;
  color: var(--text-muted);
}
.status-msg.success { color: var(--success); }
.status-msg.error   { color: var(--danger); }
