@font-face {
  font-family: "FatPixVN";
  src: url("assets/fatpix-font/FatPix-VN-SVG.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-pink-pastel: #fce4ec;
  --bg-cream: #fff9f0;
  --ink-dark: #291d38;
  --ink-soft: #4e3861;
  --pink-primary: #f5338f;
  --pink-light: #ffa1b7;
  --gold-accent: #fcd322;
  --teal-accent: #4ab5c9;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #f9d5e5;
  color: var(--ink-dark);
  font-family: "Be Vietnam Pro", system-ui, -apple-system, sans-serif;
  touch-action: manipulation;
  overscroll-behavior: none;
}

canvas {
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.hidden {
  display: none !important;
}

/* Nền vườn hoa & cánh hoa bay */
#ambient-bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Nút bật/tắt âm thanh (chừa tai thỏ, dùng khung tan ấm áp) */
.pixel-icon-btn {
  position: fixed;
  top: calc(var(--safe-top) + 8px);
  right: calc(var(--safe-right) + 8px);
  z-index: 90;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-style: solid;
  border-width: 10px;
  border-image: url("assets/kenney-pixel-ui/9-Slice/Ancient/tan.png") 16 fill stretch;
  cursor: pointer;
}

.pixel-icon-btn:active {
  border-image: url("assets/kenney-pixel-ui/9-Slice/Ancient/tan_pressed.png") 16 fill stretch;
  transform: translateY(2px);
}

.pixel-icon-btn canvas {
  width: 20px;
  height: 20px;
}

.sync-badge {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: calc(var(--safe-left) + 12px);
  z-index: 90;
  background: rgba(41, 29, 56, 0.85);
  color: #fff9f0;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  border: 2px solid #fcd322;
}

/* Quản lý 5 màn + hiệu ứng chuyển cảnh mượt */
#app-root {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  padding:
    calc(var(--safe-top) + 10px)
    calc(var(--safe-right) + 12px)
    calc(var(--safe-bottom) + 10px)
    calc(var(--safe-left) + 12px);
}

.screen.active {
  display: flex;
  animation: screenFadeIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes screenFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.screen-inner {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 460px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* Typography Pixel (FatPix VN tắt faux-bold để chữ mảnh, rõ nét, không bị đặc) */
.pixel-title {
  font-family: "FatPixVN", "Be Vietnam Pro", sans-serif;
  font-weight: 400 !important;
  font-synthesis: none;
  letter-spacing: 1px;
  line-height: 1.3;
  color: #291d38;
  text-shadow: 2px 2px 0px #fff9f0;
}

.pixel-number {
  font-family: "FatPixVN", monospace;
  font-weight: 400 !important;
  font-synthesis: none;
  letter-spacing: 0.8px;
  font-size: 21px;
  color: #d4127b;
}

/* Khung hộp thoại kiểu RPG dùng Kenney 9-Slice Ancient/tan.png hợp tông hồng/kem */
.rpg-panel {
  border-style: solid;
  border-width: 14px;
  border-image: url("assets/kenney-pixel-ui/9-Slice/Ancient/tan.png") 16 fill stretch;
  image-rendering: pixelated;
  background-clip: padding-box;
  padding: 12px 14px;
  width: 100%;
  box-shadow: 0 6px 0 rgba(90, 48, 68, 0.24);
}

.panel-cream {
  border-image: url("assets/kenney-pixel-ui/9-Slice/Ancient/tan.png") 16 fill stretch;
  background-color: rgba(255, 249, 240, 0.65);
  background-blend-mode: soft-light;
}

/* Nút bấm Kenney 9-Slice dùng Be Vietnam Pro rõ nét, dễ đọc trên điện thoại */
.pixel-btn {
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.2px;
  color: #291d38;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  border-style: solid;
  border-width: 12px;
  padding: 4px 16px;
  cursor: pointer;
  background: transparent;
  image-rendering: pixelated;
  transition: transform 0.08s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 44px;
}

.pixel-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-yellow {
  border-image: url("assets/kenney-pixel-ui/9-Slice/Colored/yellow.png") 16 fill stretch;
}
.btn-yellow:active:not(:disabled) {
  border-image: url("assets/kenney-pixel-ui/9-Slice/Colored/yellow_pressed.png") 16 fill stretch;
  transform: translateY(2px);
}

.btn-green {
  border-image: url("assets/kenney-pixel-ui/9-Slice/Colored/green.png") 16 fill stretch;
  color: #162400;
}
.btn-green:active:not(:disabled) {
  border-image: url("assets/kenney-pixel-ui/9-Slice/Colored/green_pressed.png") 16 fill stretch;
  transform: translateY(2px);
}

.btn-red {
  border-image: url("assets/kenney-pixel-ui/9-Slice/Colored/red.png") 16 fill stretch;
  color: #ffffff;
  text-shadow: 0 1px 1px #291d38;
}
.btn-red:active:not(:disabled) {
  border-image: url("assets/kenney-pixel-ui/9-Slice/Colored/red_pressed.png") 16 fill stretch;
  transform: translateY(2px);
}

.btn-blue {
  border-image: url("assets/kenney-pixel-ui/9-Slice/Colored/blue.png") 16 fill stretch;
  color: #ffffff;
  text-shadow: 0 1px 1px #291d38;
}
.btn-blue:active:not(:disabled) {
  border-image: url("assets/kenney-pixel-ui/9-Slice/Colored/blue_pressed.png") 16 fill stretch;
  transform: translateY(2px);
}

/* ==========================================================================
   MÀN 0: LOADING
   ========================================================================== */
.loading-card {
  max-width: 340px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.loading-subtitle {
  font-size: 13px;
  color: var(--ink-soft);
}

.pixel-progress-outer {
  width: 100%;
  height: 22px;
  background: #291d38;
  border: 3px solid #442d50;
  padding: 2px;
}

.pixel-progress-inner {
  height: 100%;
  background: linear-gradient(90deg, #f5338f, #fcd322);
  transition: width 0.15s ease;
}

/* ==========================================================================
   MÀN 1: HỘP QUÀ BUNG HOA & XÁC NHẬN TÊN
   ========================================================================== */
#gift-burst-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}

.gift-stage-wrap {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#gift-stage-canvas {
  width: min(230px, 65vw);
  height: auto;
  aspect-ratio: 240 / 180;
}

.tap-hint {
  margin-top: -8px;
  font-size: 17px;
  color: #d4127b;
  background: #fff9f0;
  padding: 4px 14px;
  border: 2px solid #291d38;
  animation: pulseHint 1.2s infinite ease-in-out;
}

@keyframes pulseHint {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

.greeting-panel {
  position: relative;
  z-index: 5;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 9px;
  animation: popIn 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.greeting-title {
  font-size: clamp(19px, 5vw, 24px);
  color: #d4127b;
  min-height: 30px;
}

.greeting-desc {
  font-size: 13.5px;
  color: var(--ink-dark);
  font-weight: 600;
}

.pixel-select {
  width: 100%;
  padding: 9px 12px;
  font-family: "Be Vietnam Pro", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-dark);
  background-color: #fff9f0;
  border: 3px solid #291d38;
  outline: none;
  cursor: pointer;
  user-select: auto;
  -webkit-user-select: auto;
}

.history-hint {
  font-size: 12px;
  color: #951350;
  background: #fff0f5;
  padding: 5px 8px;
  border: 1px dashed #c94a82;
  font-weight: 600;
}

.name-confirm-box {
  background: #fff9f0;
  border: 2px solid #d4127b;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: popIn 0.25s ease-out;
}

.name-confirm-question {
  font-size: 14px;
  font-weight: 700;
  color: #291d38;
}

.name-confirm-question strong {
  color: #d4127b;
  font-weight: 800;
}

.name-confirm-sub {
  font-size: 11.5px;
  color: #951350;
  font-weight: 600;
}

.name-action-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.name-action-row .pixel-btn {
  flex: 1;
}

/* Hỗ trợ Màn 1 khi điện thoại xoay ngang */
@media (orientation: landscape) and (max-height: 500px) {
  .screen-1-layout {
    max-width: 720px;
    flex-direction: row;
    gap: 16px;
  }
  #gift-stage-canvas {
    width: 190px;
  }
}

/* ==========================================================================
   MÀN 2: NÚT "KHÔNG" CHẠY TRỐN
   ========================================================================== */
.question-panel {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.question-decor-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.pixel-badge {
  font-family: "Be Vietnam Pro", sans-serif;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.6px;
  background: #fcd322;
  color: #291d38;
  padding: 3px 10px;
  border: 2px solid #291d38;
}

.question-heading {
  font-size: clamp(17px, 4.6vw, 22px);
  color: #291d38;
}

.question-sub {
  font-size: 13.5px;
  color: var(--ink-dark);
  font-weight: 600;
}

.runaway-arena {
  position: relative;
  width: 100%;
  height: clamp(185px, 35vh, 250px);
  background: rgba(255, 249, 240, 0.78);
  border: 2px dashed #c94a82;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.yes-btn {
  z-index: 5;
  transition: transform 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  margin-right: 110px;
}

.no-btn {
  position: absolute;
  z-index: 6;
  right: 24px;
  top: calc(50% - 22px);
  white-space: nowrap;
  touch-action: none;
}

@media (orientation: landscape) and (max-height: 500px) {
  .screen-2-layout {
    max-width: 620px;
  }
  .runaway-arena {
    height: 150px;
  }
}

/* ==========================================================================
   MÀN 3: GAME "CHẠY ĐI LÀM" (MÀN HÌNH NGANG 320x180)
   ========================================================================== */
.screen-landscape {
  padding: 0;
  background: #1d1526;
}

.game-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    var(--safe-top)
    var(--safe-right)
    var(--safe-bottom)
    var(--safe-left);
}

#speech-bubble {
  position: absolute;
  z-index: 25;
  font-family: "Be Vietnam Pro", sans-serif;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
  color: #5a3a1e;
  background-color: #fff9f0;
  border: 2px solid #291d38;
  border-radius: 4px;
  padding: 3px 8px;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -100%);
}

#speech-bubble::before,
#speech-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-style: solid;
}

#speech-bubble::before {
  top: 100%;
  border-width: 5px 5px 0 5px;
  border-color: #291d38 transparent transparent transparent;
}

#speech-bubble::after {
  top: calc(100% - 2px);
  border-width: 3px 3px 0 3px;
  border-color: #fff9f0 transparent transparent transparent;
}

