@import url('https://fonts.googleapis.com/css2?family=Livvic:wght@700&family=Roboto:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600;700&display=swap');

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

:root {
  --bg: #FAF6F0;
  --bg-welcome: #FFC82F;
  --surface: #FFFFFF;
  --surface-2: #F3EDE4;
  --surface-3: #EBE4D8;
  --surface-card-welcome: rgba(255, 221, 128, 0.6);
  --border-card-welcome: rgba(0, 0, 0, 0.05);
  --tile-border-white: #E1E1E1;
  --tile-changed-fill: #E9FFF0;
  --tile-changed-stroke: #1E9455;
  --text: #2D2A26;
  --text-welcome: #333333;
  --text-dim: #8A8279;
  --text-mid: #5C564E;
  --border: rgba(93,130,109,0.15);
  --border-light: rgba(0,0,0,0.06);
  --border-welcome: #333333;
  --start-color: #5D826D;
  --end-color: #D4935A;
  --success: #5D826D;
  --demo-start-bg: #333333;
  --demo-end-bg: #1E9455;
  --error: #C75C5C;
  --accent-pink: #D4879C;
  --accent-gold: #D4A95A;
  --shadow-sm: 0 1px 3px rgba(45,42,38,0.05);
  --shadow-md: 0 4px 12px rgba(45,42,38,0.07);
  --shadow-lg: 0 8px 30px rgba(45,42,38,0.09);
  --glow-start: rgba(93,130,109,0.15);
  --glow-end: rgba(212,169,90,0.15);
}

body {
  font-family: 'Roboto', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

body.page-welcome {
  background: var(--bg-welcome);
}
body.page-welcome canvas#bgCanvas {
  opacity: 0;
}

