/* =============================================
   SUDOLY — Main Stylesheet
   ============================================= */

.hidden { display: none !important; }

/* =============================================
   SVG ICON SYSTEM
   ============================================= */
.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.125em;
  overflow: visible;
  flex-shrink: 0;
}
/* Filled icons (heart, crown, star) have fill set on their symbol paths */
/* Stroke icons: default via symbol attributes */

/* --- Icon colors --- */
/* VIP crown */
.vip-crown-icon,
.vip-crown       { color: #f5b100; }

/* Difficulty icons */
[data-level="easy"]   .diff-icon { color: #43a047; }
[data-level="medium"] .diff-icon { color: #ef6c00; }
[data-level="hard"]   .diff-icon { color: #f9a825; }
[data-level="expert"] .diff-icon { color: #1e88e5; }

/* Home footer */
#btn-stats    { color: var(--primary); }
#btn-settings { color: var(--text-muted); }

/* Game action bar */
#btn-undo      .action-icon { color: var(--text-muted); }
#btn-erase     .action-icon { color: #e53935; }
#btn-pencil    .action-icon { color: #5c6bc0; }
#btn-auto-fill .action-icon { color: #ab47bc; }
#btn-hint      .action-icon { color: #f9a825; }

/* Streak icons in daily panel */
.daily-streak-item:first-child .daily-streak-icon { color: #ef6c00; }
.daily-streak-item:last-child  .daily-streak-icon { color: #f5b100; }

/* Gift popup */
.gift-icon-wrap { color: #e91e63; }

/* Ad placeholder */
.ad-placeholder { color: #90a4ae; }

/* Circle-X overlay */
#daily-retry-overlay .overlay-box > div { color: var(--error); }

/* Autofill confirm */
#autofill-confirm-overlay .overlay-box > div { color: #ab47bc; }

/* --- CSS Variables (Theme: Classic Light default) --- */
:root {
  --bg:               #FFFFFF;
  --bg-secondary:     #F5F5F5;
  --bg-overlay:       rgba(0,0,0,0.45);
  --board-line:       #CCCCCC;
  --board-line-bold:  #333333;
  --primary:          #4A90D9;
  --primary-light:    #E8F0FE;
  --selected:         #C8D9F8;
  --highlight:        #EEF3FD;
  --same-num:         #D6E4F7;
  --text:             #1A1A1A;
  --text-muted:       #888888;
  --text-given:       #1A1A1A;
  --text-filled:      #4A90D9;
  --text-pencil:      #999999;
  --error:            #E53935;
  --error-bg:         #FFEBEE;
  --error-text:       #E53935;
  --btn-daily-bg:     #4A90D9;
  --btn-daily-text:   #FFFFFF;
  --shadow:           0 2px 12px rgba(0,0,0,0.08);
  --radius:           12px;
  --radius-sm:        8px;
  --font:             'Nunito', sans-serif;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  /* dvh = dynamic viewport height: trừ thanh địa chỉ/toolbar trên mobile */
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* --- Screen System --- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transform: translateX(30px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateX(0);
}

/* Game screen: center content thay vì stretch full width */
#screen-game {
  align-items: center;
  overflow-y: auto; /* safety net: nếu viewport quá thấp thì scroll thay vì cắt */
}

/* Game content: giới hạn max-width để laptop không trải full màn hình
   → numpad không bị quá rộng → không làm lệch tính toán chiều cao board */
#game-content {
  width: 100%;
  max-width: 480px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* =============================================
   HOME SCREEN
   ============================================= */
.home-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px 20px 32px;
  gap: 14px;
  overflow-y: auto;
}

.home-hero {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 4px;
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* VIP crown button — góc phải của home hero */
.vip-crown-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 12px;
  transition: background 0.15s;
}
.vip-crown-btn:active { background: var(--highlight); }

.vip-crown-icon {
  font-size: 28px;
  line-height: 1;
  filter: grayscale(1) opacity(0.45);
  transition: filter 0.2s;
}
.vip-crown-btn.is-vip .vip-crown-icon {
  filter: none;
  drop-shadow: 0 0 6px rgba(255,200,0,0.6);
}

.vip-crown-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  line-height: 1;
}
.vip-crown-btn.is-vip .vip-crown-label {
  color: var(--primary);
}

/* Badge "GET" cho free user */
.vip-crown-btn .vip-get-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--primary);
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 6px;
  line-height: 1.4;
  letter-spacing: 0.3px;
}

.logo-icon {
  width: 100px; height: 100px;
  border-radius: 22px;
  box-shadow: 0 6px 20px rgba(74,144,217,0.4);
  display: block;
}

.logo-text {
  font-size: 30px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.btn-daily {
  width: 100%;
  max-width: 320px;
  padding: 15px 20px;
  background: linear-gradient(135deg, var(--btn-daily-bg) 0%, #2d6fc4 100%);
  color: var(--btn-daily-text);
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
  box-shadow: 0 4px 14px rgba(74,144,217,0.35);
  transition: transform 0.1s, box-shadow 0.1s, opacity 0.1s;
}
.btn-daily:active { transform: scale(0.97); box-shadow: none; }

.daily-countdown {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: -4px;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}

.difficulty-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 320px;
}

.btn-difficulty {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--board-line);
  border-left: 4px solid var(--diff-color, var(--primary));
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  transition: background 0.15s, transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.btn-difficulty:hover  { background: var(--highlight); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.btn-difficulty:active { transform: scale(0.98); }

.btn-difficulty[data-level="easy"]   { --diff-color: #4CAF50; }
.btn-difficulty[data-level="medium"] { --diff-color: #FF9800; }
.btn-difficulty[data-level="hard"]   { --diff-color: #F44336; }
.btn-difficulty[data-level="expert"] { --diff-color: #9C27B0; }

.diff-icon { font-size: 20px; flex-shrink: 0; }
.diff-name { flex: 1; text-align: left; }
.diff-arrow {
  font-size: 18px; font-weight: 300;
  color: var(--text-muted);
}
.diff-lock-label {
  font-size: 10px; font-weight: 600;
  color: var(--text-muted);
  margin-left: auto;
}
.btn-difficulty.locked, .btn-daily.locked {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-difficulty.locked:hover { background: var(--bg); box-shadow: none; }
.btn-daily.locked:hover { background: var(--bg-secondary); box-shadow: none; }
.btn-daily #daily-lock-label:not(:empty) {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,0.35);
  border-radius: 10px;
  padding: 1px 8px;
  width: 100%;
  text-align: center;
  margin-top: 4px;
}

.home-footer {
  display: flex;
  gap: 40px;
  margin-top: 4px;
}

.btn-icon-text {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none;
  font-family: var(--font); font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
  padding: 8px;
}
.btn-icon-text .icon { font-size: 26px; }
.btn-icon-text:hover { color: var(--primary); }

/* =============================================
   GAME SCREEN
   ============================================= */
.game-header {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--board-line);
  gap: 8px;
}

.header-hearts {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-back, .btn-pause {
  width: 40px; height: 40px;
  background: none; border: none;
  font-size: 28px; font-weight: 300;
  color: var(--primary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
}
.btn-back:hover, .btn-pause:hover { background: var(--highlight); }

.game-info {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  position: relative;
}

.difficulty-label {
  font-size: 12px; font-weight: 700;
  color: var(--primary);
  text-transform: uppercase; letter-spacing: 1px;
}

.timer {
  font-size: 22px; font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* .mistakes-row removed — hearts moved into .game-header */

.mistake-heart {
  font-size: 22px;
  color: var(--error);
  transition: all 0.3s;
  line-height: 1;
}
.mistake-heart.lost {
  color: var(--board-line);
  filter: grayscale(1);
}
@keyframes heartPop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}
.mistake-heart.pop { animation: heartPop 0.3s ease; }

/* --- Board --- */
.board-wrapper {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 16px 1fr;
  grid-template-rows: 16px 1fr;
  align-items: center;
  justify-items: center;
  padding: 8px 8px 8px 4px;
  /* 100% = width của #game-content (max 480px), không dùng 100vw để tránh lệch trên laptop */
  /* 330px + safe-area-inset-bottom = trừ đủ cho Android nav bar (edge-to-edge) */
  width: min(calc(100% - 16px), calc(100dvh - 330px - env(safe-area-inset-bottom, 0px)), calc(100vh - 330px - env(safe-area-inset-bottom, 0px)), 416px);
  margin: 0 auto;
}

.board-corner { /* empty top-left cell */ }

.board-col-labels,
.board-row-labels {
  display: grid;
  align-items: center;
  justify-items: center;
}
.board-col-labels {
  grid-template-columns: repeat(9, 1fr);
  width: 100%;
  padding: 0 1px; /* align with board border */
}
.board-row-labels {
  grid-template-rows: repeat(9, 1fr);
  height: 100%;
  padding: 1px 0;
}
.board-col-labels span,
.board-row-labels span {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0.6;
  line-height: 1;
  letter-spacing: 0;
}

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  border: 2.5px solid var(--board-line-bold);
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  width: 100%;
  box-shadow: var(--shadow);
}

.cell {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border-right: 1px solid var(--board-line);
  border-bottom: 1px solid var(--board-line);
  cursor: pointer;
  position: relative;
  transition: background 0.12s;
  font-size: clamp(23px, 6vw, 32px);
  font-weight: 700;
  color: var(--text-given);
}

/* Bold borders for 3x3 boxes */
.cell:nth-child(3n)   { border-right: 2px solid var(--board-line-bold); }
.cell:nth-child(9n)   { border-right: none; }
.cell[data-row="2"] , .cell[data-row="5"] { border-bottom: 2px solid var(--board-line-bold); }
.cell[data-row="8"]   { border-bottom: none; }

.cell.selected    { background: var(--selected); }
.cell.highlighted { background: var(--highlight); }
.cell.same-num    { background: var(--same-num); }
.cell.filled      { color: var(--text-filled); font-family: var(--number-font, inherit); }
.cell.error       { background: var(--error-bg); color: var(--error-text); animation: shake 0.35s ease; }
.cell.given       { font-weight: 800; color: var(--text-given); font-family: var(--number-font, inherit); }
.cell.locked      { cursor: default; }
/* Given cells: darker weight, distinct from player-filled */
.cell.given:not(.error) { color: var(--text); }
/* Player-correctly-filled cells: dùng --text-filled để theme độc lập với --primary */
.cell.filled.locked:not(.error) { color: var(--text-filled); font-weight: 700; }

/* Note highlight when a number is active */
.cell.note-highlight { background: var(--same-num); }
.pencil-num.pencil-num-active { color: var(--primary); font-weight: 800; }

/* Pencil marks */
.cell .pencil-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 90%; height: 90%;
  position: absolute;
}
.pencil-num {
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(9px, 2.4vw, 13px);
  font-weight: 600;
  color: var(--text-pencil);
  line-height: 1;
}

/* --- Action Bar --- */
.action-bar {
  display: flex;
  justify-content: space-around;
  padding: 6px 8px;
  border-top: 1px solid var(--board-line);
}

.btn-action {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  min-width: 64px;
}
.btn-action:hover  { background: var(--highlight); }
.btn-action:active { background: var(--selected); transform: scale(0.95); }
.btn-action.active {
  background: var(--primary-light);
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.btn-action.active .action-label { color: var(--primary); font-weight: 700; }
.btn-action.active .action-icon { filter: drop-shadow(0 0 2px var(--primary)); }

.action-icon { font-size: 22px; line-height: 1; }

/* Auto-complete ready state */
@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(76,175,80,0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(76,175,80,0); }
}
.btn-action.auto-complete-ready {
  background: #e8f5e9;
  border: 2px solid #4CAF50;
  animation: pulse-green 1.4s ease infinite;
}
.btn-action.auto-complete-ready .action-label { color: #2e7d32; font-weight: 800; }
.btn-action.auto-complete-ready .action-icon  { font-size: 24px; }
.action-label {
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  font-family: var(--font);
  letter-spacing: 0.2px;
}
.notes-onoff {
  font-size: 9px; font-weight: 800;
  background: var(--board-line);
  color: var(--text-muted);
  border-radius: 3px;
  padding: 1px 4px;
  margin-left: 2px;
  vertical-align: middle;
}
.btn-action.active .notes-onoff {
  background: var(--primary);
  color: #fff;
}

/* --- Numpad --- */
.numpad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
  padding: 8px 10px 24px;
}

.btn-num {
  aspect-ratio: 1;
  font-family: var(--number-font, var(--font));
  background: var(--bg-secondary);
  border: none;
  border-radius: var(--radius-sm);
  font-size: clamp(19px, 4.8vw, 26px);
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s, transform 0.1s, color 0.1s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.btn-num:active   { transform: scale(0.88); box-shadow: none; }
.btn-num:hover    { background: var(--primary-light); color: var(--primary); }
.btn-num.disabled { opacity: 0.25; pointer-events: none; }
.btn-num.active   { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(74,144,217,0.4); }
.btn-num.paint-active { background: var(--primary); color: #fff; outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px var(--primary); }

/* Numpad wrapper — paint-strip floats above, no layout shift */
.numpad-wrap {
  position: relative;
}

/* Paint mode bubble */
.paint-strip {
  position: fixed;
  width: auto;
  white-space: nowrap;
  padding: 6px 10px 6px 12px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: fadeIn 0.15s ease;
  --arrow-x: 50%;
}
.paint-strip::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: var(--arrow-x);
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-bottom: none;
  border-top-color: var(--primary);
}
.paint-strip.hidden { display: none !important; }
.paint-strip-num { font-weight: 800; }
.paint-exit-btn { background: none; border: none; color: rgba(255,255,255,0.7); font-size: 1rem; cursor: pointer; margin-left: 2px; line-height: 1; padding: 0 2px; }
.paint-exit-btn:hover { color: #fff; }

/* Banner ad placeholder (bottom of screen) */
#banner-ad {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 50px;
  background: var(--bg);
  border-top: 1px solid var(--board-line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  z-index: 50;
}
#banner-ad:empty { display: none; }
/* Push game content above banner when ad is showing */
body.has-banner #app, body.has-banner .screen { padding-bottom: 50px; }


/* =============================================
   COMPLETE SCREEN
   ============================================= */
/* Block scroller — flex layout của .screen sẽ compress content, dùng block thay thế */
#screen-complete { display: block; overflow-y: auto; }

.complete-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 32px 24px;
  gap: 20px;
  text-align: center;
  overflow-y: auto;
}

.complete-emoji { font-size: 72px; animation: bounce 0.6s ease; }

@keyframes bounce {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.complete-container h2 {
  font-size: 28px; font-weight: 800;
  color: var(--primary);
}

.complete-stats {
  display: flex;
  gap: 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 20px 32px;
}

.stat-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.stat-label {
  font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase;
  text-align: center;
  /* min-height = 2 dòng để label dài/ngắn đều thẳng hàng với value */
  min-height: 2.8em;
  display: flex; align-items: flex-end; justify-content: center;
}
.stat-value { font-size: 22px; font-weight: 800; color: var(--text); }

.new-record-badge {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff;
  font-size: 13px; font-weight: 700;
  padding: 6px 16px;
  border-radius: 99px;
  letter-spacing: 0.5px;
}

.complete-board-wrap { margin: 0 auto; width: min(280px, 90vw); }
.complete-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  border: 2px solid var(--board-line-bold);
  border-radius: 8px;
  overflow: hidden;
}
.complete-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  border-right: 1px solid var(--board-line);
  border-bottom: 1px solid var(--board-line);
  background: var(--bg);
  color: var(--text-filled);
  cursor: pointer;
}
.complete-cell.given { color: var(--text-given); font-family: var(--number-font, inherit); }
.complete-cell.filled { font-family: var(--number-font, inherit); }
.complete-cell.box-top { border-top: 2px solid var(--board-line-bold); }
.complete-cell.box-left { border-left: 2px solid var(--board-line-bold); }
.complete-cell.hl-num  { background: var(--same-num); }
.complete-cell.hl-line { background: var(--highlight); }

.streak-section {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 4px;
}
.streak-item {
  flex: 1;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px 8px;
  text-align: center;
}
.streak-item .val { font-size: 36px; font-weight: 800; color: var(--primary); }
.streak-item .lbl { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-top: 4px; }

/* =============================================
   SETTINGS + STATS SCREENS
   ============================================= */
.settings-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}

.settings-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--board-line);
}
.settings-header h2 { font-size: 20px; font-weight: 800; }

.settings-section {
  padding: 20px 16px 8px;
  border-bottom: 1px solid var(--board-line);
}
.settings-section h3 {
  font-size: 13px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 12px;
}

/* Language list */
.lang-list {
  display: flex; flex-direction: column; gap: 4px;
}
.btn-lang {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: none; border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 15px; font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-lang:hover    { background: var(--highlight); }
.btn-lang.selected { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.lang-native { font-size: 13px; color: var(--text-muted); }
.btn-lang.selected .lang-native { color: var(--primary); }

/* Theme list */
.theme-list {
  display: flex; flex-direction: column; gap: 4px;
}
.btn-theme {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: none; border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 15px; font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-theme:hover    { background: var(--highlight); }
.btn-theme.selected { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.theme-preview {
  display: flex; gap: 4px;
}
.theme-swatch {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.1);
}

/* Toggle switch */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0;
  cursor: pointer;
  font-size: 15px; font-weight: 600;
}
.toggle-row input { display: none; }
.toggle-slider {
  width: 48px; height: 26px;
  background: var(--board-line);
  border-radius: 13px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle-row input:checked + .toggle-slider { background: var(--primary); }
.toggle-row input:checked + .toggle-slider::after { transform: translateX(22px); }
.toggle-desc {
  font-size: 12px; color: var(--text-muted, #999);
  margin: 2px 0 0; line-height: 1.4;
}
.toggle-row > div { flex: 1; }

/* Settings select dropdown */
.settings-select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--board-line);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.settings-select:focus { outline: none; border-color: var(--primary); }

/* Display name row */
.name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}
.name-row > div { flex: 1; }
.settings-lb-preview { font-size: 11px; opacity: 0.45; margin-top: 2px; }
.btn-change-name {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
}
.btn-change-name:disabled { cursor: default; }

/* Name change dialog */
.name-change-sheet {
  background: var(--bg);
  border-radius: 16px;
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.name-change-sheet h3 { margin: 0; font-size: 18px; }
.name-change-warning {
  margin: 0;
  font-size: 13px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.4;
}
.name-change-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--board-line);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  box-sizing: border-box;
}
.name-change-input:focus { outline: none; border-color: var(--primary); }
.name-change-input.input-error { border-color: #ef4444; }
.name-change-error {
  margin: 0;
  font-size: 12px;
  color: #ef4444;
  min-height: 16px;
}
.name-change-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Conflict flash (numpadBlock OFF) */
@keyframes conflictFlash {
  0%   { background: rgba(220,50,50,0.15); }
  50%  { background: rgba(220,50,50,0.4); }
  100% { background: rgba(220,50,50,0.15); }
}
.cell.conflict-flash { animation: conflictFlash 0.4s ease; }

/* Stats grid */
.stats-grid {
  padding: 20px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-card .val { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-card .lbl { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; }

/* =============================================
   HINT BUBBLE
   ============================================= */
.hint-bubble {
  position: fixed;
  z-index: 200;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  padding: 10px 12px;
  max-width: 220px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: popIn 0.2s ease;
  transition: opacity 0.2s;
}
.hint-bubble.hidden { display: none; }

@keyframes popIn {
  0%   { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

/* Mũi tên chỉ vào ô */
.hint-bubble-arrow {
  position: absolute;
  width: 10px; height: 10px;
  background: var(--text);
  transform: rotate(45deg);
}
.hint-bubble.arrow-top    .hint-bubble-arrow { top: -5px;    left: 20px; }
.hint-bubble.arrow-bottom .hint-bubble-arrow { bottom: -5px; left: 20px; }
.hint-bubble.arrow-left   .hint-bubble-arrow { left: -5px;   top: 14px;  }
.hint-bubble.arrow-right  .hint-bubble-arrow { right: -5px;  top: 14px;  }

.hint-bubble-content {
  display: flex; align-items: center; gap: 8px;
  flex: 1;
}

#hint-bubble-text {
  font-size: 13px; font-weight: 600;
  line-height: 1.4;
  flex: 1;
}

.hint-bubble-why {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px; font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.hint-bubble-why:hover { opacity: 0.85; }

.hint-bubble-close {
  background: none; border: none;
  color: rgba(255,255,255,0.6);
  font-size: 18px; font-weight: 300;
  cursor: pointer; padding: 0 0 0 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}
.hint-bubble-close:hover { color: #fff; }

/* Hint count badge trên nút Hint */
.hint-count {
  position: absolute;
  top: 3px; right: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 10px; font-weight: 800;
  min-width: 20px; height: 20px;
  padding: 0 4px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.hint-count.empty { background: var(--text-muted); }

/* ---- "Watch Ad" play icon — pure CSS, no SVG/emoji ---- */
/* Dùng align-self:center để force vertical center trên mọi WebView */
.ad-play-icon {
  width: 18px; height: 18px; min-width: 18px;
  background: #FF8F00;
  border-radius: 4px;
  display: block;
  flex-shrink: 0;
  align-self: center;          /* explicit: không phụ thuộc parent align-items */
  position: relative;
  transform: translateY(-1px); /* visual center compensation */
}
.ad-play-icon::after {
  content: '';
  position: absolute;
  top: 50%; left: 55%;
  transform: translate(-50%, -50%);
  width: 0; height: 0;
  border-style: solid;
  border-width: 4.5px 0 4.5px 8px;
  border-color: transparent transparent transparent #fff;
}
/* Size variants */
.ad-play-icon.sm {
  width: 12px; height: 12px; min-width: 12px;
  border-radius: 3px;
}
.ad-play-icon.sm::after {
  border-width: 3px 0 3px 5.5px;
}
.ad-play-icon.md {
  width: 16px; height: 16px; min-width: 16px;
}
.ad-play-icon.md::after {
  border-width: 4px 0 4px 7px;
}

/* Badge "watch ad" nhỏ ở góc — chứa .ad-play-icon.sm */
.ad-corner-badge {
  position: absolute;
  top: 2px; left: 12px;
  pointer-events: none;
}
.btn-action { position: relative; }

/* =============================================
   LOADING SCREEN
   ============================================= */
.loading-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}
.loading-dots span {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--dot-color, var(--primary));
  animation: loadingBounce 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes loadingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1.1); opacity: 1; }
}
@keyframes loadingPulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 6px 24px rgba(0,0,0,0.18); }
  50%       { transform: scale(1.06); box-shadow: 0 10px 32px rgba(74,144,217,0.35); }
}

/* =============================================
   ONBOARDING
   ============================================= */
/* Welcome screen */
.welcome-box {
  background: var(--bg);
  border-radius: 20px;
  padding: 32px 24px 24px;
  max-width: 340px;
  width: calc(100% - 40px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.welcome-icon {
  width: 72px; height: 72px;
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  margin-bottom: 4px;
}
.welcome-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}
.welcome-body {
  font-size: 15px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}
.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}
.welcome-actions .btn-primary { font-size: 16px; padding: 14px; }
.welcome-actions .btn-secondary { font-size: 14px; }

/* Tutorial bubble */
#tut-bubble {
  position: fixed;
  z-index: 400;
  background: var(--primary);
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  --arrow-x: 50%;
}
#tut-bubble.hidden { display: none; }
/* Arrow pointing UP (bubble below target) */
#tut-bubble[data-arrow="up"]::before {
  content: '';
  position: absolute;
  top: -9px;
  left: var(--arrow-x);
  transform: translateX(-50%);
  border: 9px solid transparent;
  border-top: none;
  border-bottom-color: var(--primary);
}
/* Arrow pointing DOWN (bubble above target) */
#tut-bubble[data-arrow="down"]::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: var(--arrow-x);
  transform: translateX(-50%);
  border: 9px solid transparent;
  border-bottom: none;
  border-top-color: var(--primary);
}
#tut-text { flex: 1; }
#tut-skip {
  background: rgba(255,255,255,0.22);
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Tutorial target highlight */
.tut-target {
  animation: tutPulse 1.1s ease-in-out infinite !important;
  z-index: 10;
  position: relative;
}
@keyframes tutPulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--primary), 0 0 0 5px rgba(59,130,246,0.35); }
  50%       { box-shadow: 0 0 0 2px var(--primary), 0 0 0 9px rgba(59,130,246,0.1); }
}

/* =============================================
   TOAST
============================================= */
#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.82);
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}
#toast.toast-show { opacity: 1; }
#toast.toast-hide { opacity: 0; }
#toast.toast-has-action { pointer-events: auto; }
.toast-action-btn {
  background: var(--primary, #6c63ff);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.toast-action-btn:active { opacity: 0.8; }

/* =============================================
   OVERLAY
   ============================================= */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
}
.overlay.hidden { display: none; }

.overlay-box {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 32px 40px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  min-width: 240px;
}
.overlay-box h2 { font-size: 22px; font-weight: 800; }

/* Gift popup */
.gift-box {
  max-width: 320px;
  width: calc(100% - 48px);
  padding: 36px 28px 28px;
  gap: 12px;
  text-align: center;
}
.gift-icon-wrap {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 4px;
  animation: gift-bounce 0.6s ease both;
}
@keyframes gift-bounce {
  0%   { transform: scale(0.6); opacity: 0; }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.gift-box h3 {
  font-size: 22px;
  font-weight: 800;
  margin: 0;
}
.gift-body {
  font-size: 15px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}
.gift-body strong { color: var(--text); font-size: 15px; vertical-align: baseline; }
.gift-cta {
  width: 100%;
  font-size: 15px;
  line-height: 1.2;
  padding: 14px 16px;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark, var(--primary)));
  box-shadow: 0 4px 16px color-mix(in srgb, var(--primary) 40%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.gift-ad-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 0;
}
.gift-cta-text {
  line-height: 1;
}
#btn-gift-skip {
  font-size: 14px;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
}
#btn-gift-skip:hover { color: var(--text); }

/* =============================================
   BOTTOM SHEET (hint detail)
   ============================================= */
.bottom-sheet {
  position: absolute;
  inset: 0;
  z-index: 150;
  pointer-events: all;
}
.bottom-sheet.hidden { display: none; }

.bottom-sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.3);
}