#speech-bubble.hidden {
  display: none !important;
}

#game-canvas {
  background: #291d38;
  box-shadow: 0 0 0 3px #442d50, 0 12px 32px rgba(0, 0, 0, 0.6);
  touch-action: none;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(29, 21, 38, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(var(--safe-top) + 12px)
    calc(var(--safe-right) + 16px)
    calc(var(--safe-bottom) + 12px)
    calc(var(--safe-left) + 16px);
}

.rotate-card,
.gameover-card,
.confirm-card {
  max-width: 395px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.rotate-card canvas {
  width: 64px;
  height: 64px;
  animation: tiltPhone 1.5s infinite ease-in-out;
}

@keyframes tiltPhone {
  0%, 100% { transform: rotate(-15deg); }
  50% { transform: rotate(15deg); }
}

.gameover-sub {
  font-size: 13px;
  font-weight: 700;
  color: #951350;
}

.score-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.score-box {
  background: #fff9f0;
  border: 2px solid #291d38;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.score-box.highlight {
  background: #fff3c4;
  border-color: #db9a18;
}

.score-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
}

.rarity-pill {
  font-size: 13px;
  background: #fff0f5;
  border: 2px solid #c94a82;
  padding: 4px 12px;
  width: 100%;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  width: 100%;
  margin-top: 2px;
}

