/* ============================================================
   Toolvana — Brand System
   ============================================================ */

:root {
  /* Teal — primary, trust */
  --teal-50:#E8F3EF;
  --teal-100:#C5E2D5;
  --teal-200:#94CDB5;
  --teal-400:#339B79;
  --teal-600:#0F6E56;
  --teal-700:#0C5946;
  --teal-800:#0A4D3D;
  --teal-900:#06322A;

  /* Amber — accent, CTAs */
  --amber-50:#FDF4E7;
  --amber-100:#FBE4BE;
  --amber-400:#E89821;
  --amber-600:#D97706;
  --amber-700:#B45309;
  --amber-800:#92450C;

  /* Neutrals */
  --cream-50:#FAFAF7;
  --cream-100:#F4F2EB;
  --cream-200:#E8E5DB;
  --cream-300:#D6D2C5;
  --ink-900:#0F1414;
  --ink-700:#2E3433;
  --ink-500:#5F6864;
  --ink-400:#8A938F;

  /* Semantic */
  --coral:#C2410C;
  --pink:#BE185D;
  --purple:#6B21A8;
  --blue:#1E40AF;
  --green:#15803D;
  --red:#B91C1C;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-serif: 'Fraunces', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;

  /* Layout */
  --container: 1200px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15,20,20,.06), 0 1px 3px rgba(15,20,20,.08);
  --shadow: 0 4px 12px rgba(15,20,20,.06), 0 1px 3px rgba(15,20,20,.08);
  --shadow-lg: 0 10px 28px rgba(15,20,20,.10), 0 4px 10px rgba(15,20,20,.06);
  --shadow-xl: 0 24px 60px rgba(15,20,20,.14), 0 8px 20px rgba(15,20,20,.10);

  --transition: 180ms cubic-bezier(.4, 0, .2, 1);
}

/* ============================================================
   Dark mode — overrides via [data-theme="dark"]
   ============================================================ */

html[data-theme="dark"] {
  --cream-50: #0F1414;
  --cream-100: #1A2120;
  --cream-200: #243130;
  --cream-300: #354543;
  --ink-900: #F4F2EB;
  --ink-700: #D6D2C5;
  --ink-500: #A8B0AB;
  --ink-400: #6D7672;
  --teal-50: #062421;
  --teal-100: #0A332D;
  --amber-50: #2A1A05;
  --amber-100: #3A2510;
}
html[data-theme="dark"] body { background: #0F1414; color: var(--ink-900); }
html[data-theme="dark"] .site-header { background: rgba(15,20,20,0.92); border-bottom-color: #243130; }
html[data-theme="dark"] .tool-shell,
html[data-theme="dark"] .game-shell,
html[data-theme="dark"] .tool-card,
html[data-theme="dark"] .result-cell,
html[data-theme="dark"] .file-item,
html[data-theme="dark"] .thumb,
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .btn,
html[data-theme="dark"] .search-wrap input {
  background: #1A2120;
  color: var(--ink-900);
}
html[data-theme="dark"] .btn-secondary { background: transparent; }
html[data-theme="dark"] .btn-ghost { background: transparent; }
html[data-theme="dark"] .tool-card .ico { background: rgba(15, 110, 86, 0.18); color: #94CDB5; }
html[data-theme="dark"] .result-block { background: linear-gradient(135deg, #0A332D, #1A2120); border-color: #0F6E56; }
html[data-theme="dark"] .drop-zone { background: #1A2120; border-color: #354543; }
html[data-theme="dark"] .drop-zone:hover { background: rgba(15, 110, 86, 0.12); }
html[data-theme="dark"] pre { background: #000; }
html[data-theme="dark"] code { background: #243130; color: var(--cream-50); }
html[data-theme="dark"] .section-hero {
  background:
    radial-gradient(800px 400px at 80% -100px, rgba(232, 152, 33, 0.06), transparent 60%),
    radial-gradient(900px 500px at 10% 0, rgba(15, 110, 86, 0.10), transparent 60%),
    #0F1414;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-900);
  background: var(--cream-50);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main { flex: 1; }

img, svg, canvas { max-width: 100%; height: auto; display: block; }

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

@media (max-width: 640px) { .container { padding: 0 16px; } }

/* ============================================================
   Typography
   ============================================================ */

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-900);
}
h1 { font-size: clamp(2rem, 4.5vw, 3rem); line-height: 1.1; margin-bottom: 12px; }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); line-height: 1.2; margin-bottom: 16px; }
h3 { font-size: clamp(1.15rem, 2vw, 1.4rem); line-height: 1.3; margin-bottom: 8px; }
h4 { font-size: 1.05rem; line-height: 1.4; margin-bottom: 6px; }

p { margin-bottom: 12px; }

a { color: var(--teal-700); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--teal-600); text-decoration: underline; }

.eyebrow {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal-600);
  margin-bottom: 8px;
}

.lede {
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  color: var(--ink-700);
  max-width: 60ch;
  margin-bottom: 28px;
}

.mono, .numbers {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Header
   ============================================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 250, 247, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--cream-200);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
  gap: 16px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -0.02em;
}
.brand-mark:hover { text-decoration: none; color: var(--teal-700); }
.brand-mark svg { width: 32px; height: 32px; }
.brand-mark .va {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  color: var(--amber-600);
}

.nav {
  display: flex;
  align-items: center;
  gap: 28px;
}
.nav a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink-700);
}
.nav a:hover { color: var(--teal-600); text-decoration: none; }