.bottom-sheet-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
  animation: slideUp 0.25s ease;
  max-height: 55%;
  overflow-y: auto;
  height: auto;
}
#daily-sheet .bottom-sheet-panel {
  max-height: calc(100% - env(safe-area-inset-top, 24px));
  overflow-y: auto;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.bottom-sheet-handle {
  width: 36px; height: 4px;
  background: var(--board-line);
  border-radius: 2px;
  margin: 8px auto 0;
}

.bottom-sheet-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--board-line);
  justify-content: space-between;
}

.hint-badge-sm { font-size: 20px; }

.hint-technique {
  flex: 1;
  font-size: 13px; font-weight: 800;
  color: var(--primary);
  text-transform: uppercase; letter-spacing: 1px;
}

.bottom-sheet-close {
  background: var(--bg-secondary); border: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 18px; font-weight: 300;
  color: var(--text-muted);
  cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.bottom-sheet-close:hover { background: var(--highlight); }

.bottom-sheet-body {
  padding: 10px 16px 10px;
  display: flex; flex-direction: column; gap: 8px;
}

.hint-body {
  font-size: 14px; font-weight: 600;
  color: var(--text);
  line-height: 1.7;
}
.hint-body .hl { color: var(--primary); font-weight: 800; }
.hint-body .hl-dim { color: var(--text-muted); font-size: 0.85em; }

.hint-answer {
  font-size: 14px; font-weight: 600;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 10px;
}
.hint-value {
  font-size: 28px; font-weight: 800;
  color: var(--primary);
  background: var(--primary-light);
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn-primary, .btn-secondary {
  width: 100%; max-width: 280px;
  padding: 14px;
  border: none; border-radius: var(--radius);
  font-family: var(--font); font-size: 16px; font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(74,144,217,0.3);
}
.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text);
}

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-4px); }
  40%       { transform: translateX(4px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}
.shake { animation: shake 0.35s ease; }

@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.pop { animation: pop 0.2s ease; }

/* =============================================
   DAILY CALENDAR
   ============================================= */
/* Daily streak badge trên home button */
.daily-streak-badge {
  margin-left: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

/* ── Streak stats ── */
.daily-streak-row {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  margin-bottom: 4px;
}
.daily-streak-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 12px 8px 10px;
  background: linear-gradient(145deg, #4A90D9 0%, #2d6fc4 100%);
  border-radius: 18px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(74,144,217,0.25);
}
.daily-streak-icon { font-size: 18px; line-height: 1; margin-bottom: 2px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2)); }
.daily-streak-num  { font-size: 40px; font-weight: 900; color: #fff; line-height: 1; letter-spacing: -2px; text-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.daily-streak-lbl  { font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.75); text-transform: uppercase; letter-spacing: 0.8px; margin-top: 3px; }

/* ── 4×7 Day grid ── */
.daily-grid-wrap { }
.daily-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(4, auto);
  gap: 5px;
}