.modal-actions .pixel-btn {
  flex: 1;
  font-size: 14px;
}

.confirm-desc {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-dark);
  line-height: 1.45;
  background: #fff9f0;
  padding: 8px 10px;
  border: 2px solid #c94a82;
  width: 100%;
}

.confirm-note {
  font-size: 12px;
  color: #951350;
  font-weight: 600;
}

/* ==========================================================================
   MÀN 4: MỞ LÁ SỐ (CÀO THẺ)
   ========================================================================== */
.scratch-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.scratch-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.rarity-tag {
  font-family: "Be Vietnam Pro", sans-serif;
  font-weight: 800;
  font-size: 12px;
  padding: 2px 10px;
  border: 2px solid #291d38;
  background: #fcd322;
  color: #291d38;
}

.scratch-heading {
  font-size: clamp(17px, 4.5vw, 21px);
}

.scratch-sub {
  font-size: 12.5px;
  color: var(--ink-dark);
  font-weight: 600;
}

.fortune-card-frame {
  position: relative;
  width: 280px;
  height: 220px;
  max-width: 100%;
  border-style: solid;
  border-width: 12px;
  border-image: url("assets/kenney-pixel-ui/9-Slice/Ancient/tan.png") 16 fill stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.fortune-card-frame.tier-normal {
  border-image: url("assets/kenney-pixel-ui/9-Slice/Ancient/tan.png") 16 fill stretch;
  box-shadow: 0 0 0 3px #8a6f30;
}

.fortune-card-frame.tier-rare {
  border-image: url("assets/kenney-pixel-ui/9-Slice/Colored/blue.png") 16 fill stretch;
  box-shadow: 0 0 0 3px #4ab5c9, 0 0 14px rgba(74, 181, 201, 0.5);
}

.fortune-card-frame.tier-ssr {
  border-image: url("assets/kenney-pixel-ui/9-Slice/Colored/yellow.png") 16 fill stretch;
  box-shadow: 0 0 0 3px #fcd322, 0 0 18px rgba(252, 211, 34, 0.85);
}

.ssr-sparkle-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.fortune-card-inner {
  position: relative;
  z-index: 1;
  background: #fff9f0;
  border: 2px solid #291d38;
  width: 100%;
  height: 100%;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
}

.fortune-recipient-line {
  font-size: 12px;
  color: #951350;
  font-weight: 700;
}

.fortune-card-title {
  font-size: 15px;
  color: #d4127b;
}

.fortune-prediction-text {
  font-size: 13px;
  font-weight: 700;
  color: #291d38;
  line-height: 1.35;
}

.fortune-divider {
  height: 2px;
  background: repeating-linear-gradient(90deg, #c94a82 0 6px, transparent 6px 10px);
}

.fortune-wish-text {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
  line-height: 1.35;
}

#scratch-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  cursor: pointer;
  touch-action: none;
  transition: opacity 0.45s ease;
}

.scratch-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 10px;
}

