/* ==========================================================================
   Tokens
   ========================================================================== */
:root {
  --font: "Be Vietnam Pro", "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #050d1c;
  --ink: #f5f8ff;
  --ink-soft: rgba(240, 244, 252, 0.9);
  --ink-dim: rgba(226, 234, 248, 0.62);

  --gold: #ffd93d;
  --gold-hi: #ffe680;
  --gold-line: rgba(244, 208, 40, 0.4);
  --blue: #4dafff;
  --blue-line: rgba(123, 181, 227, 0.3);

  --panel-bg: linear-gradient(180deg, rgba(9, 17, 31, 0.86), rgba(5, 12, 22, 0.9));
  --radius-lg: 22px;
  --radius-md: 14px;

  --gutter: clamp(12px, 4vw, 24px);
  --content-w: 960px;

  --fs-sm: 0.8125rem;
  --fs-base: clamp(0.9375rem, 0.91rem + 0.2vw, 1.0625rem);
  --fs-h2: clamp(1.0625rem, 0.95rem + 1.1vw, 1.5rem);
  --fs-h3: clamp(1.125rem, 1rem + 0.8vw, 1.5rem);
  --fs-title: clamp(1.25rem, 1rem + 1.4vw, 1.875rem);

  --flag-size: 64px;
}

/* ==========================================================================
   Base
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img,
canvas,
video {
  max-width: 100%;
}

h2,
h3,
h4,
p {
  margin: 0;
}

h2,
h3,
h4 {
  text-wrap: balance;
}

a,
button,
input {
  -webkit-tap-highlight-color: transparent;
}

a,
button {
  touch-action: manipulation;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

/* ==========================================================================
   Nền video
   ========================================================================== */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 12%, rgba(36, 116, 210, 0.5), transparent 55%),
    linear-gradient(180deg, #0b2347 0%, #06142b 60%, #030a16 100%);
}

.bg video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.bg video.is-ready {
  opacity: 1;
}

.bg-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 14%, rgba(36, 116, 210, 0.3), transparent 48%),
    linear-gradient(180deg, rgba(3, 10, 22, 0.5) 0%, rgba(2, 8, 18, 0.74) 70%, rgba(0, 0, 0, 0.86) 100%);
}

.page {
  position: relative;
  z-index: 1;
}

.container {
  width: 100%;
  max-width: calc(var(--content-w) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Chỉ hiện khi mở trang bằng file:// và không đọc được config.json */
.config-notice {
  position: fixed;
  inset: auto 12px calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 10;
  padding: 0.7rem 1rem;
  border: 1px solid #ff8a8a;
  border-radius: var(--radius-md);
  background: rgba(60, 10, 10, 0.94);
  color: #ffe3e3;
  font-size: var(--fs-sm);
  line-height: 1.45;
  text-align: center;
}

/* ==========================================================================
   Header + dải chữ chạy
   ========================================================================== */
.site-header {
  display: flex;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) var(--gutter) 10px;
}

.hero-logo {
  display: block;
  width: clamp(132px, 38vw, 210px);
  height: auto;
  aspect-ratio: 485 / 270;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.45));
}

.hero-logo:not([src]) {
  visibility: hidden;
}

.welcome-strip {
  overflow: hidden;
  border-block: 2px solid var(--gold);
  background: rgba(0, 0, 0, 0.8);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
}

.welcome-track {
  display: flex;
  width: max-content;
  animation: marquee 26s linear infinite;
}

.welcome-group {
  display: flex;
  flex: none;
  justify-content: space-around;
  min-width: 100vw;
}

.welcome-group span {
  padding: 0.7rem 2.5rem;
  white-space: nowrap;
  text-transform: uppercase;
  font-size: clamp(0.8125rem, 0.7rem + 0.6vw, 1.25rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #f7f8fb;
}

@keyframes marquee {
  to {
    transform: translateX(-50%);
  }
}

/* ==========================================================================
   Khối chính
   ========================================================================== */
.hero-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(22px, 5vw, 34px);
  padding-top: clamp(26px, 6vw, 44px);
  padding-bottom: calc(clamp(32px, 8vw, 56px) + env(safe-area-inset-bottom, 0px));
}