/* Base card */
.dc-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 7px 4px 6px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: var(--bg-secondary);
  transition: transform 0.1s, opacity 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.dc-card:active:not(:disabled) { transform: scale(0.93); }

.dc-day-name { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; opacity: 0.6; }
.dc-day-num  { font-size: 18px; font-weight: 800; line-height: 1.15; }
.dc-icon     { font-size: 11px; line-height: 1; margin-top: 1px; }

/* Today — nổi bật */
.dc-today {
  background: linear-gradient(145deg, var(--primary) 0%, #2d6fc4 100%);
  box-shadow: 0 4px 12px rgba(74,144,217,0.35);
  grid-column: span 1;
}
.dc-today .dc-day-name { color: rgba(255,255,255,0.75); opacity: 1; }
.dc-today .dc-day-num  { color: #fff; font-size: 22px; }
.dc-today .dc-icon     { color: rgba(255,255,255,0.9); font-size: 13px; }

/* Won */
.dc-won {
  background: color-mix(in srgb, var(--primary) 12%, var(--bg-secondary));
  cursor: default;
}
.dc-won .dc-day-num { color: var(--primary); }
.dc-won .dc-icon    { color: var(--primary); font-size: 13px; }

/* Lost */
.dc-lost { background: color-mix(in srgb, var(--error) 10%, var(--bg-secondary)); }
.dc-lost .dc-day-num { color: var(--error); }
.dc-lost .dc-icon    { color: var(--error); font-size: 11px; }

/* Free (past, need ad) */
.dc-free { background: var(--bg-secondary); opacity: 0.85; }
.dc-free .dc-day-num { color: var(--text); }
.dc-free .dc-icon    { color: var(--text-muted); font-size: 10px; }

/* VIP open */
.dc-vip-open .dc-day-num { color: var(--text); }
.dc-vip-open .dc-icon    { color: var(--primary); }

/* VIP locked — rows 2-4 cho free user */
.dc-vip-locked {
  opacity: 0.5;
  cursor: pointer;
  background: var(--bg-secondary);
}
.dc-vip-locked .dc-day-num { color: var(--text-muted); font-size: 15px; }
.dc-vip-locked .dc-icon    { font-size: 13px; opacity: 0.8; }

/* Row 2-4 (VIP zone): thêm đường kẻ phân cách */
.daily-grid .dc-card:nth-child(n+8) {
  position: relative;
}
.daily-grid .dc-card:nth-child(8) {
  border-top-left-radius: 14px;
}

/* Free + ads indicator */
.dc-free-ads .dc-icon { font-size: 12px; }
.dc-free-ads .dc-day-num { color: var(--text); }

/* Nút xem năm */
.btn-daily-year {
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  border: 1.5px solid var(--board-line);
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-daily-year:active { background: var(--bg-secondary); }

/* Year heatmap overlay */
#year-view-overlay {
  align-items: flex-end;
}
.year-view-box {
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px 32px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}
.year-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.year-view-header button {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.year-heatmap-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
}
.yhm-nav-btn {
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.yhm-nav-btn:active { color: var(--primary); }
.year-heatmap-scroll {
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 6px;
  flex: 1;
  min-width: 0;
}
.year-heatmap-scroll::-webkit-scrollbar { display: none; }
.year-heatmap {
  display: flex;
  gap: 3px;
  width: max-content;
}
.yhm-col { display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; }
.yhm-month {
  display: block;
  height: 12px;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  line-height: 12px;
  opacity: 0.65;
}
.yhm-cell {
  width: 16px; height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
}
.yhm-won    { background: var(--primary); }
.yhm-missed { background: var(--board-line); }
.yhm-empty  { background: var(--board-line); opacity: 0.45; }
.year-heatmap-legend {
  display: flex;
  gap: 14px;
  margin-top: 14px;
  justify-content: center;
}
.yhm-legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.yhm-legend-dot { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }

/* VIP zone overlay label — hiện ở cell thứ 8 (đầu row 2) */
.dc-vip-row-label {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  padding: 3px 2px 1px;
  opacity: 0.65;
}
.dc-vip-row-label::before,
.dc-vip-row-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--board-line);
}

/* =============================================
   VIP SCREEN
   ============================================= */
#screen-vip { overflow-y: auto; }

.vip-container {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 0 20px 40px;
  max-width: 420px;
  margin: 0 auto;
  position: relative;
}

#btn-vip-back {
  position: absolute;
  top: 12px; left: 0;
}

