:root {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --border-card: #e2e8f0;
  --border-hover: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-sub: #94a3b8;
  --accent-red: #ef4444;
  --accent-red-bg: #fee2e2;
  --accent-red-text: #991b1b;
  --accent-amber: #f59e0b;
  --accent-amber-bg: #fef3c7;
  --accent-amber-text: #92400e;
  --accent-blue: #2563eb;
  --accent-blue-bg: #dbeafe;
  --accent-blue-text: #1e40af;
  --accent-green: #10b981;
  --accent-green-bg: #d1fae5;
  --accent-green-text: #065f46;
  --accent-purple: #8b5cf6;
  --accent-purple-bg: #ede9fe;
  --accent-purple-text: #5b21b6;
  --font-sans: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Space Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html, body {
  min-height: 100%;
  background: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Header */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1.25rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-card);
}

.title-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.page-title {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-main);
}

.page-sub {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.header-actions-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.sync-status-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.btn-refresh {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
  transition: background 0.2s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-refresh:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.btn-refresh:active {
  transform: translateY(0);
}

.btn-refresh:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  transform: none;
}

.btn-history, .btn-back {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-card);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-history:hover, .btn-back:hover {
  border-color: var(--border-hover);
  background: #f1f5f9;
}

/* User Card */
.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  flex-wrap: wrap;
  gap: 1rem;
}

.user-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid #e2e8f0;
  object-fit: cover;
}

.user-meta h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.user-handle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.user-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge.red {
  background: var(--accent-red-bg);
  color: var(--accent-red-text);
}

.badge.amber {
  background: var(--accent-amber-bg);
  color: var(--accent-amber-text);
}

.badge.blue {
  background: var(--accent-blue-bg);
  color: var(--accent-blue-text);
}

.steam-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-blue);
  text-decoration: none;
}

.steam-link:hover {
  text-decoration: underline;
}

/* Primary Metric Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.85rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.06);
}

.metric-card.highlight {
  border-left: 4px solid var(--accent-red);
}

.metric-card.highlight-amber {
  border-left: 4px solid var(--accent-amber);
}

.metric-card.highlight-blue {
  border-left: 4px solid var(--accent-blue);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-value {
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-main);
  line-height: 1;
}

.metric-value .unit {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.metric-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.metric-desc strong {
  color: var(--text-main);
}

/* Shifts Section */
.shifts-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.shifts-visual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 0.6rem;
}

.shift-pill {
  background: #f1f5f9;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  padding: 0.65rem 0.4rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.shift-pill.regular {
  background: var(--accent-blue-bg);
  border-color: #bfdbfe;
  color: var(--accent-blue-text);
}

.shift-pill.overtime {
  background: var(--accent-red-bg);
  border-color: #fecaca;
  color: var(--accent-red-text);
  font-weight: 700;
}

.shift-pill-num {
  font-size: 0.85rem;
  font-weight: 700;
}

.shift-pill-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  opacity: 0.85;
}

/* Funny "What Else Could Have Been Done" Section */
.fun-stats-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.fun-showcase-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  padding: 2rem 2.25rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fun-showcase-card:hover {
  box-shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.08);
}

.fun-card-main {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

.fun-card-icon {
  font-size: 2.75rem;
  line-height: 1;
  background: #f8fafc;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border-card);
  flex-shrink: 0;
}

.fun-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
}

.fun-card-category {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-blue-text);
  background: var(--accent-blue-bg);
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  display: inline-block;
  align-self: flex-start;
}

.fun-card-text {
  font-size: clamp(1.15rem, 2.2vw, 1.45rem);
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
}

.fun-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.25rem;
  border-top: 1px solid #f1f5f9;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.fun-counter {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.btn-next-fun {
  background: #0f172a;
  color: #ffffff;
  border: none;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: background 0.2s, transform 0.1s;
}

.btn-next-fun:hover {
  background: #1e293b;
  transform: translateY(-1px);
}

.btn-next-fun:active {
  transform: translateY(0);
}

/* Games Section */
.games-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.game-item {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
}

.game-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.08);
}

.game-banner-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  background: #e2e8f0;
  border-bottom: 1px solid var(--border-card);
}

.game-info {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.game-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.game-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.game-hours-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: var(--accent-red-bg);
  color: var(--accent-red-text);
}

.game-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding-top: 0.5rem;
  border-top: 1px solid #f1f5f9;
}

.game-stats b {
  color: var(--text-main);
}

/* Modal: Sync History */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-sheet {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-card);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-close-modal {
  background: #f1f5f9;
  border: none;
  font-size: 1.2rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
}

.btn-close-modal:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-summary {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.history-table-wrap {
  border: 1px solid var(--border-card);
  border-radius: 10px;
  overflow: hidden;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.82rem;
}

.history-table th {
  background: #f8fafc;
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-card);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.history-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-main);
}

.history-table tr:last-child td {
  border-bottom: none;
}

.history-table tr:hover td {
  background: #f8fafc;
}

.loc-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  color: #1e293b;
}

/* Footer */
.page-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 2rem;
  border-top: 1px solid var(--border-card);
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 1rem;
}

.page-footer a {
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
}

.page-footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 650px) {
  .container {
    padding: 2rem 1rem 4rem;
  }
  .top-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-actions-col {
    width: 100%;
    align-items: flex-start;
  }
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
}
