/* Boot splash that always renders, even before Tailwind/JS finish loading.
   Uses only built-in fonts and inline colors so it renders even on cold-cache CN networks. */
html, body { margin: 0; padding: 0; }
body { background: #F9F8F6; color: #2C2A26; }
#boot-splash {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #F9F8F6 0%, #F2F0EB 100%);
  color: #2C2A26;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: Georgia, "Playfair Display", "Times New Roman", serif;
  z-index: 9999;
  padding: 1.5rem;
  text-align: center;
}
#boot-splash[hidden] { display: none; }
#boot-splash .boot-mark {
  font-size: 0.7rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #4A463F;
  opacity: 0.7;
  margin-bottom: 1.25rem;
}
#boot-splash .boot-title {
  font-size: clamp(2rem, 6vw, 3.5rem);
  letter-spacing: -0.02em;
  margin: 0 0 1.75rem 0;
  font-weight: 600;
}
#boot-splash .boot-title em { font-style: italic; font-weight: 400; }
#boot-splash .boot-dots { display: inline-flex; gap: 0.5rem; }
#boot-splash .boot-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2C2A26;
  opacity: 0.3;
  animation: boot-pulse 1.4s ease-in-out infinite;
}
#boot-splash .boot-dots span:nth-child(2) { animation-delay: 0.2s; }
#boot-splash .boot-dots span:nth-child(3) { animation-delay: 0.4s; }
#boot-slow-hint {
  margin-top: 2rem;
  max-width: 32rem;
  font-family: system-ui, -apple-system, "Segoe UI", "Inter", sans-serif;
  font-size: 0.875rem;
  color: #4A463F;
  opacity: 0;
  transition: opacity 0.5s ease;
}
#boot-slow-hint[data-visible="true"] { opacity: 1; }
#boot-error {
  margin-top: 2rem;
  max-width: 36rem;
  padding: 1.25rem 1.5rem;
  font-family: system-ui, -apple-system, "Segoe UI", "Inter", sans-serif;
  font-size: 0.9rem;
  color: #7C2D12;
  background: rgba(254, 226, 226, 0.55);
  border: 1px solid rgba(252, 165, 165, 0.55);
  border-radius: 0.5rem;
  text-align: left;
}
#boot-error[hidden] { display: none; }
#boot-error h2 {
  margin: 0 0 0.5rem 0;
  font-family: Georgia, serif;
  font-size: 1.1rem;
  color: #7C2D12;
}
#boot-error button {
  margin-top: 0.75rem;
  padding: 0.5rem 1.5rem;
  background: #2C2A26;
  color: #F9F8F6;
  border: none;
  border-radius: 9999px;
  font-family: Georgia, serif;
  cursor: pointer;
  font-size: 0.875rem;
}
#boot-error details {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: #4A463F;
}
#boot-error details pre {
  margin-top: 0.5rem;
  max-height: 12rem;
  overflow: auto;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 0.25rem;
  white-space: pre-wrap;
  word-break: break-word;
}
@keyframes boot-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* Archive puzzle embedded in the boot splash. Built with vanilla
   JS / SVG so it works before the React bundle finishes downloading.
   Hidden until the user clicks the discreet toggle that fades in 1.2s
   after first paint, so fast loads never see it. */
#boot-game-toggle {
  margin-top: 2.25rem;
  background: transparent;
  border: 1px solid #2C2A26;
  border-radius: 9999px;
  padding: 0.55rem 1.4rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #2C2A26;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease, background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
#boot-game-toggle[data-visible="true"] { opacity: 0.85; pointer-events: auto; }
#boot-game-toggle:hover { background: #2C2A26; color: #F9F8F6; opacity: 1; transform: translateY(-1px); }
#boot-game-toggle[data-hidden="true"] { display: none; }
#boot-game {
  display: none;
  margin-top: 1.75rem;
  flex-direction: column;
  align-items: center;
}
#boot-game[data-open="true"] {
  display: flex;
  animation: boot-game-in 0.45s ease-out;
}
#boot-game .bg-frame {
  position: relative;
  width: min(320px, 80vw);
  height: min(320px, 80vw);
  border: 1.5px solid #A89F91;
  border-radius: 2px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  background: linear-gradient(135deg, #F9F8F6 0%, #ECE3D1 100%);
  box-shadow: 0 12px 40px -12px rgba(44,42,38,0.12), inset 0 1px 0 rgba(255,255,255,0.6);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}