.scratch-progress {
  font-family: "Be Vietnam Pro", sans-serif;
  font-weight: 800;
  font-size: 13px;
  color: #951350;
}

@media (orientation: landscape) and (max-height: 500px) {
  .screen-4-layout {
    max-width: 640px;
  }
  .scratch-container {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }
  .scratch-header {
    width: 42%;
    text-align: left;
    align-items: flex-start;
  }
  .fortune-card-frame {
    width: 260px;
    height: 195px;
  }
  .scratch-footer {
    width: 42%;
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ==========================================================================
   MÀN 5: NHẬN QUÀ & LƯU ẢNH PNG
   ========================================================================== */
.final-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.final-gift-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff9f0;
  border: 2px solid #c94a82;
  padding: 6px 10px;
  width: 100%;
  text-align: left;
}

#final-gift-icon {
  width: 52px;
  height: 46px;
  flex-shrink: 0;
}

.final-heading {
  font-size: 16px;
  color: #d4127b;
}

.pickup-message {
  font-size: 13px;
  font-weight: 700;
  color: #291d38;
  line-height: 1.35;
}

.final-score-line {
  font-size: 12px;
  font-weight: 600;
  color: #951350;
  margin-top: 2px;
}

.saved-card-preview-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#export-card-canvas {
  width: min(230px, 58vw);
  max-height: 44vh;
  height: auto;
  border: 3px solid #291d38;
  box-shadow: 0 4px 0 rgba(41, 29, 56, 0.25);
}

.final-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

.final-actions .pixel-btn {
  flex: 1;
  font-size: 14px;
}

@media (orientation: landscape) and (max-height: 500px) {
  .screen-5-layout {
    max-width: 680px;
  }
  .final-panel {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    grid-template-rows: auto auto;
    gap: 10px;
    align-items: center;
  }
  .final-gift-banner {
    grid-column: 1;
    grid-row: 1;
  }
  .final-actions {
    grid-column: 1;
    grid-row: 2;
    flex-direction: column;
  }
  .saved-card-preview-wrap {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
  #export-card-canvas {
    max-height: 72vh;
    width: auto;
  }
}

/* ==========================================================================
   KHOẢNH KHẮC TRÁI TIM (HEART MOMENT) & THIỆP CHÚC MỪNG "ÔNG BÀ"
   ========================================================================== */
.heart-moment-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(41, 29, 56, 0.45);
  backdrop-filter: blur(2px);
  pointer-events: none;
  animation: heartOverlayFade 0.3s ease-out;
}

@keyframes heartOverlayFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.heart-pulse-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.heart-glow-ring {
  position: absolute;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 105, 180, 0.5) 0%, rgba(255, 182, 193, 0.25) 50%, rgba(255, 255, 255, 0) 75%);
  animation: glowPulse 0.5s ease-out infinite alternate;
}