.sound-toggle, .menu-toggle {
  background: transparent;
  border: 1px solid var(--cream-300);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--ink-700);
}
.sound-toggle:hover, .menu-toggle:hover {
  border-color: var(--teal-400);
  background: var(--teal-50);
}
.sound-toggle.muted { opacity: 0.5; }

.menu-toggle { display: none; }

@media (max-width: 768px) {
  .nav {
    position: absolute;
    top: 100%;
    right: 16px;
    background: var(--cream-50);
    border: 1px solid var(--cream-200);
    border-radius: 12px;
    padding: 12px;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    box-shadow: var(--shadow-lg);
    display: none;
    min-width: 180px;
  }
  .nav.open { display: flex; }
  .menu-toggle { display: inline-flex; }
}

/* ============================================================
   Sections
   ============================================================ */

.section { padding: 56px 0; }
.section-tight { padding: 32px 0; }

@media (max-width: 640px) {
  .section { padding: 36px 0; }
}

.section-hero {
  background:
    radial-gradient(800px 400px at 80% -100px, rgba(232, 152, 33, 0.10), transparent 60%),
    radial-gradient(900px 500px at 10% 0, rgba(15, 110, 86, 0.08), transparent 60%),
    var(--cream-50);
  padding: 72px 0 56px;
}

.hero-meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin: 28px 0 12px;
}
.hero-meta .stat {
  display: flex;
  flex-direction: column;
}
.hero-meta .stat-num {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--teal-700);
  line-height: 1;
}
.hero-meta .stat-label {
  font-size: 0.85rem;
  color: var(--ink-500);
  margin-top: 4px;
}

/* ============================================================
   Search bar
   ============================================================ */

.search-wrap {
  position: relative;
  max-width: 560px;
  margin-top: 20px;
}
.search-wrap input {
  width: 100%;
  padding: 14px 18px 14px 48px;
  border: 2px solid var(--cream-200);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  background: white;
  color: var(--ink-900);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.search-wrap input:focus {
  outline: none;
  border-color: var(--teal-400);
  box-shadow: 0 0 0 4px rgba(15, 110, 86, 0.10);
}
.search-wrap .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-400);
  pointer-events: none;
}
.search-wrap .search-shortcut {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--cream-100);
  border: 1px solid var(--cream-300);
  border-radius: 6px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-500);
  pointer-events: none;
}

/* ============================================================
   Tool grid (homepage)
   ============================================================ */

.category {
  margin-top: 40px;
}
.category-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.category-head h2 { margin-bottom: 0; }
.category-count {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-500);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.tool-card {
  display: block;
  padding: 18px;
  background: white;
  border: 1px solid var(--cream-200);
  border-radius: 14px;
  transition: all var(--transition);
  color: inherit;
  position: relative;
  overflow: hidden;
}
.tool-card:hover {
  text-decoration: none;
  border-color: var(--teal-400);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.tool-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--teal-600), var(--amber-600));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition);
}
.tool-card:hover::after { transform: scaleX(1); }