/* --- Nút chính --- */
.main-cta {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 460px);
  min-height: 60px;
  padding: 0.85rem 1.25rem;
  border: 3px solid #b7dcff;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 38%),
    linear-gradient(180deg, #2a7ed0 0%, #1a66b5 54%, #0f4f96 100%);
  color: #fff;
  font-size: clamp(1.0625rem, 0.95rem + 0.9vw, 1.5rem);
  font-weight: 800;
  letter-spacing: 0.07em;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(8, 40, 86, 0.55);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.5),
    inset 0 -5px 10px rgba(10, 45, 98, 0.5),
    0 8px 0 #0b3162,
    0 16px 26px rgba(0, 0, 0, 0.5);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

/* Quầng sáng nhấp nháy: chỉ animate opacity để mượt trên điện thoại */
.main-cta::after {
  content: "";
  position: absolute;
  inset: -4px;
  z-index: -1;
  border-radius: inherit;
  box-shadow: 0 0 30px 6px rgba(80, 164, 255, 0.6);
  opacity: 0.3;
  animation: cta-glow 1.8s ease-in-out infinite;
  pointer-events: none;
}

.main-cta:active {
  transform: translateY(6px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.44),
    inset 0 -4px 8px rgba(10, 45, 98, 0.5),
    0 2px 0 #0b3162,
    0 8px 16px rgba(0, 0, 0, 0.48);
}

@keyframes cta-glow {
  50% {
    opacity: 1;
  }
}

/* --- Lưới cờ --- */
.lang-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem 0.25rem;
  justify-items: center;
}

.lang-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.25rem 0.1rem;
  color: inherit;
  text-align: center;
  text-decoration: none;
  transition: transform 0.2s ease;
}

.lang-item:active {
  transform: scale(0.95);
}

.flag-circle {
  display: block;
  flex: none;
  width: var(--flag-size);
  height: auto;
  aspect-ratio: 1 / 1;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #0f1a27;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.28),
    0 8px 18px rgba(0, 0, 0, 0.4);
  animation: spin 8s linear infinite;
  will-change: transform;
}

