/* Hồ Cá 3D — giao diện tối giản cho TV / tablet / desktop */
:root {
  --accent: #7fe7d2;
  --accent-soft: rgba(127, 231, 210, 0.16);
  --ink: #eaf6f6;
  --ink-dim: rgba(226, 244, 244, 0.6);
  --panel: rgba(5, 22, 28, 0.62);
  --stroke: rgba(160, 226, 224, 0.18);
  --safe: 4vmin;
  --font: "Be Vietnam Pro", "SF Pro Display", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #031016;
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#scene:active { cursor: grabbing; }
body[data-quality="medium"] #scene,
body[data-quality="high"] #scene {
  filter: saturate(1.05) contrast(1.025) brightness(1.01);
}

/* Lớp không khí điện ảnh — chỉ là CSS, không tốn GPU đáng kể */
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(130% 100% at 50% 40%, transparent 52%, rgba(0, 6, 10, 0.34) 100%),
    linear-gradient(to bottom, rgba(3, 14, 20, 0.28), transparent 22%, transparent 78%, rgba(0, 8, 12, 0.42));
}
.grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

/* ---------- HUD ---------- */
.brand {
  position: fixed;
  top: var(--safe);
  left: var(--safe);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: clamp(11px, 1.35vh, 14px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.8s ease, transform 0.8s ease;
  pointer-events: none;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.7);
}
body.ready .brand { opacity: 1; transform: none; }
.brand-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  animation: pulse 4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .45; } 50% { opacity: 1; } }
.brand-name { font-weight: 600; color: rgba(234, 246, 246, 0.86); }
.brand-stats {
  display: flex; align-items: center; gap: 0.55rem;
  color: var(--ink-dim);
  font-size: 0.82em; letter-spacing: 0.12em;
  padding-left: 0.5rem;
  border-left: 1px solid rgba(200, 240, 240, 0.16);
}
.brand-stats i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; }


/* ---------- Âm thanh ---------- */
.sound-toggle {
  position: fixed;
  top: var(--safe);
  right: var(--safe);
  z-index: 8;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(160, 232, 222, 0.18);
  background: rgba(4, 22, 27, 0.5);
  color: rgba(206, 246, 240, 0.82);
  cursor: pointer;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.5s ease, transform 0.5s ease, background 0.2s, color 0.2s;
}
body.ready .sound-toggle { opacity: 1; transform: none; }
body.hide-ui .sound-toggle { opacity: 0; pointer-events: none; }
.sound-toggle:hover, .sound-toggle:focus-visible {
  background: rgba(127, 231, 210, 0.14);
  color: #eafffb;
  outline: none;
}
.sound-toggle svg {
  width: 21px; height: 21px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.sound-toggle .icon-off { display: none; }
.sound-toggle[data-muted="true"] .icon-on { display: none; }
.sound-toggle[data-muted="true"] .icon-off { display: block; }
.sound-toggle[data-muted="true"] { color: rgba(255, 205, 160, 0.7); }

/* ---------- Nút điều khiển ---------- */
.toolbar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe) * 0.85);
  transform: translate(-50%, 0);
  z-index: 7;
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 6px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(12, 38, 46, 0.72), rgba(4, 19, 25, 0.82));
  border: 1px solid var(--stroke);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(.2,.8,.2,1);
  max-width: calc(100vw - 2 * var(--safe));
}
.btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  font-size: clamp(11px, 1.45vh, 13px);
  letter-spacing: 0.02em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 78px;
  padding: 9px 12px 8px;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.btn svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.btn span { white-space: nowrap; }