.tool-card .ico {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--teal-50);
  color: var(--teal-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  font-size: 18px;
}
.tool-card[data-cat="pdf"] .ico { background: rgba(190, 24, 93, 0.08); color: var(--pink); }
.tool-card[data-cat="image"] .ico { background: rgba(107, 33, 168, 0.08); color: var(--purple); }
.tool-card[data-cat="text"] .ico { background: rgba(30, 64, 175, 0.08); color: var(--blue); }
.tool-card[data-cat="generator"] .ico { background: rgba(217, 119, 6, 0.08); color: var(--amber-600); }
.tool-card[data-cat="calc"] .ico { background: rgba(21, 128, 61, 0.08); color: var(--green); }
.tool-card[data-cat="game"] .ico { background: rgba(194, 65, 12, 0.08); color: var(--coral); }

.tool-card h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.98rem;
  margin-bottom: 4px;
}
.tool-card p {
  font-size: 0.85rem;
  color: var(--ink-500);
  margin: 0;
}

.tool-card.hidden { display: none; }

/* ============================================================
   Breadcrumbs
   ============================================================ */

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--ink-500);
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.breadcrumbs a { color: var(--ink-500); }
.breadcrumbs a:hover { color: var(--teal-600); text-decoration: none; }
.breadcrumbs .sep { color: var(--ink-400); }

/* ============================================================
   Tool shell + Drop zone
   ============================================================ */

.tool-shell {
  background: white;
  border: 1px solid var(--cream-200);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  margin-top: 24px;
}

@media (max-width: 640px) { .tool-shell { padding: 20px 16px; } }

.drop-zone {
  border: 2px dashed var(--cream-300);
  border-radius: 14px;
  padding: 44px 24px;
  text-align: center;
  background: var(--cream-50);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--teal-400);
  background: var(--teal-50);
}
.drop-zone.dragging { transform: scale(1.01); }
.drop-zone input[type="file"] { display: none; }
.drop-zone .drop-icon {
  font-size: 36px;
  margin-bottom: 10px;
  color: var(--teal-600);
}
.drop-zone .drop-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--ink-900);
}
.drop-zone .drop-hint {
  font-size: 0.88rem;
  color: var(--ink-500);
}

/* ============================================================
   Form fields
   ============================================================ */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-700);
}
.field .field-help {
  font-size: 0.78rem;
  color: var(--ink-500);
}
.field input[type="text"],
.field input[type="number"],
.field input[type="password"],
.field input[type="email"],
.field input[type="url"],
.field input[type="search"],
.field input[type="color"],
.field select,
.field textarea {
  padding: 10px 12px;
  border: 1.5px solid var(--cream-300);
  border-radius: 9px;
  font-size: 0.95rem;
  font-family: inherit;
  background: white;
  color: var(--ink-900);
  transition: all var(--transition);
  width: 100%;
}
.field input[type="color"] { padding: 2px; height: 42px; cursor: pointer; }
.field textarea { font-family: var(--font-mono); font-size: 0.9rem; resize: vertical; min-height: 100px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--teal-400);
  box-shadow: 0 0 0 3px rgba(15, 110, 86, 0.10);
}
.field input[type="range"] {
  width: 100%;
  accent-color: var(--teal-600);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
.field-group {
  display: grid;
  gap: 16px;
}

.checkbox-row, .radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox-row input, .radio-row input { accent-color: var(--teal-600); }
.checkbox-row label, .radio-row label {
  font-weight: 400;
  cursor: pointer;
  margin: 0;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1.5px solid transparent;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  background: var(--cream-100);
  color: var(--ink-900);
  user-select: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--teal-600);
  color: white;
  border-color: var(--teal-700);
}
.btn-primary:hover { background: var(--teal-700); color: white; }

.btn-amber {
  background: var(--amber-600);
  color: white;
  border-color: var(--amber-700);
}
.btn-amber:hover { background: var(--amber-700); color: white; }

.btn-secondary {
  background: white;
  color: var(--teal-700);
  border-color: var(--teal-200);
}
.btn-secondary:hover { background: var(--teal-50); border-color: var(--teal-400); }

.btn-ghost {
  background: transparent;
  color: var(--ink-700);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--cream-100); color: var(--ink-900); }

