:root {
  --bg: #0d0d12;
  --surface: #16161e;
  --surface-2: #1f1f2a;
  --line: #2b2b38;
  --text: #f5f5f8;
  --muted: #a3a3b6;
  --pink: #ff3d6e;
  --yellow: #ffd23f;
  --cyan: #3dd9ff;
  --radius: 18px;
  --header-h: 60px;
  --gutter: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Apple SD Gothic Neo", "Noto Sans KR",
    "Hiragino Sans", "Noto Sans JP", "Malgun Gothic", "Yu Gothic", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; border-radius: 6px; }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(var(--gutter), env(safe-area-inset-left));
  background: rgba(13, 13, 18, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-weight: 900;
  font-size: 21px;
  letter-spacing: -0.04em;
}
.logo-mark { width: 30px; height: 30px; }

.lang-menu { position: relative; }
.lang-menu summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu[open] summary, .lang-menu summary:hover { color: var(--text); border-color: #444456; }
.globe {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-radius: 50%;
  position: relative;
}
.globe::after {
  content: "";
  position: absolute;
  inset: -2px 3px;
  border: 2px solid currentColor;
  border-radius: 50%;
}
.lang-menu ul {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  margin: 0;
  padding: 6px;
  list-style: none;
  min-width: 160px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.lang-menu li a {
  display: block;
  padding: 9px 12px;
  border-radius: 9px;
  text-decoration: none;
  font-weight: 600;
}
.lang-menu li a:hover { background: var(--line); }
.lang-menu li a[aria-current="true"] { color: var(--yellow); }

/* ---------- shared ---------- */
main { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 var(--gutter); }
.kicker {
  display: inline-block;
  margin: 0 0 14px;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--yellow);
  color: #141414;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.section { margin: 40px 0; }
.section-title { font-size: 22px; margin: 0 0 16px; }
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: var(--line); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--pink); border-color: var(--pink); color: #fff; }
.btn-primary:hover { background: #ff5a84; }
.icon { width: 18px; height: 18px; flex: none; }

/* ---------- home ---------- */
.hero { padding: 44px 0 8px; }
.hero h1 {
  /* break Korean at spaces and Japanese at the zero-width spaces in the copy, never mid-word */
  word-break: keep-all;
  text-wrap: balance;
  margin: 0;
  font-size: clamp(36px, 8vw, 72px);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 1.04;
}
.hero-sub { max-width: 560px; margin: 18px 0 0; color: var(--muted); font-size: 18px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 12px;
}
@media (min-width: 640px) { .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .card-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 24px 16px; } }
.card { text-decoration: none; display: flex; flex-direction: column; gap: 4px; }
.card-thumb {
  position: relative;
  display: block;
  aspect-ratio: 9 / 16;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-accent, var(--surface-2));
  margin-bottom: 6px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card:hover .card-thumb { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5); }