.lang-greet {
  margin-top: 0.4rem;
  color: var(--gold);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  text-shadow: 0 0 10px rgba(255, 217, 61, 0.45), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.lang-name {
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 800;
  line-height: 1.3;
  white-space: nowrap;
  text-shadow: 0 2px 7px rgba(0, 0, 0, 0.55);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   Panel dùng chung
   ========================================================================== */
.panel {
  width: 100%;
  border: 1px solid var(--gold-line);
  border-radius: var(--radius-lg);
  background: var(--panel-bg);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
}

/* --- Bảo mật --- */
.security-panel {
  padding: clamp(1rem, 3.5vw, 1.75rem);
}

.security-panel h2 {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  color: var(--gold-hi);
  font-size: var(--fs-h2);
  font-weight: 800;
  line-height: 1.3;
  text-shadow: 0 0 14px rgba(255, 224, 90, 0.35);
}

.security-mark {
  flex: none;
  align-self: stretch;
  width: 5px;
  border-radius: 999px;
  background: #0093ff;
  box-shadow: 0 0 12px rgba(0, 147, 255, 0.45);
}

.security-panel p {
  margin-top: 0.9rem;
  color: var(--ink-soft);
  font-size: var(--fs-base);
  line-height: 1.7;
  text-wrap: pretty;
}

.security-panel strong {
  color: var(--gold-hi);
  font-weight: 700;
}

.security-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.1rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--gold);
  border-radius: var(--radius-md);
  background: #0b2a4a;
  color: #f4f7ff;
  font-size: clamp(0.75rem, 0.7rem + 0.3vw, 0.9375rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.35;
  text-align: center;
}

.security-status::before {
  content: "";
  flex: none;
  width: 1.3em;
  height: 1.3em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffd93d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3l8 3v6c0 4.5-3.2 8-8 9-4.8-1-8-4.5-8-9V6l8-3z'/%3E%3Cpath d='M8.5 12l2.5 2.5 4.5-5'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

/* --- Nổ hũ --- */
.jackpot-panel {
  overflow: hidden;
  border-color: var(--blue-line);
}

.jackpot-panel h3 {
  padding: 0.9rem 1rem 0.6rem;
  color: var(--ink);
  font-size: var(--fs-h3);
  font-weight: 700;
}

.jackpot-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "game game game"
    "time user amount";
  align-items: center;
  gap: 0.15rem 0.6rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  transition: background-color 0.3s ease;
}

.jackpot-row.is-updating {
  background: rgba(64, 153, 229, 0.14);
}

.jackpot-time {
  grid-area: time;
  color: var(--ink-dim);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

.jackpot-game {
  grid-area: game;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jackpot-user {
  grid-area: user;
  color: var(--ink-dim);
  font-size: var(--fs-sm);
}

.jackpot-user::before {
  content: "·";
  margin-right: 0.6rem;
}

.jackpot-amount {
  grid-area: amount;
  justify-self: end;
  color: var(--blue);
  font-size: 1.0625rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* --- Đánh giá --- */
.review-panel {
  padding: clamp(1rem, 3.5vw, 1.75rem);
}

.review-panel h3 {
  color: var(--gold-hi);
  font-size: var(--fs-title);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.3;
  text-align: center;
  text-shadow: 0 0 16px rgba(255, 224, 90, 0.4);
}

.review-subtitle {
  margin-top: 0.9rem;
  color: var(--gold);
  font-size: clamp(0.875rem, 0.8rem + 0.45vw, 1.1875rem);
  font-weight: 700;
  text-align: center;
}

.review-stars {
  display: flex;
  justify-content: center;
  gap: 0.15rem;
  margin-top: 0.4rem;
}

.review-star {
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.34);
  font: inherit;
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.14s ease, color 0.14s ease, text-shadow 0.14s ease;
}

.review-star.is-active {
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 217, 56, 0.45);
}

.review-star:active {
  transform: scale(0.88);
}

.review-picked {
  margin-top: 0.15rem;
  color: rgba(245, 249, 255, 0.78);
  font-size: var(--fs-sm);
  text-align: center;
}

.review-input-row {
  display: flex;
  gap: 0.6rem;
  width: min(100%, 720px);
  margin: 1.1rem auto 0;
}

.review-input-row input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 1.1rem;
  border: 2px solid rgba(238, 201, 61, 0.7);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font: inherit;
  font-size: 1rem; /* >= 16px để iOS không tự phóng to khi focus */
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.review-input-row input::placeholder {
  color: rgba(236, 240, 246, 0.55);
}

.review-input-row input:focus {
  border-color: var(--gold);
  background: rgba(255, 255, 255, 0.14);
}

.review-input-row button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 96px;
  height: 52px;
  padding: 0 1.2rem;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffc743, #ffb420);
  color: #101418;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease;
}

.review-input-row button:active {
  transform: scale(0.96);
  filter: brightness(0.95);
}

/* Thu gọn về 0 khi ẩn để không chừa khoảng trống dưới ô nhập */
.review-thanks {
  width: fit-content;
  max-width: 100%;
  max-height: 0;
  margin: 0 auto;
  padding: 0 0.9rem;
  overflow: hidden;
  border: 0 solid rgba(255, 217, 56, 0.5);
  border-radius: 999px;
  background: rgba(255, 217, 56, 0.14);
  color: var(--gold-hi);
  font-size: var(--fs-sm);
  font-weight: 700;
  opacity: 0;
  transition: max-height 0.22s ease, margin 0.22s ease, padding 0.22s ease, opacity 0.22s ease;
  pointer-events: none;
}

.review-thanks.show {
  max-height: 3rem;
  margin-top: 0.7rem;
  padding: 0.45rem 0.9rem;
  border-width: 1px;
  opacity: 1;
}

.review-divider {
  margin: 1.3rem 0 1.1rem;
  border: 0;
  border-top: 1px solid var(--gold-line);
}

.review-panel h4 {
  margin-bottom: 1rem;
  color: var(--gold-hi);
  font-size: clamp(1.0625rem, 0.95rem + 0.9vw, 1.5rem);
  font-weight: 800;
  text-align: center;
}

.review-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.review-card {
  padding: 0.9rem 1rem;
  border: 1px solid rgba(241, 206, 71, 0.34);
  border-radius: var(--radius-md);
  background: rgba(13, 20, 24, 0.82);
  transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.review-card-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.review-avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--gold);
}

