/* ============================================================
   Connect Four — PlayStation Design System
   Roboto (display 300) + Inter (body/chrome)
   ============================================================ */

/* --- CSS Variables (Dark = default, Light = toggle) --- */
:root {
  --ps-blue: #0070d1;
  --ps-blue-pressed: #0064b7;
  --ps-blue-active: #004d8d;
  --commerce: #d53b00;
  --warning: #c81b3a;

  --bg: #000000;
  --bg-elevated: #121314;
  --bg-card: #181818;
  --bg-surface: #1f2024;
  --hairline: rgba(229,229,229,0.2);

  --text-primary: #ffffff;
  --text-body: rgba(255,255,255,0.7);
  --text-mute: rgba(229,229,229,0.55);
  --text-disabled: #cccccc;

  --link: #53b1ff;

  /* Game disc colors */
  --disc-p1: #d53b00;
  --disc-p2: #deff20;
  --disc-p1-glow: rgba(213,59,0,0.4);
  --disc-p2-glow: rgba(222,255,32,0.4);
  --board-bg: #0070d1;
  --board-cell: #000000;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-elevated: #f3f3f3;
  --bg-card: #f5f7fa;
  --bg-surface: #f3f3f3;
  --hairline: #f3f3f3;

  --text-primary: #000000;
  --text-body: rgba(0,0,0,0.6);
  --text-mute: #6b6b6b;
  --text-disabled: #cccccc;

  --link: #0064b7;

  --board-cell: #ffffff;
}

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

body {
  font-family: 'Inter', 'Helvetica', 'Arial', sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: 'Roboto', 'Inter', sans-serif;
  font-weight: 300;
  color: var(--text-primary);
  letter-spacing: 0.1px;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Global Header --- */
.global-header {
  background: var(--bg);
  height: 48px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--hairline);
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 16px; }

.logo {
  color: var(--ps-blue);
  font-family: 'Roboto', sans-serif;
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
  letter-spacing: 0.45px;
}

.breadcrumb { color: var(--text-mute); font-size: 14px; }
.breadcrumb a { color: var(--text-mute); }
.breadcrumb .sep { margin: 0 6px; }

.back-to-hub {
  color: var(--text-body);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.back-to-hub:hover { color: var(--text-primary); text-decoration: none; }

.theme-toggle {
  background: none;
  border: none;
  color: var(--text-body);
  font-size: 18px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
}
.theme-toggle:hover { color: var(--text-primary); }

/* --- Layout --- */
.layout {
  display: grid;
  grid-template-columns: 180px 1fr 320px;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.sidebar { position: sticky; top: 72px; align-self: start; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr 320px; }
  .sidebar--left { display: none; }
}

@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .sidebar--left, .sidebar--right { display: none; }
}

/* --- Ad Slots --- */
.ad-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-elevated);
  border-radius: 8px;
  overflow: hidden;
}

.ad-slot--inline { margin: 32px 0; display: none; }

@media (max-width: 768px) {
  .ad-slot--inline { display: flex; }
}

/* --- Hero Section --- */
.hero-section {
  padding: 48px 0 24px;
  text-align: center;
}

.hero-section h1 {
  font-size: 44px;
  font-weight: 300;
  line-height: 1.25;
  letter-spacing: 0.1px;
}

.subtitle {
  font-size: 18px;
  color: var(--text-body);
  margin-top: 12px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

/* --- Controls Bar / Auth --- */
.controls-bar {
  display: flex;
  justify-content: center;
  padding: 16px 0;
}

.auth-area { display: flex; align-items: center; gap: 12px; }

.btn-login {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--hairline);
  border-radius: 9999px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.324px;
  transition: background 0.15s;
}
.btn-login:hover { background: var(--bg-surface); }

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

.user-avatar { width: 28px; height: 28px; border-radius: 50%; }

.btn-logout {
  background: none;
  border: none;
  color: var(--text-mute);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
}
.btn-logout:hover { color: var(--warning); }

/* --- Mode Selector --- */
.mode-selector {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
}

.mode-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 20px;
}