/* ===== GAME PAGE (puzzle) ===== */
body.page-game {
  background: #FFC82F;
  overflow: hidden;
}
body.page-game canvas#bgCanvas {
  opacity: 0;
}
body.page-game .game-container {
  background: rgba(255, 242, 205, 0.8);
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  margin: 50px 16px 50px;
  padding: 18px 20px 20px;
  max-width: 520px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
body.page-game .game-description {
  margin: 10px 0 12px;
  text-align: left;
}
body.page-game .game-description p {
  font-family: 'Roboto', sans-serif;
  font-size: 0.9rem;
  color: #333333;
  line-height: 1.6;
  margin: 0 0 12px 0;
}
body.page-game .game-description p:last-child {
  margin-bottom: 0;
}
body.page-game .progress-labels.progress-labels-above span:first-child,
body.page-game .progress-labels.progress-labels-above span:last-child {
  color: #000000;
}
body.page-game .word-row {
  animation: none;
}
body.page-game .top-nav { margin-bottom: 8px; }
body.page-game .stats-bar { margin: 10px 0 12px; gap: 12px; }
body.page-game .progress-container { margin: 12px 0 14px; }
body.page-game .chain { gap: 8px; margin-bottom: 12px; }
body.page-game .input-area { margin: 12px 0 0; }
body.page-game .btn-row { margin-top: 12px; gap: 12px; }
body.page-game .stat {
  border: 1px solid #333333;
  background: #FFFFFF;
}
body.page-game .progress-labels.progress-labels-above {
  margin-top: 0;
  margin-bottom: 6px;
}
body.page-game .progress-pct {
  color: #000000 !important;
  font-weight: 700;
}
body.page-game .progress-track {
  background: #E5E5E5;
}
body.page-game .progress-fill::after {
  display: none;
}
body.page-game .tile-start {
  background: #000000 !important;
  color: #FFFFFF;
  border: none;
  box-shadow: none;
}
body.page-game .tile-step {
  background: #FFFFFF;
  border: none;
  color: #333333;
  box-shadow: none;
}
body.page-game .tile-step.tile-changed.tile-highlight {
  background: #E9FFF0 !important;
  border: 1px solid #1E9455 !important;
  color: #000000 !important;
  box-shadow: none;
}
body.page-game .tile-end {
  background: #1E9455 !important;
  color: #FFFFFF;
  border: none;
}
body.page-game .input-tile {
  background: #FFFFFF;
  border: none;
  box-shadow: none;
}
body.page-game .input-tile:focus {
  border: 2px solid #333333;
  box-shadow: 0 0 0 2px rgba(51,51,51,0.15);
}
body.page-game .btn-primary {
  background: #000000;
  color: #FFFFFF;
  border: none;
  box-shadow: none;
}
body.page-game .btn-secondary {
  background: #FFFFFF;
  color: #333333;
  border: 1px solid #333333;
}
body.page-game .btn-secondary:hover {
  background: #F5F5F5;
  color: #333333;
}
body.page-game .nav-btn {
  border: 1px solid transparent;
  color: #333333;
}
body.page-game .nav-btn:hover {
  border-color: #333333;
  background: #FFFFFF;
}

body.page-welcome .ctrl-btn {
  background: #FFFFFF;
  border: 1px solid #333333;
  color: #333333;
}

canvas#bgCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

.game-container {
  position: relative;
  z-index: 1;
  max-width: 520px;
  width: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.controls-row {
  position: fixed;
  top: 12px; right: 12px;
  z-index: 10;
  display: flex;
  gap: 6px;
}

.ctrl-btn {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ctrl-btn:hover { transform: scale(1.1); box-shadow: var(--shadow-md); }
.ctrl-btn.active { background: var(--surface-2); border-color: var(--start-color); color: var(--start-color); }

.header { text-align: center; margin: 24px 0 8px; position: relative; }
.header .welcome-icon { margin-bottom: 12px; }

.header h1 {
  font-family: 'Livvic', sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.header p {
  color: var(--text-dim); font-size: 0.82rem; margin-top: 6px;
  font-weight: 400; letter-spacing: 0.3px;
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--text-dim);
  font-family: 'Roboto', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.nav-btn:hover { color: var(--text); border-color: var(--start-color); background: var(--surface-2); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.nav-btn svg { width: 14px; height: 14px; }

.stats-bar { display: flex; gap: 10px; margin: 12px 0; justify-content: center; width: 100%; }

.stat {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 8px 14px;
  text-align: center;
  flex: 1;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.stat-value { font-family: 'JetBrains Mono', monospace; font-size: 1.2rem; font-weight: 700; color: var(--text); }
.stat-label { font-size: 0.6rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-top: 2px; }

.progress-container { width: 100%; margin: 8px 0 16px; position: relative; }

.progress-track {
  height: 8px;
  background: var(--surface-3);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.34,1.56,0.64,1), background 0.6s ease;
  width: 0%;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  right: -1px; top: -4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: inherit;
  box-shadow: 0 0 10px currentColor, 0 2px 6px rgba(0,0,0,0.15);
  border: 2px solid white;
  transition: all 0.6s ease;
}

.progress-labels { display: flex; justify-content: space-between; margin-top: 10px; font-size: 0.72rem; font-weight: 600; color: var(--text-dim); }

.chain { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 12px; }

.word-row { display: flex; gap: 6px; animation: slideIn 0.4s cubic-bezier(0.34,1.56,0.64,1); }

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

.tile {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem; font-weight: 700;
  border-radius: 12px;
  text-transform: uppercase;
  position: relative;
  transition: all 0.3s ease;
}

.tile-start { background: var(--start-color); color: white; box-shadow: 0 4px 16px var(--glow-start), var(--shadow-md); }
.tile-end { background: var(--end-color); color: white; box-shadow: 0 4px 16px var(--glow-end), var(--shadow-md); }
.tile-step { border: 2px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.tile-changed { animation: tileReveal 0.5s cubic-bezier(0.34,1.56,0.64,1); }

@keyframes tileReveal { 0% { transform: rotateX(90deg) scale(0.8); } 50% { transform: rotateX(-10deg) scale(1.05); } 100% { transform: rotateX(0deg) scale(1); } }

.tile-highlight { border-color: var(--success) !important; box-shadow: 0 0 12px rgba(34,197,94,0.2), var(--shadow-sm); }

.connector { display: flex; flex-direction: column; align-items: center; gap: 3px; margin: -2px 0; }
.connector-dot { width: 4px; height: 4px; border-radius: 50%; background: rgba(99,102,241,0.2); }

.input-area { width: 100%; margin: 4px 0; }
.input-row { display: flex; gap: 6px; justify-content: center; }

.input-tile {
  width: 52px; height: 52px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem; font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  caret-color: transparent;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.input-tile:focus { border-color: var(--start-color); box-shadow: 0 0 0 3px rgba(99,102,241,0.15), var(--shadow-md); transform: translateY(-2px); }
.input-tile.filled { border-color: rgba(99,102,241,0.3); background: var(--surface-2); }

.btn-row { display: flex; gap: 8px; margin-top: 12px; justify-content: center; flex-wrap: wrap; }

.btn {
  padding: 10px 24px; border-radius: 10px; border: none;
  font-family: 'Roboto', sans-serif; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s ease; position: relative; overflow: hidden;
}

.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--start-color), #818cf8); color: white; box-shadow: 0 4px 14px var(--glow-start); }
.btn-secondary { background: var(--surface); color: var(--text-mid); border: 1px solid var(--border-light); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-small { padding: 7px 16px; font-size: 0.78rem; border-radius: 8px; }

.message { padding: 10px 20px; border-radius: 10px; font-size: 0.82rem; margin: 10px 0; animation: fadeSlide 0.3s ease; text-align: center; width: 100%; font-weight: 500; }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(-10px); } }
.message-error { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }
.message-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #16a34a; }
.message-info { background: #eef2ff; border: 1px solid #c7d2fe; color: #4f46e5; }

.shake { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake { 10%,90% { transform: translateX(-2px); } 20%,80% { transform: translateX(3px); } 30%,50%,70% { transform: translateX(-5px); } 40%,60% { transform: translateX(5px); } }

body.page-victory { background: #FFC82F; }
.victory-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 50px 16px;
  background: #FFC82F;
  animation: fadeIn 0.4s ease; flex-direction: column;
}
@keyframes fadeIn { from { opacity: 0; } }

.victory-card {
  background: rgba(255, 242, 205, 0.8); border: 1px solid var(--border-light);
  border-radius: 24px; padding: 24px 28px; text-align: center;
  animation: popIn 0.5s cubic-bezier(0.34,1.56,0.64,1);
  max-width: 400px; width: 90%; box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 100px); overflow-y: auto;
}
.victory-btn-row { display: flex; justify-content: space-evenly; width: 100%; gap: 12px; }
.victory-btn-row .btn-primary {
  background: #000000 !important;
  color: #FFFFFF;
}
.victory-stats .stat-value { color: #000000 !important; font-weight: 700; }
.btn-with-icon { display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn-with-icon svg { width: 14px; height: 14px; flex-shrink: 0; }
@keyframes popIn { from { transform: scale(0.8) translateY(20px); opacity: 0; } }

.victory-title {
  font-family: 'Livvic', sans-serif;
  font-size: 1.6rem; font-weight: 700; margin-bottom: 6px;
  color: var(--text);
}

.victory-sub {
  font-family: 'Roboto', sans-serif;
  color: #000000; font-size: 0.88rem; margin-bottom: 18px; line-height: 1.6;
}
@media (min-width: 380px) {
  .victory-sub { white-space: nowrap; }
}
.victory-stats { display: flex; gap: 16px; justify-content: center; margin-bottom: 20px; }

.confetti-piece { position: fixed; z-index: 101; pointer-events: none; animation: confettiFall var(--fall-dur) ease-in forwards; }
@keyframes confettiFall { 0% { transform: translateY(0) rotate(0deg); opacity: 1; } 100% { transform: translateY(100vh) rotate(720deg); opacity: 0; } }

.welcome { text-align: center; margin-top: 20px; animation: fadeIn 0.6s ease; }

.welcome-icon {
  width: 64px; height: 64px; margin: 0 auto 18px; display: flex;
  align-items: center; justify-content: center;
  background: transparent;
  border-radius: 16px;
  animation: gentleFloat 4s ease-in-out infinite;
}
body:not(.page-welcome) .welcome-icon {
  background: var(--start-color);
  box-shadow: 0 4px 16px rgba(93,130,109,0.25);
}
.welcome-icon svg { width: 32px; height: 32px; }
body.page-welcome .welcome-icon {
  background: #FFFFFF;
  border: 1px solid #E0E0E0;
}
body.page-welcome .welcome-icon svg { stroke: #333333; }
@keyframes gentleFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.welcome h2 {
  font-family: 'Roboto', sans-serif;
  font-size: 1.6rem; margin-bottom: 8px; color: var(--text);
  font-weight: 600; letter-spacing: -0.3px;
}
.welcome p { color: var(--text-dim); font-size: 0.84rem; max-width: 340px; margin: 0 auto 20px; line-height: 1.7; }
body.page-welcome .welcome .header p,
body.page-welcome .welcome p { color: var(--text-welcome); }
body.page-welcome .header h1 { color: var(--text-welcome); font-family: 'Livvic', sans-serif; font-weight: 700; }
body.page-welcome .header p { color: var(--text-welcome); font-family: 'Roboto', sans-serif; }

.difficulty-picker { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

.diff-btn {
  padding: 14px 24px; border-radius: 12px; border: 1px solid var(--border-light);
  background: var(--surface); color: var(--text);
  font-family: 'Roboto', sans-serif; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s ease; text-align: left; min-width: 120px;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}

.diff-btn::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  border-radius: 12px 0 0 12px;
}

.diff-btn[data-diff="easy"]::before { background: var(--start-color); }
.diff-btn[data-diff="medium"]::before { background: var(--end-color); }
.diff-btn[data-diff="hard"]::before { background: var(--accent-pink); }
body.page-welcome .diff-btn {
  background: #FFFFFF; border: 2px solid var(--border-welcome); color: var(--text-welcome);
}
body.page-welcome .diff-btn::before { display: none; }
body.page-welcome .diff-btn span { color: var(--text-welcome); }

.diff-btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border);
  background: var(--surface-2);
}
.diff-btn:active { transform: translateY(0); }

.diff-btn strong {
  display: block; margin-bottom: 2px; font-size: 0.9rem;
  font-family: 'Roboto', sans-serif; font-weight: 600;
}
.diff-btn span { font-size: 0.7rem; color: var(--text-dim); font-weight: 400; }
body.page-welcome .diff-btn span { color: var(--text-welcome); }
.diff-btn .diff-letters { display: block; margin-top: 2px; font-size: 0.7rem; color: var(--text-dim); font-weight: 400; }
body.page-welcome .diff-btn .diff-letters { color: var(--text-dim); }

.how-to {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 14px; padding: 18px 22px; margin: 16px 0;
  font-size: 0.82rem; color: var(--text-dim); line-height: 1.7;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-sm);
}
.how-to strong { color: var(--text); }

.example-demo {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 16px; padding: 20px 18px; margin: 16px 0;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-sm);
  overflow: hidden;
}
body.page-welcome .example-demo {
  background: var(--surface-card-welcome);
  border: 1px solid var(--border-card-welcome);
}
.example-demo-label {
  font-size: 0.7rem; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1.2px; margin-bottom: 14px; text-align: center;
}
body.page-welcome .example-demo-label { color: var(--text-welcome); }
.demo-chain {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  position: relative;
}
.demo-row {
  display: flex; gap: 5px;
  perspective: 600px;
}
.demo-row.target-row .demo-tile-wrap { opacity: 1 !important; }
.demo-row.target-row .demo-tile-inner { transform: rotateY(0deg) !important; animation: none !important; }

.demo-tile-wrap {
  width: 40px; height: 40px;
  position: relative;
  transform-style: preserve-3d;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.demo-tile-wrap.flipped .demo-tile-inner {
  animation: demoFlipIn 0.5s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
.demo-tile-wrap.revealed { opacity: 1; }

.demo-tile-inner {
  width: 100%; height: 100%;
  transform: rotateY(-90deg);
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

@keyframes demoFlipIn {
  0%   { transform: rotateY(-90deg) scale(0.85); }
  60%  { transform: rotateY(8deg) scale(1.04); }
  100% { transform: rotateY(0deg) scale(1); }
}

.demo-tile {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem; font-weight: 700;
  border-radius: 10px;
  text-transform: uppercase;
}
.demo-tile-start { background: var(--start-color); color: white; }
.demo-tile-end { background: var(--end-color); color: white; }
.demo-tile-step { background: var(--surface-2); border: 2px solid var(--border); color: var(--text); }
body.page-welcome .demo-tile-start { background: var(--demo-start-bg); color: #FFFFFF; border: none; }
body.page-welcome .demo-tile-end { background: var(--demo-end-bg); color: #FFFFFF; border: none; }
body.page-welcome .demo-tile-step { background: #FFFFFF; border: 1px solid var(--tile-border-white); color: var(--text-welcome); }
.demo-row:not(.target-row) .demo-tile-changed .demo-tile {
  border-color: var(--success) !important;
  box-shadow: 0 0 10px rgba(34,197,94,0.25);
  background: #f0fdf4;
}
body.page-welcome .demo-row:not(.target-row) .demo-tile-changed .demo-tile {
  background: var(--tile-changed-fill) !important;
  color: var(--tile-changed-stroke) !important;
  border: 1px solid var(--tile-changed-stroke) !important;
}
.demo-connector {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  opacity: 0; transition: opacity 0.3s ease;
}
.demo-connector.visible { opacity: 1; }
.demo-connector-dot { width: 3px; height: 3px; border-radius: 50%; background: rgba(99,102,241,0.2); }
.demo-replay {
  display: block; margin: 14px auto 0; padding: 5px 16px;
  border-radius: 8px; border: 1px solid var(--border-light);
  background: var(--surface-2); color: var(--text-dim);
  font-family: 'Roboto', sans-serif; font-size: 0.72rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s ease;
}
.demo-replay:hover { background: var(--start-color); color: white; border-color: var(--start-color); transform: translateY(-1px); }
body.page-welcome .demo-replay {
  background: #FFFFFF; color: var(--text-welcome); border: none;
}
body.page-welcome .demo-replay:hover { background: var(--text-welcome); color: #FFFFFF; border: none; }

.leaderboard {
  width: 100%; max-width: 400px; margin-top: 20px;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 16px; padding: 20px; box-shadow: var(--shadow-sm);
  animation: fadeIn 0.5s ease;
}

.lb-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.lb-title { font-size: 0.95rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 6px; }
.lb-tabs { display: flex; gap: 4px; }
.lb-tab {
  padding: 4px 12px; border-radius: 6px; border: 1px solid var(--border-light);
  background: transparent; color: var(--text-dim);
  font-family: 'Roboto', sans-serif; font-size: 0.7rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s ease;
}
.lb-tab.active { background: var(--start-color); color: white; border-color: var(--start-color); }
body.page-welcome .lb-tab.active { background: #000000; color: #FFFFFF; border: none; }
body.page-welcome .leaderboard { background: var(--surface-card-welcome); border: 1px solid var(--border-card-welcome); }
body.page-welcome .lb-tab { background: #FFFFFF; border: none; color: var(--text-welcome); }
body.page-welcome .lb-title { color: var(--text-welcome); }
.lb-tab:hover:not(.active) { background: var(--surface-2); }
.lb-empty { color: var(--text-dim); font-size: 0.8rem; text-align: center; padding: 16px 0; font-style: italic; }
body.page-welcome .lb-empty { color: var(--text-welcome); font-style: normal; }
.lb-entry {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  margin-bottom: 4px; transition: all 0.2s ease;
  font-size: 0.8rem;
}
.lb-entry:hover { background: var(--surface-2); }
body.page-welcome .lb-entry {
  background: #FFFFFF;
  border: 1px solid #818181;
  border-radius: 10px;
  margin-bottom: 6px;
}
body.page-welcome .lb-entry:hover { background: #F8F8F8; }
.lb-rank {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.7rem; flex-shrink: 0;
}
.lb-rank-1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: white; }
.lb-rank-2 { background: linear-gradient(135deg, #9ca3af, #6b7280); color: white; }
.lb-rank-3 { background: linear-gradient(135deg, #d97706, #b45309); color: white; }
.lb-rank-default { background: var(--surface-3); color: var(--text-dim); }
body.page-welcome .lb-rank {
  background: #333333;
  color: #FFFFFF;
}
body.page-welcome .lb-rank-1,
body.page-welcome .lb-rank-2,
body.page-welcome .lb-rank-3 { background: #333333; color: #FFFFFF; }
.lb-puzzle { font-weight: 600; color: var(--text); flex: 1; }
.lb-puzzle span { color: var(--text-dim); font-weight: 400; }
body.page-welcome .lb-puzzle { color: var(--text-welcome); }
body.page-welcome .lb-puzzle span { color: var(--text-welcome); }
body.page-welcome .lb-detail { color: var(--text-welcome); }
.lb-detail { font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; color: var(--text-dim); text-align: right; white-space: nowrap; }
.lb-clear {
  display: block; margin: 10px auto 0; padding: 4px 14px;
  border-radius: 6px; border: 1px solid var(--border-light);
  background: transparent; color: var(--text-dim);
  font-family: 'Roboto', sans-serif; font-size: 0.65rem;
  cursor: pointer; transition: all 0.2s ease;
}
.lb-clear:hover { background: #fef2f2; color: var(--error); border-color: var(--error); }

@media (max-width: 420px) {
  .tile, .input-tile { width: 44px; height: 44px; font-size: 1.1rem; }
  .header h1 { font-size: 1.5rem; }
  .stats-bar { gap: 6px; }
  .stat { padding: 6px 8px; }
  .stat-value { font-size: 1rem; }
}