.btn-danger {
  background: var(--red);
  color: white;
  border-color: #7F1D1D;
}
.btn-danger:hover { background: #7F1D1D; color: white; }

.btn-lg { padding: 14px 22px; font-size: 1rem; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

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

/* ============================================================
   Status bar + Result block
   ============================================================ */

.status-bar {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-top: 16px;
  display: none;
  border-left: 3px solid;
  background: var(--cream-100);
  border-color: var(--ink-400);
}
.status-bar.show { display: block; }
.status-bar.success {
  background: rgba(21, 128, 61, 0.08);
  border-color: var(--green);
  color: #14532D;
}
.status-bar.error {
  background: rgba(185, 28, 28, 0.08);
  border-color: var(--red);
  color: #7F1D1D;
}
.status-bar.warning {
  background: rgba(217, 119, 6, 0.08);
  border-color: var(--amber-600);
  color: #78350F;
}
.status-bar.info {
  background: rgba(15, 110, 86, 0.08);
  border-color: var(--teal-600);
  color: var(--teal-900);
}

.result-block {
  margin-top: 24px;
  padding: 24px;
  background: linear-gradient(135deg, var(--teal-50), var(--cream-50));
  border: 1px solid var(--teal-100);
  border-radius: 14px;
}
.result-block .result-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal-700);
  font-weight: 600;
  margin-bottom: 6px;
}
.result-block .result-value {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 600;
  color: var(--ink-900);
  line-height: 1.1;
}
.result-block .result-sub {
  font-size: 0.9rem;
  color: var(--ink-500);
  margin-top: 6px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.result-cell {
  background: white;
  border: 1px solid var(--cream-200);
  border-radius: 10px;
  padding: 14px;
}
.result-cell .label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-500);
  font-weight: 600;
  margin-bottom: 4px;
}
.result-cell .value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink-900);
}

/* ============================================================
   File list + thumb grid
   ============================================================ */

.file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--cream-50);
  border: 1px solid var(--cream-200);
  border-radius: 10px;
  cursor: grab;
  transition: all var(--transition);
}
.file-item:hover { border-color: var(--teal-200); }
.file-item.dragging { opacity: 0.4; cursor: grabbing; }
.file-item .file-handle {
  color: var(--ink-400);
  cursor: grab;
  font-size: 1.1rem;
}
.file-item .file-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-item .file-size {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-500);
}
.file-item .file-remove {
  background: transparent;
  border: none;
  color: var(--ink-400);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}
.file-item .file-remove:hover { color: var(--red); background: rgba(185, 28, 28, 0.08); }

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.thumb {
  position: relative;
  aspect-ratio: 1;
  border: 1.5px solid var(--cream-200);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--cream-50);
  transition: all var(--transition);
}
.thumb img, .thumb canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.thumb:hover { border-color: var(--teal-400); }
.thumb.selected {
  border-color: var(--teal-600);
  box-shadow: 0 0 0 2px rgba(15, 110, 86, 0.20);
}
.thumb .thumb-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 20, 20, 0.8);
  color: white;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 3px 6px;
  text-align: center;
}

/* ============================================================
   Preview grid (before/after)
   ============================================================ */

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.preview-grid .col {
  background: var(--cream-50);
  border: 1px solid var(--cream-200);
  border-radius: 12px;
  padding: 14px;
}
.preview-grid .col-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-500);
  font-weight: 600;
  margin-bottom: 8px;
}
.preview-grid img, .preview-grid canvas {
  width: 100%;
  border-radius: 8px;
  background: repeating-conic-gradient(var(--cream-200) 0% 25%, white 0% 50%) 50% / 16px 16px;
}

/* ============================================================
   Progress bar
   ============================================================ */

.progress {
  height: 8px;
  background: var(--cream-200);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 12px;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-600), var(--amber-600));
  width: 0;
  transition: width 240ms cubic-bezier(.4,0,.2,1);
  border-radius: 99px;
}

/* ============================================================
   Toast notifications
   ============================================================ */

