:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #eaeaea;
  --primary: #ff6b35;
  --primary-hover: #e55a2b;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, .12);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --text: #f5f5f5;
    --text-muted: #999;
    --border: #2a2a2a;
    --shadow: 0 1px 3px rgba(0, 0, 0, .3);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, .5);
  }
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- header ---------- */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(10px);
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
  color: var(--text);
}
.logo-mark { font-size: 22px; }

.lang-switcher { display: flex; gap: 4px; }
.lang-switcher button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all .15s ease;
}
.lang-switcher button:hover { border-color: var(--text-muted); }
.lang-switcher button.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ---------- hero / homepage ---------- */
.hero {
  text-align: center;
  padding: 64px 20px 40px;
}
.hero h1 {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.hero p {
  color: var(--text-muted);
  font-size: 17px;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  padding-bottom: 60px;
}

.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  text-decoration: none;
  color: var(--text);
  transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s ease, border-color .25s ease;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.game-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, .14);
  border-color: transparent;
}

.game-card-preview {
  height: 140px;
  background: linear-gradient(135deg, var(--accent-1, #888) 0%, var(--accent-2, #444) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.game-card-preview::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .25) 0, transparent 45%),
    radial-gradient(circle at 80% 90%, rgba(0, 0, 0, .18) 0, transparent 50%);
  pointer-events: none;
}
.game-card-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(rgba(255, 255, 255, .12) 1px, transparent 1.2px);
  background-size: 14px 14px;
  background-position: 0 0;
  opacity: .6;
  pointer-events: none;
}
.game-card-emoji {
  font-size: 60px;
  line-height: 1;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .25));
  transition: transform .3s cubic-bezier(.2, 1.4, .4, 1);
}
.game-card:hover .game-card-emoji {
  transform: scale(1.12) rotate(-4deg);
}

.game-card-body {
  padding: 16px 18px 18px;
}
.game-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.game-card p {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}

footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- shared game page ---------- */
.game-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  gap: 14px;
}
.game-header {
  width: 100%;
  max-width: 500px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.back-link {
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background .15s ease;
}
.back-link:hover { background: var(--border); }
.game-title {
  font-size: 17px;
  font-weight: 700;
}

.btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s ease, transform .1s ease;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: scale(.97); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--border); }

.scores {
  display: flex;
  gap: 8px;
}
.score-box {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  text-align: center;
  min-width: 76px;
}
.score-box .label {
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}
.score-box .value {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}

.hint {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  margin-top: 4px;
}

/* ---------- modal overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 20px;
}
.overlay.show { display: flex; }
.overlay-card {
  background: var(--surface);
  padding: 32px 28px;
  border-radius: 14px;
  text-align: center;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.overlay-card h2 {
  margin-bottom: 8px;
  font-size: 22px;
}
.overlay-card p {
  margin-bottom: 22px;
  color: var(--text-muted);
}

/* ---------- ad slot placeholder ---------- */
.ad-slot {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  margin: 16px auto;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ---------- header right cluster ---------- */
.header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-decoration: none;
  font-size: 17px;
  transition: background .15s, border-color .15s;
  cursor: pointer;
  position: relative;
}
.icon-link:hover { background: var(--border); }
.icon-link.hidden { display: none; }
.icon-link .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 5px;
  line-height: 1.4;
  min-width: 14px;
  text-align: center;
}

/* ---------- daily challenge banner (game pages) ---------- */
.daily-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #ff8a3d 0%, #ff5a4a 100%);
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(255, 90, 74, .35);
  letter-spacing: .02em;
}
.daily-banner-cd {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  opacity: .9;
  font-size: 12px;
  background: rgba(0, 0, 0, .15);
  padding: 2px 8px;
  border-radius: 999px;
}
.daily-dot {
  filter: drop-shadow(0 0 6px rgba(255, 230, 200, .6));
}