.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--pink);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
}
.card-title { font-weight: 800; font-size: 16px; line-height: 1.3; }
.card-tagline {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.about-block { max-width: 720px; color: var(--muted); }
.about-block .section-title { color: var(--text); }

/* ---------- game page ---------- */
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  padding-top: 16px;
}
.stage-col { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.stage {
  position: relative;
  width: 100%;
  /* leave room for the score bar and a peek of the title, so people know they can scroll */
  height: calc(100svh - var(--header-h) - 150px);
  min-height: 440px;
  max-height: 860px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 1px var(--line), 0 30px 60px -30px var(--accent, var(--pink));
}
.stage iframe { display: block; width: 100%; height: 100%; border: 0; }
.stage-close {
  display: none;
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.stage-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}
.best-box {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  margin-right: auto;
  padding-left: 4px;
}
.best-box span { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.best-box strong { font-size: 22px; font-weight: 900; color: var(--yellow); font-variant-numeric: tabular-nums; }
@media (max-width: 480px) {
  .stage-bar .btn:not(.btn-primary) span { display: none; }
  .stage-bar .btn:not(.btn-primary) { width: 44px; padding: 0; }
}

/* in-page full screen (works everywhere, incl. iPhone) */
body.is-playing { overflow: hidden; }
body.is-playing .stage {
  position: fixed;
  inset: 0;
  z-index: 100;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  min-height: 0;
  border-radius: 0;
}
body.is-playing .stage-close, .stage:fullscreen .stage-close { display: block; }
.stage:fullscreen { width: 100vw; height: 100vh; max-height: none; border-radius: 0; }

/* iPad and up: the game gets the full width and nearly the full screen height; text follows below */
@media (min-width: 768px) {
  .game-layout { gap: 28px; padding-top: 20px; }
  .stage {
    height: calc(100svh - var(--header-h) - 96px);
    min-height: 560px;
    max-height: 1000px;
  }
  .stage-bar { max-width: 100%; }
  .game-article { margin: 0 auto; width: 100%; }
}

.game-article { max-width: 680px; }
.game-article h1 { font-size: clamp(30px, 5vw, 44px); font-weight: 900; margin: 0 0 8px; }
.game-article .kicker { background: var(--surface-2); color: var(--cyan); font-weight: 700; }
.lede { font-size: 19px; color: var(--muted); margin: 0 0 24px; }
.game-article h2 { font-size: 22px; margin: 32px 0 10px; }
.game-article p, .game-article li { color: #d6d6e0; }
.game-article ol, .game-article ul { padding-left: 22px; }
.game-article li { margin: 6px 0; }
.meta-line { margin-top: 32px; font-size: 14px; color: var(--muted) !important; }

.source-card {
  margin: 28px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.source-card h2 { margin: 0 0 12px; font-size: 18px; }
.yt-facade {
  position: relative;
  display: block;
  width: min(100%, 280px);
  aspect-ratio: 9 / 16;
  padding: 0;
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  cursor: pointer;
}
.yt-facade.is-landscape { width: 100%; aspect-ratio: 16 / 9; }
.yt-facade img { width: 100%; height: 100%; object-fit: cover; opacity: 0.85; }
.yt-facade iframe { width: 100%; height: 100%; border: 0; }
.yt-play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 61, 110, 0.95);
}
.yt-play::after {
  content: "";
  position: absolute;
  left: 26px;
  top: 20px;
  border-style: solid;
  border-width: 12px 0 12px 20px;
  border-color: transparent transparent transparent #fff;
}
.post-facade {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(100%, 420px);
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #000;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.post-facade:hover { border-color: var(--cyan); }
.post-x { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: #fff; color: #000; font-size: 22px; font-weight: 900; }
.post-text { display: flex; flex-direction: column; gap: 2px; }
.post-text strong { font-size: 16px; }
.post-text small { font-size: 13px; color: var(--muted); }
.post-embed { max-width: 550px; min-height: 120px; }
.post-embed .twitter-tweet { margin: 0 !important; }
.source-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 12px 0 0; font-size: 15px; }
.source-by { color: var(--muted); }
.source-link { color: var(--cyan); font-weight: 700; text-decoration: none; }
.source-link:hover { text-decoration: underline; }

.ad-slot { margin: 24px 0; min-height: 100px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 200;
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- text pages ---------- */
.prose-page { max-width: 760px; padding-top: 40px; padding-bottom: 40px; }
.prose h1 { font-size: clamp(30px, 6vw, 44px); font-weight: 900; margin: 0 0 20px; }
.prose h2 { font-size: 21px; margin: 32px 0 8px; }
.prose p, .prose li { color: #d6d6e0; }
.prose a, .game-article a:not(.btn):not(.source-link) { color: var(--cyan); }
.prose code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 0.92em; }
.contact-email { font-size: 22px; font-weight: 800; }
.not-found h1 { font-size: clamp(28px, 6vw, 44px); font-weight: 900; }
.not-found .card-grid { margin-top: 32px; }
.chooser-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.chooser-list a {
  display: block;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-decoration: none;
  font-weight: 700;
  font-size: 18px;
}

/* ---------- footer ---------- */
.site-footer {
  max-width: 1200px;
  margin: 56px auto 0;
  padding: 28px var(--gutter) max(36px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 12px; }
.footer-links a { text-decoration: none; font-weight: 600; color: var(--text); }
.footer-links a:hover { text-decoration: underline; }
.footer-note { max-width: 640px; margin: 0 0 6px; }
.footer-copy { margin: 0; }