.tv-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}
.tv-toast {
  padding: 12px 18px;
  background: var(--ink-900);
  color: white;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: tvToastIn 240ms cubic-bezier(.34,1.56,.64,1) forwards;
  border-left: 3px solid var(--teal-400);
}
.tv-toast.success { border-left-color: #4ADE80; }
.tv-toast.error { border-left-color: #F87171; }
.tv-toast.warning { border-left-color: #FBBF24; }
.tv-toast.info { border-left-color: #60A5FA; }
.tv-toast.leaving { animation: tvToastOut 200ms ease forwards; }

@keyframes tvToastIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes tvToastOut {
  to { transform: translateY(20px); opacity: 0; }
}

/* ============================================================
   Confetti
   ============================================================ */

.tv-confetti-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 998;
}

/* ============================================================
   Sparkle
   ============================================================ */

.tv-sparkle {
  position: absolute;
  pointer-events: none;
  width: 14px;
  height: 14px;
  background: radial-gradient(circle, var(--amber-400) 0%, transparent 70%);
  border-radius: 50%;
  animation: tvSparkle 800ms ease-out forwards;
}
@keyframes tvSparkle {
  0% { transform: scale(0) rotate(0); opacity: 1; }
  60% { transform: scale(1.4) rotate(120deg); opacity: 1; }
  100% { transform: scale(0) rotate(240deg); opacity: 0; }
}

/* ============================================================
   Game-specific shells
   ============================================================ */

.game-shell {
  background: white;
  border: 1px solid var(--cream-200);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-top: 24px;
}
.game-board {
  margin: 20px auto;
  display: grid;
  gap: 8px;
  user-select: none;
}
.game-cell {
  background: var(--cream-100);
  border: 2px solid var(--cream-200);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 120ms ease;
  aspect-ratio: 1;
}
.game-cell:hover:not(.filled):not(.disabled) {
  background: var(--teal-50);
  border-color: var(--teal-400);
  transform: scale(1.04);
}
.game-cell.filled { cursor: default; }
.game-cell.x { color: var(--teal-700); }
.game-cell.o { color: var(--amber-600); }
.game-cell.win { background: var(--amber-50); border-color: var(--amber-400); animation: tvPulse 600ms ease-out infinite; }

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

.score-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 14px;
  flex-wrap: wrap;
}
.score-box {
  background: var(--cream-50);
  border: 1px solid var(--cream-200);
  border-radius: 10px;
  padding: 10px 18px;
  text-align: center;
}
.score-box .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-500);
  font-weight: 600;
}
.score-box .value {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink-900);
}

/* ============================================================
   Code / Mono blocks
   ============================================================ */

pre, code {
  font-family: var(--font-mono);
  font-size: 0.88rem;
}
pre {
  background: var(--ink-900);
  color: var(--cream-100);
  padding: 14px 18px;
  border-radius: 10px;
  overflow-x: auto;
  line-height: 1.5;
}
code {
  background: var(--cream-100);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--ink-900);
}

/* ============================================================
   Color swatch
   ============================================================ */

.color-swatch {
  width: 100%;
  height: 200px;
  border-radius: 14px;
  border: 1px solid var(--cream-200);
  margin-bottom: 16px;
  transition: background 200ms ease;
}

/* ============================================================
   Footer
   ============================================================ */

.site-footer {
  background: var(--ink-900);
  color: var(--cream-200);
  padding: 48px 0 28px;
  margin-top: 64px;
}
.site-footer .brand-mark { color: white; }
.site-footer .brand-mark:hover { color: var(--amber-400); }
.site-footer .footer-grid {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: 32px;
  margin-bottom: 32px;
}
@media (max-width: 768px) {
  .site-footer .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .site-footer .footer-grid { grid-template-columns: 1fr; }
}
.site-footer .footer-col h4 {
  color: white;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
  font-weight: 600;
}
.site-footer .footer-col ul { list-style: none; padding: 0; }
.site-footer .footer-col li { margin-bottom: 8px; }
.site-footer .footer-col a {
  color: var(--cream-200);
  font-size: 0.9rem;
}
.site-footer .footer-col a:hover { color: white; text-decoration: none; }
.site-footer .footer-tagline {
  font-size: 0.9rem;
  color: var(--ink-400);
  max-width: 32ch;
  margin-top: 12px;
}
.site-footer .footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--ink-400);
  flex-wrap: wrap;
  gap: 12px;
}
.site-footer .footer-bottom a { color: var(--cream-300); }
.site-footer .footer-bottom a:hover { color: white; }
.site-footer .aravindlabs-stamp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(217, 119, 6, 0.12);
  color: var(--amber-400);
  border: 1px solid rgba(217, 119, 6, 0.30);
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
}
.site-footer .aravindlabs-stamp:hover {
  background: rgba(217, 119, 6, 0.20);
  color: var(--amber-400);
  text-decoration: none;
}

/* ============================================================
   Tooltips
   ============================================================ */

.tv-tooltip {
  position: fixed;
  transform: translate(-50%, -100%);
  background: var(--ink-900);
  color: var(--cream-100);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity 140ms ease;
  white-space: nowrap;
  max-width: 240px;
  box-shadow: var(--shadow-lg);
}
.tv-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ink-900);
}
.tv-tooltip.show { opacity: 1; }

/* ============================================================
   Cheatsheet overlay
   ============================================================ */