.btn:hover, .btn:focus-visible { background: rgba(150, 235, 225, 0.09); color: var(--ink); outline: none; }
.btn:active { transform: scale(0.95); }
.btn-primary { color: #062024; background: var(--accent); box-shadow: 0 6px 22px rgba(127, 231, 210, 0.24); }
.btn-primary:hover, .btn-primary:focus-visible { background: #9df3e1; color: #04211f; }
.btn-primary svg { stroke-width: 1.7; }

body.hide-ui .toolbar { opacity: 0; transform: translate(-50%, 14px); pointer-events: none; }
body.hide-ui .brand,
body.hide-ui .hint { opacity: 0 !important; }
body.hide-ui #scene { cursor: none; }
body.ready.hide-ui #scene { cursor: none; }

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe) * 0.85 + 84px);
  transform: translateX(-50%);
  z-index: 5;
  font-size: clamp(11px, 1.4vh, 13px);
  color: rgba(222, 244, 244, 0.42);
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 1s ease;
  text-shadow: 0 2px 10px rgba(0,0,0,.8);
}
.hint.gone { opacity: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe) * 0.85 + 102px);
  transform: translate(-50%, 10px);
  z-index: 9;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(4, 20, 26, 0.84);
  border: 1px solid var(--stroke);
  color: var(--ink);
  font-size: clamp(12px, 1.6vh, 14px);
  letter-spacing: 0.01em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Intro ---------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: var(--safe);
  background:
    radial-gradient(80% 70% at 50% 40%, rgba(6, 28, 36, 0.35), rgba(2, 9, 13, 0.82) 100%),
    linear-gradient(to bottom, rgba(2, 12, 17, 0.62), rgba(2, 9, 13, 0.88));
  transition: opacity 1s ease, visibility 1s;
  overflow: hidden;
}
.intro.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.intro-glow {
  position: absolute;
  width: 120vmax; height: 120vmax;
  left: 50%; top: 62%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(74, 204, 190, 0.18), transparent 58%);
  filter: blur(10px);
  animation: breathe 9s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { transform: translate(-50%, -50%) scale(1); opacity: .8; } 50% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; } }