/* Hero */
.vip-hero {
  text-align: center;
  padding: 40px 0 16px;
}
.vip-crown {
  font-size: 44px;
  line-height: 1;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 12px rgba(255,190,30,0.4));
}
.vip-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #4A90D9 0%, #9b59b6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 4px;
}
.vip-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

/* Benefits list */
.vip-benefits {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 16px;
}
.vip-benefit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: 12px;
}
.vip-benefit-icon {
  font-size: 26px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}
/* 5 tim VIP trên benefit screen */
.vip-lives-icon {
  display: flex;
  flex-wrap: wrap;
  width: 36px;
  gap: 1px;
  color: var(--error);
  font-size: 12px;
}
.vip-lives-icon .icon { width: 12px; height: 12px; }

/* Tim thêm (m4, m5) — ẩn mặc định, hiện khi VIP */
.vip-heart { color: #ff69b4; }

.vip-no-ads-icon {
  font-size: 10px;
  font-weight: 900;
  color: #fff;
  background: var(--error);
  border-radius: 6px;
  padding: 4px 5px;
  letter-spacing: 0.5px;
  text-decoration: line-through;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}
.vip-benefit-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.vip-benefit-text strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.vip-benefit-text span {
  font-size: 12px;
  color: var(--text-muted);
}

/* Pricing */
.vip-pricing {
  text-align: center;
  margin-bottom: 12px;
}
.vip-price-main {
  font-size: 34px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -1.5px;
  line-height: 1;
}
.vip-price-period {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}
.vip-offer-badge {
  display: inline-block;
  background: linear-gradient(135deg, #ff6b35, #f7c948);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}
.vip-price-original {
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: line-through;
  margin-right: 6px;
}

/* CTA */
.vip-cta {
  width: 100%;
  padding: 14px 18px;
  border-radius: 18px;
  border: none;
  background: linear-gradient(135deg, #4A90D9 0%, #9b59b6 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(74,144,217,0.35);
  transition: transform 0.1s, box-shadow 0.1s;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
  overflow: visible;
}
.vip-discount-badge {
  position: absolute;
  top: -14px;
  right: -10px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff5252, #c0392b);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(192,57,43,0.5);
  transform: rotate(12deg);
  letter-spacing: -0.3px;
}
.vip-cta:active { transform: scale(0.97); box-shadow: none; }
.vip-btn-price {
  display: block;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.85;
}
.vip-btn-price s { opacity: 0.65; }
.vip-btn-cta {
  display: block;
  font-size: 17px;
  font-weight: 800;
}

.vip-legal {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* Restore purchases link-button */
.vip-restore-btn {
  display: block;
  margin: 12px auto 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.7;
}
.vip-restore-btn:active { opacity: 0.5; }

/* Disabled state khi đang process */
.vip-cta:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }
.vip-restore-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Active VIP state */
.vip-active-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  background: linear-gradient(135deg, color-mix(in srgb, #4A90D9 15%, var(--bg-secondary)), var(--bg-secondary));
  border-radius: 14px;
  border: 1.5px solid var(--primary);
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
}

/* === Cheat Panel === */
#btn-cheat-float {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0,0,0,0.15);
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 9999;
  opacity: 0.7;
  transition: opacity 0.2s;
}
#btn-cheat-float:hover { opacity: 1; }
#cheat-panel {
  position: fixed;
  bottom: 64px;
  right: 16px;
  z-index: 9999;
  background: var(--cell-bg, var(--bg));
  border: 1.5px solid var(--board-line);
  border-radius: 14px;
  padding: 14px;
  min-width: 200px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
#cheat-panel.hidden { display: none; }
.cheat-panel-title { font-weight: 700; margin-bottom: 10px; font-size: 0.9rem; color: var(--text-muted); }
.cheat-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
}
.cheat-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.cheat-row select {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1.5px solid var(--board-line);
  background: var(--cell-bg, var(--bg));
  color: var(--text);
  font-size: 0.8rem;
}
.cheat-row .cheat-btn {
  width: auto;
  margin-bottom: 0;
  padding: 6px 12px;
  flex-shrink: 0;
}

/* =============================================
   AD OVERLAY
   ============================================= */

.ad-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.ad-overlay.hidden { display: none; }
.ad-box {
  background: #1a1a1a;
  border-radius: 16px;
  width: min(320px, 90vw);
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
}
.ad-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #aaa;
}
.ad-placeholder {
  font-size: 80px;
  line-height: 1;
}
.ad-timer {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
}
.ad-skip {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-skip.hidden { display: none; }
#ad-loading, #ad-counting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.ad-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ad-spin 0.8s linear infinite;
}
@keyframes ad-spin { to { transform: rotate(360deg); } }

/* --- Penalty Toast (+1:00 ⏱ nổi lên khi điền sai) --- */
.penalty-toast {
  position: absolute;
  font-size: 14px;
  font-weight: 700;
  color: #ff4d4d;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(0);
  transition: none;
}
.penalty-toast-show {
  opacity: 1;
  transform: translateY(-28px);
  transition: opacity 0.2s ease, transform 0.4s ease;
}
.penalty-toast-hide {
  opacity: 0;
  transform: translateY(-48px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* =============================================
   LEADERBOARD SCREEN
   ============================================= */

/* Reuse settings-header style cho leaderboard header */
.lb-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}

/* Leaderboard header: date-nav | close (1 hàng) */
.lb-header {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--board-line);
  flex-shrink: 0;
  gap: 8px;
}
.btn-lb-close {
  width: 36px; height: 36px;
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-lb-close:hover { background: var(--highlight); }
.btn-lb-close .icon { width: 20px; height: 20px; }

/* Date navigation */
.lb-date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
}
.lb-nav-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--board-line);
  cursor: pointer;
  color: var(--text);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 22px;
  line-height: 1;
  font-weight: 300;
  transition: background 0.15s;
  min-width: 44px;
  text-align: center;
}
.lb-nav-btn:hover { background: var(--highlight); }
.lb-nav-btn:disabled { opacity: 0.25; cursor: default; }