.mode-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-mute);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.324px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.mode-tab--active {
  color: var(--ps-blue);
  border-bottom-color: var(--ps-blue);
}

.mode-panel { text-align: center; }

.difficulty-pills {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.pill {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: none;
  border-radius: 9999px;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.324px;
  cursor: pointer;
  transition: background 0.15s;
}

.pill--active {
  background: var(--ps-blue);
  color: #ffffff;
}

/* --- Buttons --- */
.btn-primary {
  background: var(--ps-blue);
  color: #ffffff;
  border: none;
  border-radius: 9999px;
  padding: 12px 28px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.45px;
  cursor: pointer;
  height: 48px;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--ps-blue-pressed); }
.btn-primary:active { background: var(--ps-blue-active); }
.btn-primary:disabled {
  background: var(--bg-surface);
  color: var(--text-disabled);
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--hairline);
  border-radius: 9999px;
  padding: 12px 28px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.45px;
  cursor: pointer;
  height: 48px;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover { border-color: var(--ps-blue); color: var(--ps-blue); }

.btn-secondary--danger:hover { border-color: var(--warning); color: var(--warning); }

/* --- Online Actions --- */
.online-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.join-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-code {
  background: var(--bg);
  color: var(--text-primary);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 12px 16px;
  font-size: 18px;
  font-weight: 400;
  width: 200px;
  height: 48px;
  text-align: center;
  letter-spacing: 4px;
  font-family: 'Inter', sans-serif;
}

.input-code:focus {
  outline: none;
  border: 2px solid var(--ps-blue);
}

.online-note {
  font-size: 14px;
  color: var(--text-mute);
  margin-top: 8px;
  min-height: 20px;
}

/* --- Game Info Bar --- */
.game-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-card);
  border-radius: 8px;
  margin-bottom: 16px;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
}

.disc {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-block;
}

.disc--p1 { background: var(--disc-p1); box-shadow: 0 0 8px var(--disc-p1-glow); }
.disc--p2 { background: var(--disc-p2); box-shadow: 0 0 8px var(--disc-p2-glow); }

.turn-display {
  font-family: 'Roboto', sans-serif;
  font-weight: 300;
  font-size: 22px;
  color: var(--text-primary);
  letter-spacing: 0.1px;
}

.timer-display {
  font-size: 18px;
  font-weight: 700;
  color: var(--ps-blue);
  min-width: 50px;
  text-align: center;
}

.timer-display.timer--warning { color: var(--warning); }

/* --- Game Board --- */
.board-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.board-top {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  width: 100%;
  max-width: 490px;
  height: 40px;
}

.board-top .preview-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-disc {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s;
}

.preview-disc.visible { opacity: 0.5; }

.board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  background: var(--board-bg);
  border-radius: 8px;
  padding: 10px;
  width: 100%;
  max-width: 490px;
  aspect-ratio: 7 / 6;
}

.cell {
  background: var(--board-cell);
  border-radius: 50%;
  aspect-ratio: 1;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s;
}

.cell:hover { transform: scale(1.05); }
.cell[data-value="0"] { background: var(--board-cell); }

.cell[data-value="1"] {
  background: var(--disc-p1);
  box-shadow: inset 0 -3px 6px rgba(0,0,0,0.3), 0 0 12px var(--disc-p1-glow);
}

.cell[data-value="2"] {
  background: var(--disc-p2);
  box-shadow: inset 0 -3px 6px rgba(0,0,0,0.2), 0 0 12px var(--disc-p2-glow);
}

.cell.winning {
  animation: pulse 0.6s ease-in-out infinite alternate;
}

@keyframes pulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.1); }
}

@keyframes drop {
  0% { transform: translateY(-400%); opacity: 0.5; }
  60% { transform: translateY(5%); opacity: 1; }
  80% { transform: translateY(-3%); }
  100% { transform: translateY(0); opacity: 1; }
}

.cell.dropping {
  animation: drop 0.35s ease-out forwards;
}

.cell.disabled { cursor: not-allowed; pointer-events: none; }

/* --- Game Controls --- */
.game-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}