/* ---------- daily section on homepage ---------- */
.daily-section {
  margin: 0 0 28px;
  background: linear-gradient(135deg, #fff7ed 0%, #ffe4c4 100%);
  border-radius: 18px;
  padding: 22px 24px;
  box-shadow: 0 6px 18px rgba(255, 107, 53, .08);
  position: relative;
  overflow: hidden;
}
@media (prefers-color-scheme: dark) {
  .daily-section {
    background: linear-gradient(135deg, #2a1f12 0%, #1a1208 100%);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
  }
}
.daily-section::before {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255, 138, 61, .25), transparent 70%);
  pointer-events: none;
}
.daily-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}
.daily-header h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.daily-cd {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.daily-featured {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  transition: transform .2s ease, box-shadow .2s ease;
}
.daily-featured:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .08);
}
.daily-featured-emoji {
  font-size: 56px;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-1, #ff8a3d) 0%, var(--accent-2, #ff5a4a) 100%);
  border-radius: 12px;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .15));
}
.daily-featured-body {
  flex: 1;
  min-width: 0;
}
.daily-featured-body h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 2px;
}
.daily-featured-body p {
  font-size: 13px;
  color: var(--text-muted);
}
.daily-featured-cta {
  background: var(--primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.daily-featured-cta.done {
  background: #4caf50;
}

/* tick badge on game cards when today's challenge done */
.game-card-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(76, 175, 80, .95);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}

/* ---------- achievement toast ---------- */
.ach-toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #2c1f48 0%, #1a1226 100%);
  color: #fff;
  padding: 12px 18px 12px 14px;
  border-radius: 12px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, .35);
  border: 1px solid rgba(255, 215, 0, .4);
  transform: translateX(120%);
  transition: transform .35s cubic-bezier(.2, 1.2, .4, 1);
  max-width: 320px;
}
.ach-toast.show { transform: translateX(0); }
.ach-toast-icon {
  font-size: 32px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffd700 0%, #ff9800 100%);
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(255, 152, 0, .4);
}
.ach-toast-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #ffd700;
  margin-bottom: 2px;
}
.ach-toast-name {
  font-size: 15px;
  font-weight: 700;
}
@media (max-width: 600px) {
  .ach-toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}

/* ---------- achievements page ---------- */
.ach-page-head {
  text-align: center;
  padding: 50px 20px 30px;
}
.ach-page-head h1 {
  font-size: clamp(26px, 5vw, 38px);
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.ach-page-head p { color: var(--text-muted); }

.ach-progress {
  max-width: 400px;
  margin: 18px auto 0;
}
.ach-progress-bar {
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}
.ach-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffd700 0%, #ff9800 100%);
  border-radius: 999px;
  transition: width .6s cubic-bezier(.2, .8, .2, 1);
  box-shadow: 0 0 8px rgba(255, 152, 0, .4);
}
.ach-progress-label {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding-bottom: 60px;
}
.ach-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform .2s, box-shadow .2s;
}
.ach-card.unlocked {
  background: linear-gradient(135deg, var(--surface) 0%, rgba(255, 215, 0, .08) 100%);
  border-color: rgba(255, 152, 0, .35);
  box-shadow: 0 4px 14px rgba(255, 152, 0, .12);
}
.ach-card.unlocked:hover {
  transform: translateY(-2px);
}
.ach-card.locked {
  opacity: .5;
  filter: grayscale(.5);
}
.ach-card-icon {
  font-size: 36px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffd700 0%, #ff9800 100%);
  border-radius: 12px;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(255, 152, 0, .25);
}
.ach-card.locked .ach-card-icon {
  background: var(--border);
  box-shadow: none;
  filter: grayscale(1);
}
.ach-card-body { flex: 1; min-width: 0; }
.ach-card-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}
.ach-card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ---------- share modal ---------- */
.share-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity .2s;
  z-index: 9000;
}
.share-overlay.show { opacity: 1; }
.share-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 22px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.share-card h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 14px;
}
.share-preview {
  background: #f5f5f5;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
}
.share-preview canvas {
  width: 100%;
  height: auto;
  display: block;
}
.share-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}
.share-actions .btn { padding: 8px 14px; font-size: 13px; }

/* ---------- share button on overlay ---------- */
.overlay-card .share-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn-share {
  background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
  color: #fff;
}
.btn-share:hover { filter: brightness(1.08); }
