/* Firefly Fields: theme vườn đêm (màu lấy từ DESIGN.md của game) */
@font-face { font-family: "Fraunces"; src: url("../fonts/Fraunces-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("../fonts/Nunito-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("../fonts/Nunito-ExtraBold.ttf") format("truetype"); font-weight: 800; font-display: swap; }

:root {
  --night-center: #1b2250;
  --night-edge: #070a1e;
  --modal: #10153a;
  --line: #2e3a6e;
  --glass: rgba(16, 21, 58, 0.72);
  --text: #eef0ff;
  --muted: #a9b0d6;
  --gold: #ffd24a;
  --gold-soft: #fff2a8;
  --gold-ink: #2a1a04;
  --grass: #3e6b3a;
  --lit: #ffe08a;
  --green: #9be36d;
  --teal: #5fd7c8;
  --radius: 22px;
  --wrap: 1080px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 700;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--night-edge);
  background-image: radial-gradient(ellipse at 50% 0%, var(--night-center) 0%, #0d1236 45%, var(--night-edge) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* bầu trời: sao + đom đóm (main.js vẽ vào canvas) */
#sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
.wrap { width: min(100% - 32px, var(--wrap)); margin-inline: auto; }

h1, h2, h3, .display {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  line-height: 1.15;
  color: #fff6dc;
  text-shadow: 0 0 18px rgba(255, 210, 74, 0.35), 0 2px 0 rgba(0, 0, 0, 0.35);
}
.eyebrow {
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- header / footer ---------- */
.site-header { position: sticky; top: 0; z-index: 10; backdrop-filter: blur(10px); background: rgba(7, 10, 30, 0.55); border-bottom: 1px solid rgba(46, 58, 110, 0.6); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-family: "Fraunces", serif; font-size: 1.2rem; }
.brand:hover { text-decoration: none; }
.brand img { width: 36px; height: 36px; border-radius: 9px; }
.nav { display: flex; gap: 20px; font-weight: 800; font-size: 0.95rem; }
.nav a { color: var(--muted); }
.nav a:hover, .nav a[aria-current="page"] { color: var(--gold); text-decoration: none; }

.site-footer { margin-top: 72px; padding: 28px 0 40px; border-top: 1px solid rgba(46, 58, 110, 0.6); color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 18px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover, .site-footer a[aria-current="page"] { color: var(--gold); }

/* ---------- nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 26px; border-radius: 16px;
  font-weight: 800; font-size: 1.02rem; letter-spacing: 0.04em;
  border: 1px solid transparent; cursor: pointer;
}
.btn:hover { text-decoration: none; }
.btn-gold {
  color: var(--gold-ink);
  background: linear-gradient(180deg, #ffe680 0%, var(--gold) 55%, #f0b62e 100%);
  box-shadow: 0 0 28px rgba(255, 210, 74, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-gold:hover { transform: translateY(-1px); box-shadow: 0 0 40px rgba(255, 210, 74, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
.btn-glass { color: var(--text); background: var(--glass); border-color: var(--line); }
.btn svg { width: 22px; height: 22px; }

/* ---------- trang chủ ---------- */
.hero { padding: 64px 0 40px; text-align: center; }
.hero-icon {
  width: 132px; height: 132px; margin: 0 auto 22px; border-radius: 30px;
  box-shadow: 0 0 60px rgba(255, 210, 74, 0.35), 0 10px 30px rgba(0, 0, 0, 0.5);
}
.hero h1 { font-size: clamp(2.6rem, 7vw, 4.4rem); margin: 0; }
.hero .tagline { margin: 10px 0 0; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; font-weight: 800; font-size: 0.9rem; }
.hero .lead { max-width: 640px; margin: 22px auto 30px; font-size: 1.15rem; color: #d7dbf5; }
.hero .cta, .closing .cta { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

.shots { display: flex; gap: 18px; padding: 26px 0 8px; overflow-x: auto; scroll-snap-type: x mandatory; }
/* canh giữa khi vừa khung, cuộn được từ ảnh đầu khi tràn (justify-content: center cắt mất phần đầu) */
.shots figure:first-child { margin-left: auto; }
.shots figure:last-child { margin-right: auto; }
.shots figure { margin: 0; flex: 0 0 auto; scroll-snap-align: center; }
.shots img {
  width: 220px; border-radius: 26px; border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}
.shots figure:nth-child(1) img { box-shadow: 0 0 46px rgba(95, 215, 200, 0.35), 0 18px 40px rgba(0, 0, 0, 0.5); }
.shots figcaption { margin-top: 10px; text-align: center; color: var(--muted); font-size: 0.85rem; }

section { padding: 56px 0 0; }
section > .wrap > h2 { font-size: clamp(1.8rem, 4vw, 2.4rem); text-align: center; margin: 6px 0 28px; }
section > .wrap > .eyebrow { text-align: center; }

.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }
.card {
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; backdrop-filter: blur(6px);
}
.card h3 { margin: 12px 0 6px; font-size: 1.3rem; }
.card p { margin: 0; color: #cfd3ef; }
.rule-mark {
  width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center;
  font-family: "Fraunces", serif; font-size: 1.6rem; color: #fff;
}
.rule-mark.light { background: radial-gradient(circle, var(--gold-soft) 0 22%, rgba(255, 210, 74, 0.45) 40%, var(--grass) 72%); }
.rule-mark.sight { background: linear-gradient(90deg, var(--grass) 0 42%, #3a3f55 42% 58%, var(--grass) 58%); }
.rule-mark.stone { background: #3a3f55; color: var(--green); }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px 28px; list-style: none; padding: 0; margin: 0; }
.features li { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid rgba(46, 58, 110, 0.5); color: #d7dbf5; }
.features li::before {
  content: ""; flex: 0 0 12px; height: 12px; margin-top: 8px; border-radius: 50%;
  background: var(--gold-soft); box-shadow: 0 0 12px 4px rgba(255, 210, 74, 0.55);
}
.features strong { color: #fff6dc; }

.gardens { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 26px; }
.garden-chip { padding: 8px 16px; border-radius: 999px; font-weight: 800; font-size: 0.9rem; border: 1px solid rgba(255, 255, 255, 0.12); }

.closing { text-align: center; }
.closing .card { padding: 40px 24px; }
.closing p { margin: 0 auto 24px; max-width: 520px; color: #cfd3ef; }

/* ---------- trang tài liệu ---------- */
.page { padding: 48px 0 0; }
.doc { max-width: 820px; margin: 0 auto; padding: clamp(24px, 5vw, 48px); }
.doc h1 { font-size: clamp(2rem, 5vw, 2.8rem); margin: 0 0 6px; }
.doc h2 { font-size: 1.4rem; margin: 34px 0 10px; }
.doc .meta { color: var(--muted); margin: 0 0 22px; }
.doc p, .doc li { color: #d7dbf5; }
.doc ul { padding-left: 22px; }
.doc li { margin: 6px 0; }
.doc strong { color: #fff6dc; }
.well { background: rgba(255, 210, 74, 0.08); border: 1px solid rgba(255, 210, 74, 0.35); border-radius: 16px; padding: 16px 20px; margin-top: 18px; }
.well p { margin: 0; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--gold-soft); font-weight: 800; }

.faq details { border-bottom: 1px solid var(--line); padding: 14px 0; }
.faq summary { cursor: pointer; font-weight: 800; color: #fff6dc; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--gold); font-size: 1.3rem; line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 10px 0 0; }

.contact-box { text-align: center; }
.contact-box .btn { margin-top: 8px; }

.notfound { text-align: center; padding: 90px 0 40px; }
.notfound .big { font-family: "Fraunces", serif; font-size: 5rem; color: var(--gold-soft); text-shadow: 0 0 30px rgba(255, 210, 74, 0.6); margin: 0; }

/* ---------- bàn Light Up (play, how-to-solve); màu theo bảng màu nền trong DESIGN.md của game ---------- */
.btn-small { min-height: 42px; padding: 0 18px; font-size: 0.92rem; border-radius: 13px; }
.btn[aria-disabled="true"] { opacity: 0.35; pointer-events: none; }
.btn-glass.on { border-color: var(--gold); color: var(--gold-soft); box-shadow: 0 0 18px rgba(255, 210, 74, 0.3); }
.chip { display: inline-flex; align-items: center; padding: 6px 14px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); color: var(--muted); font-weight: 800; font-size: 0.9rem; }

.board {
  --cell: min(calc((100vw - 64px) / var(--cols)), 56px);
  display: inline-flex; flex-direction: column; gap: 3px; padding: 8px;
  background: #0b1030; border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}
.board-row { display: flex; gap: 3px; }
.cell {
  position: relative; width: calc(var(--cell) - 3px); height: calc(var(--cell) - 3px); padding: 0; margin: 0;
  border: 0; border-radius: 22%; font: inherit; color: #fff;
  display: grid; place-items: center; -webkit-tap-highlight-color: transparent;
}
button.cell { cursor: pointer; }
button.cell:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.cell.grass { background: #17382a; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), inset 0 -2px 0 rgba(0, 0, 0, 0.25); transition: background 0.25s ease; }
.cell.grass.lit { background: linear-gradient(rgba(255, 224, 138, 0.42), rgba(255, 224, 138, 0.42)), #3e6b3a; }
.cell.rock { background: #3a3f55; border-radius: 34% 40% 30% 38%; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.45); }
.cell.rock.clue { font-family: "Fraunces", serif; font-size: calc(var(--cell) * 0.46); }
.cell.rock.full { background: #5a6078; color: var(--green); }
.cell.rock.over { color: #ff6b5e; box-shadow: 0 0 0 2px #e8413c; }
.cell.fly::after {
  content: ""; width: 38%; height: 38%; border-radius: 50%; background: #fff2a8;
  box-shadow: 0 0 10px 4px rgba(255, 210, 74, 0.85), 0 0 24px 10px rgba(255, 210, 74, 0.35);
  animation: breathe 2.4s ease-in-out infinite;
}
.cell.fly.seen::after { background: #ffb3ab; box-shadow: 0 0 10px 4px rgba(232, 65, 60, 0.9); animation: none; }
.cell.fly.seen { box-shadow: inset 0 0 0 2px #e8413c; }
.cell.dot::after { content: ""; width: 16%; height: 16%; border-radius: 50%; background: #8c94b8; }
.cell.related { box-shadow: inset 0 0 0 2px var(--teal), 0 0 12px rgba(95, 215, 200, 0.35); }
.cell.target-fly::after {
  content: ""; width: 38%; height: 38%; border-radius: 50%; background: var(--gold);
  box-shadow: 0 0 12px 5px rgba(255, 210, 74, 0.8); animation: breathe 1.4s ease-in-out infinite;
}
.cell.target-dot::before { content: ""; position: absolute; inset: 22%; border-radius: 50%; border: 2px solid var(--gold); box-shadow: 0 0 10px rgba(255, 210, 74, 0.6); }
@keyframes breathe { 50% { transform: scale(0.82); opacity: 0.8; } }

.play-page { padding-top: 36px; }
.play-head { text-align: center; }
.play-head h1 { font-size: clamp(2rem, 6vw, 3rem); margin: 4px 0 14px; }
.day-nav { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.play-area { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-top: 26px; }
.play-status { display: flex; gap: 12px; }
.stat { display: flex; flex-direction: column; align-items: center; min-width: 88px; padding: 8px 12px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); }
.stat .eyebrow { font-size: 0.66rem; }
.stat strong { font-family: "Fraunces", serif; font-size: 1.35rem; color: #fff6dc; line-height: 1.2; }
.board-msg { min-height: 1.6em; margin: 0; color: var(--muted); text-align: center; max-width: 460px; }
.tools { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.cell.rock.under { animation: needs 1.1s ease-in-out infinite; }
@keyframes needs { 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 16px rgba(255, 210, 74, 0.7); color: var(--gold-soft); } }
.board-msg.warn { color: var(--gold-soft); }
.play-area.solved .cell.grass { animation: bloom 1.2s ease-out var(--d, 0ms) both; }
.play-area.solved .cell.fly::after { animation: glow 1.4s ease-in-out infinite; }
@keyframes bloom { 0% { filter: brightness(1); } 35% { filter: brightness(1.9) saturate(1.3); box-shadow: 0 0 22px rgba(255, 210, 74, 0.7); } 100% { filter: brightness(1.15); } }
@keyframes glow { 50% { transform: scale(1.35); box-shadow: 0 0 16px 8px rgba(255, 210, 74, 0.9), 0 0 40px 18px rgba(255, 210, 74, 0.45); } }
.burst { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }
.win[open] { animation: rise 0.45s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(0.97); } }
.play-area.solved .board { box-shadow: 0 0 60px rgba(255, 210, 74, 0.45), 0 18px 40px rgba(0, 0, 0, 0.5); }
.play-rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; padding-top: 44px; }
.play-rules h2 { font-size: 1.4rem; margin: 0 0 10px; }
.play-rules ul { padding-left: 20px; margin: 0 0 12px; color: #d7dbf5; }
.play-rules li { margin: 6px 0; }
.play-rules strong { color: #fff6dc; }
.app-card { display: flex; gap: 18px; align-items: flex-start; }
.app-card img { width: 72px; height: 72px; border-radius: 17px; flex: 0 0 auto; box-shadow: 0 0 30px rgba(255, 210, 74, 0.3); }
.app-card .cta, .guide-cta .cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

.win {
  width: min(100% - 32px, 440px); padding: 30px 24px 26px; text-align: center; color: var(--text);
  background: var(--modal); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 0 80px rgba(255, 210, 74, 0.25), 0 30px 60px rgba(0, 0, 0, 0.6);
}
.win::backdrop { background: rgba(7, 10, 30, 0.7); backdrop-filter: blur(4px); }
.win h2 { font-size: 2.2rem; margin: 4px 0 18px; }
.win-close { position: absolute; top: 10px; right: 10px; margin: 0; }
.win .close { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); color: var(--text); font-size: 1.3rem; cursor: pointer; }
.win-stats { display: flex; gap: 10px; justify-content: center; margin-bottom: 18px; }
.win-app { color: #cfd3ef; margin: 18px 0 14px; }
.win .cta { display: flex; flex-direction: column; gap: 10px; }

.guide h3 { font-size: 1.25rem; margin: 30px 0 8px; }
.technique { padding: 0; }
.example { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin-top: 14px; }
.example .board { --cell: min(calc((100vw - 120px) / var(--cols)), 44px); }
.guide ol { padding-left: 22px; color: #d7dbf5; }
.guide ol li { margin: 6px 0; }
.guide-cta { margin-top: 28px; }
.home-play { margin-top: 18px; color: var(--muted); }


/* ---------- dải ảnh: carousel không thanh cuộn (main.js bọc .shots trong .gallery) ---------- */
.gallery { position: relative; }
.shots { scrollbar-width: none; -ms-overflow-style: none; padding-left: 8px; padding-right: 8px; padding-bottom: 22px; scroll-padding-inline: 8px;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l, 0px), #000 calc(100% - var(--fade-r, 0px)), transparent 100%);
          mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l, 0px), #000 calc(100% - var(--fade-r, 0px)), transparent 100%); }
.shots::-webkit-scrollbar { display: none; }
.gallery.can-left .shots { --fade-l: 56px; }
.gallery.can-right .shots { --fade-r: 56px; }
.gallery-btn {
  position: absolute; top: 44%; transform: translateY(-50%); z-index: 2;
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  font-size: 2rem; line-height: 1; cursor: pointer; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
  color: var(--gold); background: var(--glass); border: 1px solid var(--line); box-shadow: 0 0 18px rgba(255, 210, 74, 0.25); backdrop-filter: blur(6px);
}
.gallery-btn.prev { left: 4px; }
.gallery-btn.next { right: 4px; }
.gallery.can-left .gallery-btn.prev, .gallery.can-right .gallery-btn.next { opacity: 1; pointer-events: auto; }
@media (hover: none) { .gallery-btn { display: none; } }

@media (max-width: 640px) {
  .nav { gap: 14px; font-size: 0.88rem; }
  .shots img { width: 190px; }
  .hero { padding-top: 44px; }
  .nav a[href*="support"] { display: none; }
  .tools .btn { min-height: 42px; padding: 0 16px; font-size: 0.92rem; }
}
@media (max-width: 440px) {
  .brand span { display: none; }
  .app-card { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn-gold { transition: none; }
  .cell.fly::after, .cell.target-fly::after, .cell.rock.under, .play-area.solved .cell.grass, .play-area.solved .cell.fly::after, .win[open] { animation: none; }
}