/* --- Result Overlay --- */
.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.result-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 48px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.result-title {
  font-size: 35px;
  font-weight: 300;
  margin-bottom: 12px;
}

.result-detail {
  font-size: 16px;
  color: var(--text-body);
  margin-bottom: 32px;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* --- Leaderboard --- */
.leaderboard-section {
  margin: 32px 0;
}

.leaderboard-section h2 {
  font-size: 28px;
  margin-bottom: 16px;
}

.leaderboard-table-wrap {
  overflow-x: auto;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.leaderboard-table thead th {
  color: var(--text-mute);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 12px;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
}

.leaderboard-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--hairline);
  color: var(--text-primary);
}

.leaderboard-table tbody tr:hover {
  background: var(--bg-elevated);
}

.lb-empty {
  text-align: center;
  color: var(--text-mute);
  padding: 24px !important;
}

.lb-rank {
  font-weight: 700;
  color: var(--ps-blue);
  width: 40px;
}

.lb-name { font-weight: 500; }

.lb-rating {
  font-weight: 700;
  color: var(--ps-blue);
}

/* --- Educational Content --- */
.content-section {
  margin: 48px 0;
}

.content-section section {
  margin-bottom: 40px;
}

.content-section h2 {
  font-size: 28px;
  font-weight: 300;
  margin-bottom: 16px;
  letter-spacing: 0.1px;
}

.content-section p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-body);
  margin-bottom: 12px;
}

.content-section strong { color: var(--text-primary); font-weight: 600; }

/* --- FAQ --- */
.faq-section details {
  border-bottom: 1px solid var(--hairline);
}

.faq-section summary {
  padding: 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.faq-section summary::after {
  content: '+';
  font-size: 20px;
  font-weight: 300;
  color: var(--text-mute);
  transition: transform 0.2s;
}

.faq-section details[open] summary::after {
  content: '-';
}

.faq-answer {
  padding: 0 0 16px;
}

.faq-answer p {
  font-size: 15px;
  color: var(--text-body);
  line-height: 1.6;
}

/* --- Cross Links --- */
.cross-links {
  padding: 48px 0;
  border-top: 1px solid var(--hairline);
}

.cross-links h2 {
  font-size: 28px;
  font-weight: 300;
  margin-bottom: 24px;
}

.cross-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.cross-link-card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 24px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: background 0.15s;
}

.cross-link-card:hover { background: var(--bg-surface); text-decoration: none; }

.cross-link-icon { font-size: 32px; }
.cross-link-name { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.cross-link-desc { font-size: 14px; color: var(--text-body); }

/* --- Footer --- */
.global-footer {
  background: var(--ps-blue);
  padding: 32px;
  text-align: center;
  color: #ffffff;
  font-size: 14px;
}

.footer-links { margin-bottom: 12px; }

.footer-links a {
  color: rgba(255,255,255,0.85);
  margin: 0 16px;
  text-decoration: none;
  font-size: 14px;
}

.footer-links a:hover { color: #ffffff; text-decoration: underline; }

.footer-copyright { color: rgba(255,255,255,0.6); font-size: 12px; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .global-header { padding: 0 16px; }
  .breadcrumb { display: none; }

  .hero-section { padding: 32px 0 16px; }
  .hero-section h1 { font-size: 32px; }
  .subtitle { font-size: 16px; }

  .board { max-width: 100%; gap: 4px; padding: 6px; }
  .board-top { max-width: 100%; }

  .mode-selector { padding: 16px; }

  .game-info { padding: 12px 16px; flex-wrap: wrap; gap: 8px; justify-content: center; }
  .turn-display { font-size: 18px; width: 100%; text-align: center; order: -1; }

  .result-card { padding: 32px 24px; }
  .result-title { font-size: 28px; }

  .cross-links-grid { grid-template-columns: repeat(2, 1fr); }

  .content-section h2 { font-size: 22px; }

  .game-controls { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .hero-section h1 { font-size: 28px; }
  .board { gap: 3px; padding: 4px; }
  .join-row { flex-direction: column; }
  .input-code { width: 100%; }
}
