/* ============================================================================
   HAKHU ARCADE — CLEAN WHITE 3D THEME (MOBILE + PC RESPONSIVE)
   ============================================================================ */
:root {
  --bg: #f4f7fc;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #0ea5e9;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 12px 28px rgba(37, 99, 235, 0.10);
  --shadow-lg: 0 22px 48px rgba(15, 23, 42, 0.14);
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* Header */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
}

.nav-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
  border: 2px solid #fff;
}

.brand-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
}

.brand-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
}

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

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.uid-pill {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--primary-dark);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.uid-pill:hover {
  transform: translateY(-1px);
}

.cloud-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
}

.cloud-dot.local {
  background: var(--warning);
}

/* Main Container */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 16px 48px;
}

/* Hero Banner */
.hero-card {
  background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
  border: 1px solid #dbeafe;
  border-radius: 22px;
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.hero-text h1 {
  margin: 0 0 6px;
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero-text p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  max-width: 680px;
  line-height: 1.5;
}

.hero-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hero-badge {
  background: #fff;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

/* Monetag Ad Slot */
.ad-slot {
  background: #ffffff;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  padding: 10px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

/* Controls & Filter Bar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.18s ease;
}

.tab-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

.search-box {
  position: relative;
  flex: 1 1 240px;
  max-width: 320px;
}

.search-box input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  outline: none;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* 1:1 Ratio Game Cards Grid */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

@media (max-width: 540px) {
  .games-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}

.game-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  border-color: #93c5fd;
}

/* Strictly 1:1 Square Image Container */
.card-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #ffffff;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.card-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.game-card:hover .card-thumb-wrap img {
  transform: scale(1.05);
}

.card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  color: var(--primary-dark);
  border: 1px solid #dbeafe;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.08);
}

.mission-counter-badge {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(15, 23, 42, 0.85);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
}

.mission-counter-badge.all-done {
  background: var(--success);
}

.card-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
}

.card-meta {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.play-btn {
  width: 100%;
  border: none;
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 12px;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.22);
  transition: opacity 0.15s ease;
}

.play-btn:hover {
  opacity: 0.94;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.modal-backdrop.hidden {
  display: none !important;
}

/* Name Onboarding Card */
.welcome-modal {
  background: #ffffff;
  border-radius: 24px;
  max-width: 440px;
  width: 100%;
  padding: 26px 24px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  border: 1px solid var(--border);
}

.welcome-modal h2 {
  margin: 12px 0 6px;
  font-size: 22px;
  font-weight: 800;
}

.welcome-modal p {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.welcome-input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 14px;
  border: 2px solid var(--border);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  outline: none;
  margin-bottom: 14px;
  text-align: center;
}

.welcome-input:focus {
  border-color: var(--primary);
}

.primary-cta {
  width: 100%;
  padding: 13px 18px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.28);
}

/* Game Stage Modal */
.stage-modal {
  background: #ffffff;
  border-radius: 22px;
  width: 100%;
  max-width: 1120px;
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.stage-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #ffffff;
}

.stage-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stage-title-group h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.stage-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-soft {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 700;
  font-size: 12.5px;
  padding: 8px 12px;
  border-radius: 10px;
}

.btn-close {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: var(--danger);
  font-weight: 800;
  font-size: 12.5px;
  padding: 8px 14px;
  border-radius: 10px;
}

.stage-body {
  display: grid;
  grid-template-columns: 1fr 330px;
  overflow-y: auto;
  flex: 1;
}

@media (max-width: 900px) {
  .stage-body {
    grid-template-columns: 1fr;
  }
}

.game-arena {
  padding: 14px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 430px;
}

.game-hud-bar {
  width: 100%;
  max-width: 640px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
}

.game-mount {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.game-canvas {
  width: 100%;
  max-width: 560px;
  aspect-ratio: 4 / 3;
  background: #0f172a;
  border-radius: 16px;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.14);
  touch-action: none;
  display: block;
}

.controls-bar {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.touch-btn {
  min-width: 66px;
  min-height: 46px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font-weight: 800;
  font-size: 14px;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
  user-select: none;
}

.touch-btn:active {
  background: #eff6ff;
  transform: scale(0.96);
}

.controls-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  font-weight: 600;
}

/* Missions Sidebar */
.missions-panel {
  border-left: 1px solid var(--border);
  background: #ffffff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (max-width: 900px) {
  .missions-panel {
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

.missions-panel h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mission-card {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 14px;
  padding: 12px;
}

.mission-card.done {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.mission-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.mission-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.mission-pts {
  font-size: 11px;
  font-weight: 800;
  background: #eff6ff;
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 999px;
}

.mission-card.done .mission-pts {
  background: #dcfce7;
  color: var(--success);
}

.mission-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.progress-track {
  width: 100%;
  height: 7px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.25s ease;
}

.mission-card.done .progress-fill {
  background: var(--success);
}

.proof-btn {
  margin-top: 6px;
  width: 100%;
  border: 1px solid #16a34a;
  background: #16a34a;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
  border-radius: 10px;
}

/* Screenshot Proof Certificate Card */
.proof-modal {
  background: #ffffff;
  max-width: 440px;
  width: 100%;
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  border: 2px solid #16a34a;
}

.proof-certificate {
  background: linear-gradient(145deg, #ffffff 0%, #f0fdf4 100%);
  border: 2px dashed #16a34a;
  border-radius: 18px;
  padding: 18px;
  text-align: center;
}

.proof-seal {
  display: inline-block;
  background: #16a34a;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.proof-certificate h3 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 800;
}

.proof-rows {
  margin: 14px 0;
  text-align: left;
  background: #ffffff;
  border: 1px solid #dcfce7;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 12.5px;
}

.proof-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid #f1f5f9;
}

.proof-row:last-child {
  border-bottom: none;
}

.proof-row span:first-child {
  color: var(--text-muted);
  font-weight: 600;
}

.proof-row span:last-child {
  color: var(--text);
  font-weight: 800;
}

/* Board UI Helpers for Brain Games */
.board-wrap {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 460px;
}

.chess-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  border: 2px solid #1e293b;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
}

.chess-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(20px, 5vw, 32px);
  user-select: none;
  cursor: pointer;
  position: relative;
}

.chess-cell.light { background: #f8fafc; }
.chess-cell.dark { background: #93c5fd; }
.chess-cell.selected { background: #fde047 !important; }
.chess-cell.legal::after {
  content: "";
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.55);
  position: absolute;
}
.chess-cell.capture { box-shadow: inset 0 0 0 3px #ef4444; }

.sudoku-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  border: 2.5px solid #0f172a;
  aspect-ratio: 1 / 1;
  background: #ffffff;
}

.sudoku-cell {
  border: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(14px, 3.6vw, 19px);
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.sudoku-cell.b-right { border-right: 2.2px solid #0f172a; }
.sudoku-cell.b-bottom { border-bottom: 2.2px solid #0f172a; }
.sudoku-cell.fixed { background: #f1f5f9; color: #0f172a; }
.sudoku-cell.user-val { color: #2563eb; }
.sudoku-cell.selected { background: #dbeafe !important; }
.sudoku-cell.error { background: #fee2e2 !important; color: #dc2626; }
.sudoku-notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  font-size: 8px;
  color: #64748b;
  width: 100%;
  height: 100%;
  padding: 1px;
  line-height: 1;
  text-align: center;
}

.num-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.num-btn {
  padding: 10px 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-weight: 800;
  font-size: 14px;
  color: var(--text);
}

.num-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: #0f172a;
  color: #ffffff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
}

.toast.hidden { display: none; }