.tv-cheat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 20, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.tv-cheat-overlay.open { display: flex; animation: tvCheatIn 200ms ease; }
@keyframes tvCheatIn { from { opacity: 0; } to { opacity: 1; } }
.tv-cheat-card {
  background: white;
  border-radius: 16px;
  padding: 24px 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: tvCheatCardIn 240ms cubic-bezier(.34,1.56,.64,1);
}
@keyframes tvCheatCardIn {
  from { transform: scale(0.92) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
.tv-cheat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.tv-cheat-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--ink-500);
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
}
.tv-cheat-close:hover { background: var(--cream-100); color: var(--ink-900); }
.tv-cheat-table {
  width: 100%;
  border-collapse: collapse;
}
.tv-cheat-table td {
  padding: 8px 0;
  border-bottom: 1px solid var(--cream-100);
  font-size: 0.92rem;
}
.tv-cheat-table td:first-child { width: 130px; }
.tv-cheat-table kbd {
  display: inline-block;
  padding: 2px 8px;
  background: var(--cream-100);
  border: 1px solid var(--cream-300);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  margin-right: 2px;
}
.tv-cheat-foot { margin-top: 16px; }

/* ============================================================
   Consent banner
   ============================================================ */

.tv-consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: var(--ink-900);
  color: var(--cream-100);
  padding: 14px 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  animation: tvConsentUp 320ms cubic-bezier(.34,1.56,.64,1);
}
@keyframes tvConsentUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.tv-consent-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  flex-wrap: wrap;
  font-size: 0.9rem;
}
.tv-consent-banner .btn {
  padding: 8px 14px;
  font-size: 0.85rem;
}
.tv-consent-reject {
  background: transparent;
  color: var(--cream-200);
  border-color: var(--ink-700);
}
.tv-consent-reject:hover { background: var(--ink-700); color: white; }

/* ============================================================
   Mobile responsive — 480px breakpoint
   ============================================================ */

@media (max-width: 480px) {
  /* FLAMES letters: smaller + tighter on mobile */
  .flames-letters { gap: 8px; flex-wrap: wrap; }
  .flames-letter { width: 44px; height: 44px; font-size: 1.4rem; border-radius: 9px; }

  /* Result block: tighter padding */
  .result-block { padding: 18px; }
  .result-block .result-value { font-size: 1.8rem; }

  /* Tool shell: tighter */
  .tool-shell { padding: 18px 14px; }

  /* Field rows stack cleanly */
  .field-row { grid-template-columns: 1fr 1fr; }
  .field-row:has(input[type="color"]) { grid-template-columns: 1fr; }

  /* Game cells smaller */
  .game-cell { font-size: 1.5rem; }

  /* Site header: hide some nav links on phone */
  .site-header .container { padding-top: 10px; padding-bottom: 10px; }

  /* Hero meta stacks */
  .hero-meta { gap: 16px; }
  .hero-meta .stat-num { font-size: 2rem; }

  /* Search box */
  .search-wrap input { font-size: 0.95rem; padding: 12px 16px 12px 42px; }
  .search-wrap .search-shortcut { display: none; }

  /* Buttons */
  .btn { padding: 9px 14px; font-size: 0.9rem; }
  .btn-lg { padding: 12px 18px; font-size: 0.95rem; }

  /* Tool cards: smaller */
  .tool-card { padding: 14px; }

  /* Consent banner: stacks */
  .tv-consent-inner { font-size: 0.85rem; }

  /* Cheat card: full screen on tiny mobile */
  .tv-cheat-card { padding: 18px; }

  /* Footer: tighter */
  .site-footer { padding: 32px 0 20px; }
  .site-footer .footer-bottom { font-size: 0.78rem; }
}

/* Very small phones — 360px and below */
@media (max-width: 360px) {
  .flames-letter { width: 38px; height: 38px; font-size: 1.2rem; }
  h1 { font-size: 1.7rem; }
  .container { padding: 0 12px; }
}

/* ============================================================
   Utilities
   ============================================================ */

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-sm { font-size: 0.85rem; }
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--ink-500); }
.tag {
  display: inline-block;
  background: var(--teal-50);
  color: var(--teal-700);
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============================================================
   Reduced motion + Accessibility
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

:focus-visible {
  outline: 2px solid var(--teal-400);
  outline-offset: 2px;
}

::selection { background: var(--amber-100); color: var(--ink-900); }