@keyframes glowPulse {
  from { transform: scale(0.85); opacity: 0.6; }
  to { transform: scale(1.3); opacity: 1; }
}

#heart-burst-canvas {
  position: relative;
  z-index: 2;
  width: 280px;
  height: 280px;
}

.chuc-vui-banner {
  position: absolute;
  bottom: -45px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: popBanner 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
}

@keyframes popBanner {
  0% { transform: scale(0.4); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.chuc-vui-pixel-text {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(41, 29, 56, 0.95);
  border: 3px solid #ffffff;
  border-radius: 20px;
  padding: 8px 16px;
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.85), 0 4px 12px rgba(0, 0, 0, 0.5);
}

.rainbow-greeting {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 15px;
  font-weight: 900;
  background: linear-gradient(90deg, #ff0000, #ff7f00, #ffff00, #00ff00, #00ffff, #0000ff, #8b00ff);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rainbowScroll 2s linear infinite;
}

@keyframes rainbowScroll {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

.sparkle-star {
  font-size: 18px;
  animation: starTwinkle 0.8s ease-in-out infinite alternate;
}

@keyframes starTwinkle {
  0% { transform: scale(0.8) rotate(0deg); }
  100% { transform: scale(1.25) rotate(25deg); }
}

.chuc-vui-meme-wrap {
  border: 4px solid #fcd322;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(255, 105, 180, 0.8);
  overflow: hidden;
  max-width: 240px;
  max-height: 180px;
  margin-bottom: 8px;
}

.chuc-vui-meme-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.fortune-open-score-line {
  font-size: 12px;
  color: #79435b;
  font-weight: 700;
  margin-top: 4px;
}


/* Nút Cóa phủ kín màn hình sau 6 lần né Hem */
.yes-btn.yes-fullscreen {
  position: fixed !important;
  inset: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  border-radius: 0;
  z-index: 999;
  font-size: clamp(48px, 16vw, 140px);
  animation: yes-pop 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
@keyframes yes-pop {
  from { transform: scale(0.6); }
  to { transform: scale(1); }
}

/* Ô tự gõ tên cho bạn bè ("Tên khác…") */
.custom-name-input {
  margin-top: 8px;
  cursor: text;
  font-size: 16px; /* >=16px để iPhone không tự zoom khi gõ */
  user-select: text;
  -webkit-user-select: text;
}
.custom-name-error {
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: #c0203f;
}

/* ===== Bảng xếp hạng ===== */
.lb-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(29, 21, 38, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 12px);
}
.lb-backdrop.hidden { display: none; }
.lb-card {
  width: min(380px, 100%);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
}
.lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #fff9f0;
  border: 2px solid #e6d3b3;
  font-family: "Be Vietnam Pro", sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #3a2a1e;
}
.lb-row.is-me { background: #ffe3ef; border-color: #c94a82; }
.lb-rank {
  flex: 0 0 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: #6b5a48;
}
/* Huy chương pixel: ô vuông có viền + bóng cứng */
.lb-rank.medal-1, .lb-rank.medal-2, .lb-rank.medal-3 {
  color: #291d38;
  border: 2px solid #291d38;
  box-shadow: 2px 2px 0 #291d38;
}
.lb-rank.medal-1 { background: #fcd322; }
.lb-rank.medal-2 { background: #d6dbe4; }
.lb-rank.medal-3 { background: #d9894a; }
.lb-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-family: FatPixVN, monospace; color: #c0203f; }
.lb-me { margin: 0; font-weight: 700; font-size: 13px; color: #951350; }
.lb-empty { font-size: 13px; color: #6b5a48; padding: 10px 0; }
.lb-open-btn { margin-top: 8px; width: 100%; }

/* Lớp chữ nét phủ lên canvas game (HUD, điểm bay) — vị trí/kích thước do JS đặt mỗi khung hình */
#game-text-canvas {
  position: absolute;
  pointer-events: none;
  image-rendering: auto;
  z-index: 2;
}

/* Thiệp 20/10: canh giữa nội dung, lời chúc to rõ (đã bỏ tiêu đề + quẻ lá số) */
.fortune-card-inner {
  justify-content: center;
  gap: 10px;
  padding: 14px 16px;
}
.fortune-recipient-line { font-size: 15px; }
.fortune-wish-text {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  color: #4e3861;
}
.card-ornament {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #c94a82;
}