.lb-date-label {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

/* My entry khi nằm ngoài top 50 */
.lb-my-entry {
  padding: 0 16px;
  flex-shrink: 0;
}

.lb-my-entry-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  margin-bottom: 8px;
  font-weight: 700;
}

.lb-my-entry-card .lb-name {
  flex: 1;
}

/* Main list */
.lb-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 24px;
}

/* Header row (labels) */
.lb-header-row {
  display: grid;
  grid-template-columns: 52px 1fr 70px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--board-line);
  margin-bottom: 4px;
}

/* Data row */
.lb-row {
  display: grid;
  grid-template-columns: 52px 1fr 70px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  transition: background 0.15s;
}

.lb-row:nth-child(even) {
  background: var(--highlight);
}

/* Highlight người dùng hiện tại */
.lb-row-me {
  background: color-mix(in srgb, var(--primary) 15%, transparent) !important;
  font-weight: 700;
}

/* Rank cell */
.lb-rank {
  font-size: 16px;
  font-weight: 800;
  min-width: 40px;
}

/* Name cell */
.lb-name {
  flex: 1;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* UUID tag suffix — phân biệt trùng tên */
.lb-tag {
  font-size: 11px;
  opacity: 0.45;
  font-weight: 400;
  margin-left: 2px;
}

/* Time cell */
.lb-time {
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

/* Total completions count */
.lb-total {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0 8px;
  min-height: 20px;
}

/* Loading / empty state */
.lb-loading,
.lb-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  padding: 40px 16px;
}
