:root {
  --bg: #0f1420;
  --bg-card: #1a2233;
  --bg-card-hover: #232f47;
  --text: #e8ecf4;
  --text-dim: #9aa5bd;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --border: #2a3650;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.site-header {
  background: rgba(15, 20, 32, 0.95);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(8px);
}
.header-inner {
  max-width: 1100px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.site-logo { font-size: 1.35rem; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 8px; }
.site-logo:hover { text-decoration: none; }
.site-logo .logo-badge {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 10px; padding: 2px 10px; font-size: 1rem;
}
.main-nav { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.main-nav a { color: var(--text-dim); font-size: 0.95rem; }
.main-nav a:hover, .main-nav a.active { color: var(--text); text-decoration: none; }
.lang-switch { border: 1px solid var(--border); border-radius: 6px; padding: 2px 10px; font-size: 0.85rem; }
.lang-select {
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; font-size: 0.85rem; cursor: pointer;
}
.lang-select:hover { border-color: var(--accent); }

/* Main */
main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 48px; width: 100%; flex: 1; }
.hero { text-align: center; padding: 36px 0 24px; }
.hero h1 { font-size: 2rem; margin-bottom: 8px; }
.hero p { color: var(--text-dim); font-size: 1.05rem; }
.section-title { font-size: 1.3rem; margin: 32px 0 16px; display: flex; align-items: center; gap: 10px; }

/* Ad slots */
.ad-slot {
  margin: 20px auto; display: flex; justify-content: center; align-items: center;
  min-height: 90px; max-width: 100%;
}
.ad-slot.rect { min-height: 250px; }
.ad-placeholder {
  width: 100%; max-width: 728px; height: 90px;
  border: 2px dashed var(--border); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 0.85rem; letter-spacing: 2px;
}
.ad-placeholder.rect { max-width: 300px; height: 250px; }

/* Game grid */
.game-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.game-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; transition: transform 0.15s, background 0.15s;
  display: flex; flex-direction: column;
}
.game-card:hover { transform: translateY(-4px); background: var(--bg-card-hover); text-decoration: none; }
.game-thumb {
  aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
  font-size: 3rem; font-weight: 800; position: relative;
  background: linear-gradient(135deg, #1c2a44, #2a1c44);
}
.game-thumb .cat-emoji { position: absolute; top: 8px; left: 10px; font-size: 1.1rem; opacity: 0.8; }
.game-info { padding: 10px 12px; }
.game-title { color: var(--text); font-weight: 700; font-size: 0.98rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-desc { color: var(--text-dim); font-size: 0.8rem; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Category chips */
.chip-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.chip {
  padding: 6px 16px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text-dim); font-size: 0.9rem; background: var(--bg-card);
}
.chip:hover, .chip.active { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; }

/* Game page */
.game-page h1 { font-size: 1.6rem; margin-bottom: 4px; }
.game-meta { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 16px; display: flex; gap: 14px; flex-wrap: wrap; }
.game-frame-wrap {
  background: #000; border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; position: relative; width: 100%;
  min-height: 600px; /* iframe is display:none until Play is clicked; keep the area visible */
}
.game-frame-wrap iframe { width: 100%; height: 600px; border: 0; display: block; }
.fs-btn {
  position: absolute; bottom: 10px; right: 10px; z-index: 10;
  background: rgba(0,0,0,0.65); color: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 0.85rem;
}
.fs-btn:hover { background: var(--accent); }
.game-desc-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; margin-top: 20px; }
.game-desc-box h2 { font-size: 1.1rem; margin-bottom: 8px; }
.license-note { color: var(--text-dim); font-size: 0.8rem; margin-top: 12px; }

/* Static pages */
.static-page h1 { font-size: 1.7rem; margin-bottom: 16px; }
.static-page h2 { font-size: 1.2rem; margin: 24px 0 8px; }
.static-page p { margin-bottom: 12px; color: var(--text-dim); }
.static-page ul { margin: 0 0 12px 24px; color: var(--text-dim); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 24px 20px; text-align: center; color: var(--text-dim); font-size: 0.85rem; }
.site-footer nav { display: flex; gap: 18px; justify-content: center; margin-bottom: 10px; flex-wrap: wrap; }
.site-footer a { color: var(--text-dim); }

@media (max-width: 600px) {
  .hero h1 { font-size: 1.5rem; }
  .game-frame-wrap { min-height: 70vh; }
  .game-frame-wrap iframe { height: 70vh; }
  .header-inner { gap: 10px; }
  .main-nav { margin-left: 0; }
}

/* --- Monetization & UX additions (balanced plan) --- */

/* Random game button */
.random-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff; border: 0; border-radius: 999px; padding: 10px 22px;
  font-size: 1rem; font-weight: 700; cursor: pointer; margin: 8px 0;
}
.random-btn:hover { transform: translateY(-2px); text-decoration: none; color: #fff; }

/* Game cover (click-to-play) */
.game-cover {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #1c2a44, #0a0e18);
}
.play-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: 0; border-radius: 12px; padding: 14px 44px;
  font-size: 1.3rem; font-weight: 800; cursor: pointer;
}
.play-btn:hover { transform: scale(1.05); }

/* Loading ad overlay (inside game area only) */
.loader-overlay {
  position: absolute; inset: 0; z-index: 8;
  background: rgba(10, 14, 24, 0.96);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}
.loader-overlay.hidden { display: none; }
.loader-close {
  position: absolute; top: 8px; right: 10px;
  background: none; border: 0; color: var(--text-dim); font-size: 1.4rem; cursor: pointer;
}
.loader-spinner {
  width: 34px; height: 34px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Keyboard notice (touch devices only, via JS) */
.kb-notice {
  display: none; align-items: center; gap: 8px;
  background: #3a2f14; border: 1px solid #8a6d1f; color: #ffd97a;
  border-radius: 10px; padding: 10px 16px; margin: 14px 0; font-size: 0.95rem;
}

/* Mobile sticky bottom banner */
#mobileAdBar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + 20px); /* 20px anti-misclick clearance */
  justify-content: center; align-items: center;
}
#mobileAdBar .ma-close {
  position: absolute; top: -14px; right: 8px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 50%;
  width: 28px; height: 28px; color: var(--text); cursor: pointer; font-size: 1rem; line-height: 1;
}
@media (max-width: 768px) {
  #mobileAdBar.visible { display: flex; }
  body.has-mobile-ad { padding-bottom: 96px; }
}
