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

html, body {
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* legacy IE/Edge */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;                /* Chrome / Safari / WebKit */
}

body {
  background: #000;
  color: #f2f2f2;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', 'Segoe UI', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#root { display: none; }

/* ── Page column ─────────────────────────────────────────────────────────── */
#page {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 24px 110px;
}

/* ── Scene banner (animated Goldwin Smith scene) ─────────────────────────── */
#scene-banner {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: 4px;
  background: #000;
  /* Match the heading→paragraph gap (the h2's 28px bottom margin) above the image. */
  margin-top: 28px;
}

#scene {
  position: absolute;
  inset: 0;
  background-image: url('background.png');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: default;
}

#bubbles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

/* ── Article (editable) ──────────────────────────────────────────────────── */
#about {
  margin-top: 48px;
}

#about h1,
#about h2 {
  font-weight: 700;
  font-size: clamp(24px, 3.8vw, 30px);
  letter-spacing: -0.02em;
  color: #fff;
  margin-bottom: 28px;
}

#about p {
  font-size: 17px;
  line-height: 1.85;
  color: #d8d8d8;
  margin-bottom: 22px;
}

#about a {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(255, 255, 255, 0.4);
  transition: text-decoration-color .15s;
}
#about a:hover { text-decoration-color: #fff; }

/* ── Links ───────────────────────────────────────────────────────────────── */
#links {
  margin-top: 56px;
}

#links h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8a8a8a;
  margin-bottom: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
}

#links ul {
  list-style: none;
}

#links li {
  font-size: 17px;
  line-height: 2;
}

#links a {
  color: #e8e8e8;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
  transition: color .15s, border-color .15s;
}
#links a:hover {
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.7);
}

/* ── Speech bubbles (creature hover popups) ──────────────────────────────── */
.speech-bubble {
  position: absolute;
  background: #fdf3d0;
  border: 3px solid #2a1200;
  padding: 10px 13px;
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(5px, 1.1vw, 8px);
  line-height: 2;
  color: #2a1200;
  max-width: 260px;
  min-width: 120px;
  z-index: 20;
  pointer-events: auto;
  box-shadow: 3px 3px 0 #2a1200;
  transform: translateX(-50%);
  animation: bubblePop 0.12s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  image-rendering: pixelated;
}

/* tail pointing down */
.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -11px;
  left: var(--tail-x, 50%);
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 11px solid #2a1200;
}

.speech-bubble::before {
  content: '';
  position: absolute;
  bottom: -7px;
  left: var(--tail-x, 50%);
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 9px solid #fdf3d0;
  z-index: 1;
}

/* tail pointing up (bubble displayed below the character) */
.speech-bubble.bubble-below { max-width: 110px; }

.speech-bubble.bubble-below::after {
  bottom: auto;
  top: -11px;
  left: var(--tail-x, 50%);
  border-top: none;
  border-bottom: 11px solid #2a1200;
}

.speech-bubble.bubble-below::before {
  bottom: auto;
  top: -7px;
  left: var(--tail-x, 50%);
  border-top: none;
  border-bottom: 9px solid #fdf3d0;
}

.speech-bubble a {
  color: #1a44cc;
  text-decoration: underline;
  font-family: inherit;
  font-size: inherit;
}
.speech-bubble a:hover { color: #cc2200; }

@keyframes bubblePop {
  0%   { transform: translateX(-50%) scale(0.4); opacity: 0; }
  100% { transform: translateX(-50%) scale(1);   opacity: 1; }
}

/* ── Blog page (shown when navigating to /blog) ──────────────────────────── */
#new-page {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 95;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
}

/* ── Blog listing ────────────────────────────────────────────────────────── */
#blog-listing {
  max-width: 640px;
  margin: 0 auto;
  padding: 96px 24px 80px;
}

.blog-heading {
  font-size: 36px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.025em;
  margin: 0 0 24px;
}

.article-item {
  padding: 28px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: opacity .15s;
}

.article-item:first-child { border-top: 1px solid rgba(255,255,255,0.08); }
.article-item:hover { opacity: .7; }

.article-item-title {
  font-size: 19px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -.01em;
  margin-bottom: 6px;
}

.article-item-meta {
  font-size: 13px;
  color: rgba(255,255,255,.38);
  margin-bottom: 10px;
}

.article-item-excerpt {
  font-size: 15px;
  color: rgba(255,255,255,.52);
  line-height: 1.6;
}

/* ── Article detail ──────────────────────────────────────────────────────── */
#article-view {
  display: none;
  max-width: 640px;
  margin: 0 auto;
  padding: 96px 24px 80px;
}

#article-back {
  display: inline-block;
  background: none;
  border: none;
  padding: 0;
  margin-bottom: 40px;
  font-family: inherit;
  font-size: 14px;
  color: rgba(255,255,255,.4);
  cursor: pointer;
  transition: color .15s;
  letter-spacing: .01em;
}
#article-back:hover { color: rgba(255,255,255,.9); }

#article-title {
  font-size: 34px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin: 0 0 14px;
}

#article-meta {
  font-size: 13px;
  color: rgba(255,255,255,.38);
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

#article-body {
  font-size: 17px;
  line-height: 1.8;
  color: rgba(255,255,255,.78);
}
#article-body p  { margin: 0 0 24px; }
#article-body h2 {
  font-size: 22px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -.01em;
  margin: 44px 0 16px;
}

#back-btn {
  position: absolute;
  top: 24px;
  left: 24px;
  width: 45px;
  height: 45px;
  padding: 0;
  /* Sprite sheet: 4 frames × 32px source, rendered at ~1.4× = 179×45px */
  background: url('Owlet_Monster_Idle_4.png') 0 0 no-repeat;
  background-size: 179px 45px;
  image-rendering: pixelated;
  border: 1.5px solid #555;
  border-radius: 6px;
  cursor: pointer;
  animation: owlet-idle 1.4s steps(4) infinite;
  transition: border-color .2s;
}

@keyframes owlet-idle {
  from { background-position:    0 0; }
  to   { background-position: -179px 0; }
}

#back-btn:hover { border-color: #aaa; }

/* ── KaTeX math rendering ─────────────────────────────────────────────────── */
#article-body .katex { color: rgba(255,255,255,.9); font-size: 1em; }
#article-body .katex-display {
  margin: 1.6em 0;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
}
#article-body .katex-display > .katex { display: inline-block; text-align: left; }
#article-body code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .88em;
  background: rgba(255,255,255,.08);
  padding: 2px 6px;
  border-radius: 4px;
}
#article-body blockquote {
  border-left: 3px solid rgba(255,255,255,.25);
  margin: 24px 0;
  padding: 4px 0 4px 20px;
  color: rgba(255,255,255,.55);
  font-style: italic;
}
#article-body h3 {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  margin: 32px 0 12px;
}
#article-body h4 {
  font-size: 15px;
  font-weight: 600;
  color: rgba(255,255,255,.8);
  margin: 24px 0 8px;
}
#article-body ul, #article-body ol {
  margin: 0 0 24px 24px;
  padding: 0;
}
#article-body li { margin-bottom: 8px; }