#boot-game .bg-frame[data-done="true"] {
  border-color: #2C2A26;
  animation: boot-game-celebrate 0.6s ease-out;
}
#boot-game .bg-slot {
  position: relative;
  border: 1px solid rgba(44,42,38,0.14);
  background: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
}
#boot-game .bg-slot[data-active="true"] { border-color: #2C2A26; background: #F9F8F6; }
#boot-game .bg-slot[data-wrong="true"] { border-color: #B91C1C; background: #FEF2F2; }
#boot-game .bg-fragment {
  position: absolute;
  inset: 10px;
  width: calc(100% - 20px);
  height: calc(100% - 20px);
}
#boot-game .bg-fragment[data-ghost="true"] { opacity: 0.09; }
#boot-game .bg-slot-label,
#boot-game .bg-piece-label {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  min-width: 1.2rem;
  height: 1.2rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.55rem;
  line-height: 1;
}
#boot-game .bg-slot-label {
  border: 1px solid #D1CCC0;
  color: #6E665A;
  background: rgba(255,255,255,0.8);
}
#boot-game .bg-piece-label {
  color: #F9F8F6;
  background: #2C2A26;
}
#boot-game .bg-tray {
  width: min(320px, 80vw);
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}
#boot-game .bg-piece {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid #E6E2D8;
  background: linear-gradient(135deg, #F9F8F6, #E6E2D8);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
#boot-game .bg-piece[data-piece="r1c1"] { background: linear-gradient(135deg, #F9F8F6, #E6E2D8); }
#boot-game .bg-piece[data-piece="r1c2"] { background: linear-gradient(135deg, #F9F8F6, #E8E0D2); }
#boot-game .bg-piece[data-piece="r1c3"] { background: linear-gradient(135deg, #F9F8F6, #E2DDD4); }
#boot-game .bg-piece[data-piece="r2c1"] { background: linear-gradient(135deg, #F9F8F6, #E0D9CB); }
#boot-game .bg-piece[data-piece="r2c2"] { background: linear-gradient(135deg, #F9F8F6, #DDD8CE); }
#boot-game .bg-piece[data-piece="r2c3"] { background: linear-gradient(135deg, #F9F8F6, #DAD3C6); }
#boot-game .bg-piece[data-piece="r3c1"] { background: linear-gradient(135deg, #F9F8F6, #E4DDD0); }
#boot-game .bg-piece[data-piece="r3c2"] { background: linear-gradient(135deg, #F9F8F6, #DFD8CC); }
#boot-game .bg-piece[data-piece="r3c3"] { background: linear-gradient(135deg, #F9F8F6, #D8D1C5); }
#boot-game .bg-piece:hover,
#boot-game .bg-piece[data-selected="true"] {
  transform: translateY(-2px) scale(1.03);
  border-color: #2C2A26;
  box-shadow: 0 4px 12px -4px rgba(44,42,38,0.15);
}
#boot-game .bg-piece svg {
  position: absolute;
  inset: 8px;
  width: 100%;
  height: 100%;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
}
#boot-game .bg-meta {
  margin-top: 0.95rem;
  font-family: Georgia, "Playfair Display", serif;
  font-style: italic;
  font-size: 1rem;
  color: #2C2A26;
  opacity: 0.3;
  transition: opacity 0.7s ease;
  min-height: 22px;
}
#boot-game .bg-meta[data-done="true"] { opacity: 1; }
#boot-game .bg-era {
  margin-top: 0.25rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.6rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #4A463F;
  opacity: 0.5;
  transition: opacity 0.7s ease;
  min-height: 12px;
}
#boot-game .bg-era[data-done="true"] { opacity: 0.85; }
#boot-game .bg-controls {
  margin-top: 0.85rem;
  display: flex;
  gap: 1.4rem;
}
#boot-game .bg-controls button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9999px;
  padding: 0.4rem 0.9rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #5B5246;
  cursor: pointer;
  transition: all 0.2s ease;
}
#boot-game .bg-controls button:hover {
  color: #2C2A26;
  border-color: #D1CCC0;
  background: rgba(255,255,255,0.5);
}
#boot-game .bg-hint {
  margin-top: 0.5rem;
  font-family: system-ui, -apple-system, "Segoe UI", "Inter", sans-serif;
  font-size: 0.7rem;
  color: #6E665A;
  max-width: 240px;
  text-align: center;
}
@keyframes boot-game-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes boot-game-celebrate {
  0% { transform: scale(1); box-shadow: 0 12px 40px -12px rgba(44,42,38,0.12); }
  50% { transform: scale(1.02); box-shadow: 0 0 0 8px rgba(44,42,38,0.04); }
  100% { transform: scale(1); box-shadow: 0 12px 40px -12px rgba(44,42,38,0.12); }
}
@keyframes boot-slot-placed {
  0% { background: rgba(255,255,255,0.9); }
  100% { background: rgba(255,255,255,0.5); }
}
#boot-game .bg-slot[data-just-placed="true"] {
  animation: boot-slot-placed 0.4s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  #boot-game-toggle,
  #boot-game,
  #boot-splash .boot-dots span,
  #boot-game .bg-piece,
  #boot-game .bg-meta,
  #boot-game .bg-era {
    transition: none !important;
    animation: none !important;
  }
}