.intro-card {
  position: relative;
  width: min(620px, 92vw);
  text-align: center;
  animation: rise 1.1s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.logo {
  width: 74px; height: 74px;
  margin: 0 auto 18px;
  border-radius: 24px;
  display: grid; place-items: center;
  color: var(--accent);
  background: linear-gradient(160deg, rgba(127, 231, 210, 0.18), rgba(127, 231, 210, 0.04));
  border: 1px solid rgba(127, 231, 210, 0.28);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.logo svg { width: 44px; height: 44px; }
.eyebrow {
  margin: 0 0 12px;
  font-size: clamp(10px, 1.25vh, 12px);
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.8;
}
.intro h1 {
  margin: 0;
  font-size: clamp(46px, 9.2vh, 92px);
  line-height: 0.96;
  font-weight: 200;
  letter-spacing: 0.03em;
  background: linear-gradient(180deg, #f2fbfb 10%, #a9ded9 55%, #5fa7a5 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 12px 40px rgba(0, 0, 0, 0.35));
}
.lede {
  margin: 18px auto 30px;
  max-width: 430px;
  font-size: clamp(13px, 1.85vh, 16px);
  line-height: 1.65;
  color: rgba(224, 244, 244, 0.66);
  font-weight: 300;
}
.start-btn {
  appearance: none;
  border: 1px solid rgba(127, 231, 210, 0.5);
  background: linear-gradient(180deg, #a5f0e2, #6dd9c5);
  color: #04221f;
  font: inherit;
  font-size: clamp(14px, 1.9vh, 17px);
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 15px 26px 15px 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: 0 20px 50px rgba(50, 190, 170, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.2s ease, box-shadow 0.25s ease, filter 0.2s;
}
.start-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.start-btn:hover { transform: translateY(-2px); box-shadow: 0 26px 60px rgba(50, 190, 170, 0.36), inset 0 1px 0 rgba(255,255,255,.6); }
.start-btn:active { transform: translateY(0) scale(0.98); }
.start-btn:focus-visible { outline: 2px solid #d9fff8; outline-offset: 4px; }
.start-hints {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  font-size: clamp(10px, 1.35vh, 12px);
  color: rgba(220, 242, 242, 0.4);
  letter-spacing: 0.02em;
}
.start-hints b { color: rgba(232, 250, 250, 0.78); font-weight: 600; }
.device-note {
  margin: 22px 0 0;
  font-size: clamp(10px, 1.25vh, 12px);
  color: rgba(200, 230, 230, 0.28);
  letter-spacing: 0.06em;
}

/* ---------- Fatal ---------- */
.fatal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #041015;
}
.fatal[hidden] { display: none; }
.fatal-card { max-width: 460px; text-align: center; }
.fatal h2 { font-weight: 400; font-size: 30px; margin: 0 0 12px; }
.fatal p { color: rgba(230, 245, 245, 0.7); line-height: 1.6; }
.fatal .muted { color: rgba(230, 245, 245, 0.4); font-size: 13px; }
.fatal .start-btn { margin-top: 16px; }

/* ---------- Debug ---------- */
.debug {
  position: fixed;
  left: 10px; bottom: 10px;
  z-index: 40;
  margin: 0;
  padding: 10px 12px;
  max-width: 46vw;
  font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #b9f5e9;
  background: rgba(0, 10, 14, 0.78);
  border: 1px solid rgba(127, 231, 210, 0.2);
  border-radius: 8px;
  pointer-events: none;
  white-space: pre-wrap;
}

@media (max-width: 480px) {
  .intro h1 { font-size: clamp(40px, 13vw, 64px); }
  .intro-card { width: min(92vw, 520px); }
  .lede { font-size: 13px; }
  .start-hints { gap: 6px 12px; }
}

@media (max-width: 760px) {
  .btn { min-width: 48px; padding: 8px 6px 7px; }
  .btn svg { width: 22px; height: 22px; }
  .btn span { display: none; }
  .toolbar { gap: 0; padding: 5px; bottom: calc(var(--safe) * 0.7); }
  .hint { bottom: calc(var(--safe) * 0.7 + 70px); white-space: normal; text-align: center; max-width: 88vw; line-height: 1.5; }
  .toast { bottom: calc(var(--safe) * 0.7 + 80px); white-space: normal; text-align: center; max-width: 80vw; }
  .brand-stats { display: none; }
}
@media (max-height: 430px) {
  .intro-card { width: min(760px, 94vw); }
  .logo { width: 54px; height: 54px; border-radius: 18px; margin-bottom: 10px; }
  .logo svg { width: 32px; height: 32px; }
  .intro h1 { font-size: clamp(38px, 12vh, 64px); }
  .lede { margin: 10px auto 18px; line-height: 1.5; }
  .start-btn { padding: 11px 22px 11px 26px; }
  .start-hints { margin-top: 16px; }
  .device-note { margin-top: 12px; }
  .btn svg { width: 22px; height: 22px; }
  .btn { min-width: 70px; padding: 6px 10px; gap: 3px; }
  .hint { bottom: calc(var(--safe) * 0.85 + 70px); }
}

@media (prefers-reduced-motion: reduce) {
  .intro-card, .intro-glow, .brand-dot { animation: none; }
}


/* Trước khi bắt đầu, chỉ hiện màn hình giới thiệu */
body:not(.ready) .toolbar,
body:not(.ready) .brand,
body:not(.ready) .hint,
body:not(.ready) .toast {
  opacity: 0 !important;
  pointer-events: none !important;
}


/* --- bản PRO --- */
.pro-badge {
  display: inline-block;
  margin-left: 7px;
  padding: 2px 6px 1px;
  border-radius: 4px;
  border: 1px solid rgba(255, 210, 145, 0.55);
  color: #ffd9a0;
  font-size: 0.52em;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.2em;
  line-height: 1.2;
  vertical-align: 0.12em;
  background: rgba(255, 196, 120, 0.08);
}
.pro-tag {
  display: inline-block;
  margin-left: 0.18em;
  padding: 0.1em 0.32em 0.06em;
  border-radius: 0.16em;
  font-size: 0.105em;
  font-weight: 500;
  letter-spacing: 0.18em;
  vertical-align: 0.9em;
  color: #ffd9a0;
  border: 1px solid rgba(255, 210, 145, 0.5);
  background: rgba(255, 200, 130, 0.08);
  -webkit-text-fill-color: #ffd9a0;
}
body[data-quality="high"] .pro-badge { box-shadow: 0 0 18px rgba(255, 200, 130, 0.18); }
