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

:root {
  --bg:          #0f1117;
  --surface:     #1a1d2e;
  --surface-2:   #252840;
  --tile-bg:     #1e2235;
  --tile-hover:  #272b42;
  --tile-sel:    #3a3f6b;
  --tile-sel-border: #6c72c9;
  --border:      #2e3250;
  --text:        #e8eaf0;
  --text-muted:  #8890b0;
  --accent:      #6c72c9;
  --accent-dark: #4e54a8;
  --accent-glow: rgba(108,114,201,0.3);
  --green:       #6aaa64;
  --yellow:      #c9b458;
  --orange:      #d48832;
  --red:         #d1495b;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 4px 20px rgba(0,0,0,0.4);
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
}

html { font-size: 16px; }

body {
  background: linear-gradient(180deg, #0f1117 0%, #131628 50%, #0f1117 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.logo-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.logo {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #fff;
  background: linear-gradient(135deg, #fff 0%, #c0c4e8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.puzzle-num {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  font-weight: 700;
  min-width: 44px;
  min-height: 44px;
}

.icon-btn:hover { background: var(--surface); transform: scale(1.06); }
.icon-btn:active { transform: scale(0.95); }

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main {
  width: 100%;
  max-width: 560px;
  padding: 16px 12px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* ── Solved Groups ────────────────────────────────────────────────────────── */
.solved-groups {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.solved-card {
  width: 100%;
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}

.solved-card-enter {
  animation: slideDown 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-18px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.solved-category {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.85;
}

.solved-items {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* ── Grid ─────────────────────────────────────────────────────────────────── */
.grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

/* ── Tile ─────────────────────────────────────────────────────────────────── */
.tile {
  background: var(--tile-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: clamp(0.65rem, 2.4vw, 0.88rem);
  font-weight: 700;
  cursor: pointer;
  padding: 10px 6px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  transition: background 0.12s, border-color 0.12s, transform 0.12s, box-shadow 0.12s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.08) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.15s;
}

.tile:hover {
  background: var(--tile-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.tile:hover::after { opacity: 1; }

.tile:active { transform: scale(0.95) translateY(0); }

.tile.selected {
  background: var(--tile-sel);
  border-color: var(--tile-sel-border);
  color: #fff;
  box-shadow: 0 0 0 3px var(--accent-glow), 0 4px 16px var(--accent-glow);
  animation: tilePop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tile.selected:hover { transform: translateY(-2px); }

@keyframes tilePop {
  0%   { transform: scale(0.92); }
  60%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ── Tile animations ──────────────────────────────────────────────────────── */
.tile-shake {
  animation: tileShake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) !important;
}

@keyframes tileShake {
  0%, 100% { transform: translateX(0); }
  15%  { transform: translateX(-6px) rotate(-1.5deg); }
  30%  { transform: translateX(6px) rotate(1.5deg); }
  45%  { transform: translateX(-5px) rotate(-1deg); }
  60%  { transform: translateX(5px) rotate(1deg); }
  75%  { transform: translateX(-3px); }
  90%  { transform: translateX(3px); }
}

.tile-flip-out {
  animation: tileFlipOut 0.38s ease-in forwards;
}

@keyframes tileFlipOut {
  0%   { transform: rotateY(0) scale(1); opacity: 1; }
  50%  { transform: rotateY(90deg) scale(0.8); opacity: 0.4; }
  100% { transform: rotateY(90deg) scale(0.6); opacity: 0; }
}

.tile-shuffle {
  animation: tileShuffle 0.35s ease both;
}

@keyframes tileShuffle {
  from { opacity: 0; transform: scale(0.85) rotate(-3deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* ── Mistakes ─────────────────────────────────────────────────────────────── */
.mistakes-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mistakes-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.mistakes-dots {
  display: flex;
  gap: 8px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--border);
  transition: background 0.3s, border-color 0.3s, transform 0.3s;
}

.dot.dot-active {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.dot.dot-used {
  background: transparent;
  border-color: var(--border);
  opacity: 0.35;
  transform: scale(0.8);
}

/* ── Controls ─────────────────────────────────────────────────────────────── */
.controls {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
}

.btn {
  border: none;
  border-radius: 100px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 12px 22px;
  min-height: 44px;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s, opacity 0.15s;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.96); }

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  color: var(--text);
}

.btn-sm {
  font-size: 0.78rem;
  padding: 6px 12px;
  min-height: 34px;
  border-radius: var(--radius-sm);
}

.btn-secondary:not(:disabled):hover {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:not(:disabled):hover {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  filter: brightness(1.12);
  box-shadow: 0 4px 24px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-share {
  background: linear-gradient(135deg, var(--green) 0%, #4d8f47 100%);
  color: #fff;
  font-size: 1rem;
  padding: 14px 28px;
  box-shadow: 0 4px 16px rgba(106,170,100,0.35);
}

.btn-share:hover {
  background: linear-gradient(135deg, #7aba74 0%, #5da057 100%);
  transform: translateY(-1px);
}

/* ── Share modal ──────────────────────────────────────────────────────────── */
.modal-share { max-width: 360px; width: 100%; }

.share-modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 12px;
  text-align: left;
  justify-content: flex-start;
  transition: filter 0.15s, transform 0.15s;
}

.share-btn:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.share-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.share-btn-x       { background: #000; color: #fff; }
.share-btn-facebook { background: #1877f2; color: #fff; }
.share-btn-linkedin { background: #0a66c2; color: #fff; }
.share-btn-copy    { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

.share-btn-copy.copied { background: var(--green); color: #fff; border-color: var(--green); }

.spin {
  animation: spinIcon 0.4s ease;
}

@keyframes spinIcon {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 22px;
  border-radius: 100px;
  font-size: 0.9rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 1000;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.toast.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Result Banner ────────────────────────────────────────────────────────── */
.result-banner {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 18, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.3s ease;
}

.result-banner[hidden] { display: none; }

.result-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  padding: 32px 28px 48px;
  width: 100%;
  max-width: 560px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: slideUp 0.4s cubic-bezier(0.34, 1.2, 0.64, 1);
}

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

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

.result-emoji { font-size: 3.5rem; line-height: 1; }
.result-title { font-size: 1.8rem; font-weight: 900; letter-spacing: 0.02em; }
.result-subtitle { font-size: 1rem; color: var(--text-muted); }

.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
}

.next-puzzle {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: center;
}

.countdown {
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 18, 0.8);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px;
  width: 100%;
  max-width: 440px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: modalPop 0.3s cubic-bezier(0.34, 1.3, 0.64, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 900;
  text-align: center;
  margin-bottom: 20px;
  letter-spacing: 0.04em;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  min-width: 44px;
  min-height: 44px;
}

.modal-close:hover { background: var(--surface); color: var(--text); }

.modal-body { display: flex; flex-direction: column; gap: 14px; }
.modal-body p { font-size: 0.95rem; color: var(--text-muted); line-height: 1.6; }

.example-groups {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.example-group {
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.how-to-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.how-to-list li {
  font-size: 0.9rem;
  color: var(--text-muted);
  padding-left: 20px;
  position: relative;
  line-height: 1.5;
}

.how-to-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

.how-to-list strong { color: var(--text); }

.modal-tip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem !important;
}

/* ── Stats ────────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
}

.stat-val {
  font-size: 1.7rem;
  font-weight: 900;
  line-height: 1;
  color: var(--text);
}

.stat-lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 4px;
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
}

.bar-track {
  flex: 1;
  background: var(--surface-2);
  border-radius: 100px;
  height: 24px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--border);
  border-radius: 100px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-fill.bar-fill-active { background: var(--accent); }

/* ── Ready-to-submit glow (when exactly 4 tiles selected) ─────────────────── */
.grid.ready-to-submit .tile.selected {
  animation: readyPulse 1.5s ease-in-out infinite;
}

@keyframes readyPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent-glow), 0 4px 16px var(--accent-glow); }
  50%      { box-shadow: 0 0 0 5px var(--accent-glow), 0 4px 24px var(--accent-glow); }
}

/* ── Give Up button ───────────────────────────────────────────────────────── */
.giveup-wrap {
  display: flex;
  justify-content: center;
  margin-top: -4px;
}

.btn-giveup {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 20px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-giveup:hover {
  color: var(--red);
  border-color: var(--red);
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.footer {
  margin-top: auto;
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  opacity: 0.6;
}

/* ── Confetti canvas ──────────────────────────────────────────────────────── */
.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 500;
  display: none;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 400px) {
  .header { padding: 12px 12px 10px; }
  .logo { font-size: 1.3rem; }
  .main { padding: 12px 8px 28px; gap: 12px; }
  .grid { gap: 6px; }
  .tile { min-height: 56px; font-size: 0.62rem; padding: 8px 4px; }
  .btn { padding: 10px 16px; font-size: 0.82rem; }
  .controls { gap: 7px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 500px) {
  .tile { min-height: 72px; font-size: 0.92rem; }
}

@media (min-width: 560px) {
  .tile { min-height: 80px; font-size: 0.95rem; padding: 12px 8px; }
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 3px; }

/* ── Auth: header right group ─────────────────────────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-wrap {
  position: relative;
}

/* ── Auth: button states ──────────────────────────────────────────────────── */
.auth-btn {
  position: relative;
  overflow: visible; /* allow dropdown to escape */
}

.auth-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0;
}

/* ── User menu dropdown ───────────────────────────────────────────────────── */
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 180px;
  box-shadow: var(--shadow);
  z-index: 400;
  overflow: hidden;
  animation: modalPop 0.18s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.user-menu-info {
  padding: 12px 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}

.user-menu-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}

.user-menu-item:hover { background: var(--surface-2); }

/* ── Auth modal: Google button ────────────────────────────────────────────── */
.btn-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  background: #fff;
  color: #3c4043;
  border: 1.5px solid #dadce0;
  border-radius: 100px;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s, box-shadow 0.15s;
  letter-spacing: 0.01em;
}

.btn-google:hover { background: #f8f9fa; box-shadow: 0 1px 8px rgba(0,0,0,0.18); }
.btn-google:active { background: #f1f3f4; }
.btn-google:disabled { opacity: 0.6; cursor: not-allowed; }

.google-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* ── Auth modal: divider ──────────────────────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Auth modal: form ─────────────────────────────────────────────────────── */
.auth-field { display: flex; flex-direction: column; }

.auth-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  min-height: 44px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.auth-input::placeholder { color: var(--text-muted); }

.auth-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#auth-form { display: flex; flex-direction: column; gap: 10px; }

.auth-submit { width: 100%; }

.auth-toggle {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.auth-toggle a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.auth-toggle a:hover { text-decoration: underline; }

.auth-error {
  padding: 8px 12px;
  background: rgba(209, 73, 91, 0.12);
  border: 1px solid rgba(209, 73, 91, 0.35);
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  color: #e57083;
  line-height: 1.4;
}

.auth-error.auth-error-info {
  background: rgba(108, 114, 201, 0.12);
  border-color: rgba(108, 114, 201, 0.35);
  color: var(--accent);
}

.auth-guest-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.83rem;
  cursor: pointer;
  padding: 4px 0;
  text-align: center;
  width: 100%;
  transition: color 0.15s;
}

.auth-guest-link:hover { color: var(--text); }

/* ── Account prompt (in result banner) ────────────────────────────────────── */
.account-prompt {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideDown 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
  margin-top: 4px;
}

.account-prompt-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
  margin: 0;
}

.account-prompt-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.account-prompt-cta {
  width: 100%;
  max-width: 260px;
  font-size: 0.9rem;
  padding: 11px 20px;
}

.account-prompt-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s;
}

.account-prompt-dismiss:hover { color: var(--text); }

/* ── Responsive: auth ─────────────────────────────────────────────────────── */
@media (max-width: 400px) {
  .user-menu { min-width: 160px; }
}

/* ── Hint row ─────────────────────────────────────────────────────────────── */
.hint-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: -4px;
}

.btn-hint {
  padding: 10px 20px;
  font-size: 0.85rem;
}

.hint-count-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Hinted tile ──────────────────────────────────────────────────────────── */
.tile.tile-hinted {
  border-color: var(--hint-color, var(--accent)) !important;
  box-shadow: 0 0 0 2px var(--hint-color, var(--accent)) !important;
  animation: hintGlow 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes hintGlow {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ── Theme transition ─────────────────────────────────────────────────────── */
.theme-transitioning .btn,
.theme-transitioning .tile,
.theme-transitioning .dot,
.theme-transitioning .countdown,
.theme-transitioning .auth-avatar,
.theme-transitioning .bar-fill-active {
  transition: background 0.35s ease, background-color 0.35s ease,
              border-color 0.35s ease, box-shadow 0.35s ease,
              color 0.35s ease !important;
}

/* ── Theme picker modal ───────────────────────────────────────────────────── */
#modal-theme .modal-body {
  max-height: 65vh;
  overflow-y: auto;
  padding-right: 4px;
}

#modal-theme .modal-body::-webkit-scrollbar { width: 4px; }
#modal-theme .modal-body::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 2px; }

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.theme-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  min-height: 44px;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.theme-item:hover {
  background: var(--surface);
  border-color: var(--accent);
}

.theme-item.theme-active {
  border-color: var(--accent);
  background: var(--surface);
  color: var(--accent);
}

.theme-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.18);
}

/* ── Pro Badge ─────────────────────────────────────────────────────────────── */
.pro-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--accent) 0%, #9b59b6 100%);
  color: #fff;
  padding: 2px 7px;
  border-radius: 20px;
  vertical-align: middle;
  margin-left: 6px;
  text-transform: uppercase;
}

/* ── Archive Banner ────────────────────────────────────────────────────────── */
.archive-banner {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px;
  background: linear-gradient(90deg, rgba(108,114,201,0.18) 0%, rgba(108,114,201,0.08) 100%);
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

.archive-banner[hidden] { display: none; }

/* ── Archive Modal ─────────────────────────────────────────────────────────── */
.modal-archive {
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-archive .modal-body {
  overflow-y: auto;
  flex: 1;
  padding-top: 0;
}

.archive-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.4;
}

.archive-upgrade-msg {
  background: rgba(108,114,201,0.15);
  border: 1px solid rgba(108,114,201,0.35);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.83rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 12px;
  text-align: center;
}

.archive-upgrade-msg[hidden] { display: none; }

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.archive-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 24px 0;
}

.archive-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  color: var(--text);
  text-align: left;
  min-height: 48px;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.archive-item:hover {
  background: var(--surface);
  border-color: var(--accent);
}

.archive-item:active {
  transform: scale(0.98);
}

.archive-item-locked {
  opacity: 0.65;
  cursor: default;
}

.archive-item-locked:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.archive-num {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--accent);
  min-width: 36px;
  flex-shrink: 0;
}

.archive-date {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
}

.archive-status-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.archive-lock-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
  color: var(--text-muted);
}

/* Back to Today button in archive result banner */
.btn-back-today-result {
  margin-top: 4px;
  font-size: 0.85rem;
  padding: 8px 18px;
}

/* ── Streak Saver Status (in Stats modal) ──────────────────────────────────── */
.streak-saver-info {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(108,114,201,0.12);
  border: 1px solid rgba(108,114,201,0.25);
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.streak-saver-locked {
  opacity: 0.7;
  background: rgba(136,144,176,0.1);
  border-color: rgba(136,144,176,0.2);
  color: var(--text-muted);
}

.streak-saver-locked em {
  font-style: normal;
  color: var(--accent);
}

/* ── Upgrade Modal ─────────────────────────────────────────────────────────── */
.modal-upgrade {
  max-width: 420px;
}

.upgrade-section {
  margin-bottom: 24px;
}

.upgrade-section:last-child {
  margin-bottom: 0;
}

.upgrade-section-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.upgrade-section-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.4;
}

/* Benefits list */
.upgrade-benefits {
  list-style: none;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.upgrade-benefits li {
  font-size: 0.85rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.upgrade-benefits li::before {
  content: '✓';
  color: var(--green);
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* Pricing buttons */
.upgrade-price-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.btn-upgrade-price {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 12px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  line-height: 1.3;
  text-align: center;
}

.btn-upgrade-price:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn-upgrade-price:active {
  transform: scale(0.97);
}

.btn-upgrade-price.btn-upgrade-highlight {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-upgrade-price.btn-upgrade-highlight:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.upgrade-price-label {
  font-size: 0.72rem;
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* Divider between sections */
.upgrade-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* Loading state for price buttons */
.btn-upgrade-price:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

/* Upgrade CTA in stats modal */
.stats-upgrade-cta {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(108,114,201,0.1);
  border: 1px solid rgba(108,114,201,0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stats-upgrade-cta span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-stats-upgrade {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-stats-upgrade:hover {
  background: var(--accent-dark);
}

/* Upgrade button in user menu */
.user-menu-item-upgrade {
  color: var(--accent) !important;
  font-weight: 700;
}