.review-avatar svg {
  width: 24px;
  height: 24px;
}

.review-name {
  color: var(--gold);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.3;
}

.review-time {
  margin-top: 0.1rem;
  color: rgba(236, 240, 246, 0.62);
  font-size: var(--fs-sm);
}

.review-rate {
  margin-top: 0.7rem;
  color: var(--gold);
  font-size: 1.125rem;
  letter-spacing: 0.08em;
  line-height: 1;
}

.review-text {
  margin-top: 0.45rem;
  color: rgba(247, 250, 255, 0.92);
  font-size: 0.9375rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   < 480px: ô nhập và nút gửi xếp dọc cho dễ bấm
   ========================================================================== */
@media (max-width: 479.98px) {
  .review-input-row {
    flex-direction: column;
  }

  .review-input-row input {
    flex: none;
  }

  .review-input-row button {
    width: 100%;
  }
}

/* ==========================================================================
   >= 480px
   ========================================================================== */
@media (min-width: 480px) {
  :root {
    --flag-size: 72px;
  }

  .lang-greet,
  .lang-name {
    font-size: 0.875rem;
  }

  .jackpot-game {
    font-size: 1rem;
  }
}

/* ==========================================================================
   >= 720px (tablet / desktop)
   ========================================================================== */
@media (min-width: 720px) {
  :root {
    --flag-size: clamp(72px, 9vw, 104px);
  }

  .welcome-track {
    animation-duration: 32s;
  }

  .lang-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 1rem 0.5rem;
  }

  .flag-circle {
    border-width: 4px;
  }

  .lang-greet,
  .lang-name {
    font-size: 0.9375rem;
  }

  .jackpot-panel h3 {
    padding: 1.1rem 1.5rem 0.7rem;
  }

  .jackpot-row {
    grid-template-columns: 4.5rem minmax(0, 1fr) 6rem 7rem;
    grid-template-areas: "time game user amount";
    gap: 0.75rem;
    padding: 0.85rem 1.5rem;
  }

  .jackpot-time,
  .jackpot-user {
    font-size: 0.9375rem;
  }

  .jackpot-user::before {
    content: none;
  }

  .jackpot-game {
    font-size: 1.0625rem;
  }

  .jackpot-amount {
    font-size: 1.25rem;
  }

  .review-stars {
    gap: 0.4rem;
  }

  .review-star {
    width: 56px;
    height: 56px;
    font-size: 2.6rem;
  }

  .review-card {
    padding: 1.1rem 1.2rem;
  }

  .review-name {
    font-size: 1.0625rem;
  }

  .review-text {
    font-size: 1rem;
  }
}

@media (min-width: 900px) {
  .review-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
  }

  .review-card {
    min-height: 168px;
  }
}

@media (min-width: 960px) {
  .lang-greet,
  .lang-name {
    font-size: 1.0625rem;
  }

  .welcome-track {
    animation-duration: 38s;
  }
}

/* ==========================================================================
   Thiết bị cảm ứng / chuột
   ========================================================================== */
@media (hover: hover) and (pointer: fine) {
  .main-cta:hover {
    transform: translateY(-3px);
    filter: brightness(1.08);
  }

  .lang-item:hover {
    transform: translateY(-4px);
  }

  .review-star:hover {
    transform: translateY(-2px) scale(1.06);
  }

  .review-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 221, 99, 0.75);
    background: rgba(24, 36, 46, 0.92);
  }
}

/* ==========================================================================
   Giảm chuyển động
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .welcome-track,
  .flag-circle,
  .main-cta::after {
    animation: none;
  }

  .welcome-track {
    width: auto;
  }

  .welcome-group[aria-hidden="true"] {
    display: none;
  }

  .welcome-group {
    min-width: 0;
    width: 100%;
  }

  .welcome-group span {
    white-space: normal;
    text-align: center;
  }

  .main-cta::after {
    opacity: 0.6;
  }
}
