:root {
  --cream: #f7eedc;
  --cream-shadow: rgba(52, 32, 18, 0.28);
  --ink: #362216;
  --ink-soft: #6d4f3a;
  --terracotta: #c45b28;
  --mango: #e2a227;
  --neem: #3d6342;
  --sky-warm: #f3d7a4;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--cream);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  touch-action: none;
}

#webgl-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

.hidden {
  display: none !important;
}

/* Loader */
#loader {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 35%, #fbf4e6 0%, #efe0c3 100%);
  transition: opacity 0.65s ease;
}

#loader.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loader-card {
  text-align: center;
  padding: 2rem 2.5rem;
}

.loader-era {
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  font-weight: 700;
  color: var(--terracotta);
  margin-bottom: 0.45rem;
}

.loader-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.loader-subtitle {
  margin-top: 0.35rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.loader-ring {
  width: 52px;
  height: 52px;
  margin: 1.4rem auto 0.9rem;
}

.loader-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: rgba(109, 79, 58, 0.18);
  stroke-width: 4;
}

.ring-arc {
  fill: none;
  stroke: var(--terracotta);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 119.38;
  stroke-dashoffset: 119.38;
  transition: stroke-dashoffset 0.15s ease-out;
}

.loader-status {
  font-size: 0.84rem;
  color: var(--ink-soft);
}

/* Painterly Brushstroke Reveal Wipe */
#wipe {
  position: fixed;
  inset: 0;
  z-index: 35;
  pointer-events: none;
  background: linear-gradient(125deg, #f7eedc 0%, #f1dec0 55%, #e7c899 100%);
  clip-path: circle(150% at 50% 50%);
  transition: clip-path 1.15s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease 0.85s;
}

#wipe.revealed {
  clip-path: circle(0% at 50% 50%);
  opacity: 0;
}

/* HUD */
#hud {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

#hud.hud-hidden {
  opacity: 0;
  transform: translateY(-10px);
}

.tilted-card {
  pointer-events: auto;
  background: var(--cream);
  color: var(--ink);
  border: 2px solid rgba(54, 34, 22, 0.12);
  border-radius: 12px;
  box-shadow: 0 5px 14px var(--cream-shadow);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.tilted-card:hover {
  transform: translateY(-2px) rotate(0deg) scale(1.04);
  box-shadow: 0 8px 18px rgba(52, 32, 18, 0.34);
}

.tilted-card:active {
  transform: translateY(1px) scale(0.97);
}

.hud-top-right {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn:nth-child(odd) {
  transform: rotate(3deg);
}

.icon-btn:nth-child(even) {
  transform: rotate(-3.5deg);
}

.icon-btn svg {
  width: 21px;
  height: 21px;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #c45b28;
  border: 2px solid rgba(54, 34, 22, 0.18);
}

.quality-badge {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--terracotta);
}

.info-glyph {
  font-family: Georgia, serif;
  font-size: 1.25rem;
  font-weight: 700;
}

.secrets-counter {
  margin-top: 2px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #fffaf0;
  text-shadow: 0 2px 6px rgba(45, 22, 8, 0.65);
  letter-spacing: 0.04em;
}

.zone-pill {
  background: rgba(247, 238, 220, 0.88);
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  box-shadow: 0 3px 10px rgba(45, 22, 8, 0.25);
  backdrop-filter: blur(4px);
}

/* Interact Prompt */
.interact-prompt {
  position: fixed;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(247, 238, 220, 0.95);
  border: 2px solid rgba(196, 91, 40, 0.35);
  padding: 10px 18px;
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(42, 22, 10, 0.35);
  font-weight: 700;
  cursor: pointer;
  animation: pulsePrompt 1.8s ease-in-out infinite;
}

@keyframes pulsePrompt {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-4px); }
}

.prompt-key {
  background: var(--terracotta);
  color: #fffaf0;
  font-size: 0.85rem;
  padding: 3px 9px;
  border-radius: 7px;
}

/* Active Playable HUD */
.playable-hud {
  position: fixed;
  top: 18px;
  left: 18px;
  width: min(340px, calc(100vw - 96px));
  background: rgba(247, 238, 220, 0.94);
  border: 2px solid rgba(54, 34, 22, 0.14);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 10px 26px rgba(42, 22, 10, 0.32);
  pointer-events: auto;
}

.playable-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.playable-title {
  font-family: Georgia, serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.playable-hint {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-top: 2px;
}

.exit-btn {
  padding: 5px 11px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 9px;
  transform: rotate(-2deg);
}

.playable-stats {
  margin-top: 10px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--terracotta);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.playable-meter-wrap {
  position: relative;
  height: 16px;
  margin-top: 12px;
  background: rgba(54, 34, 22, 0.14);
  border-radius: 999px;
  overflow: hidden;
}

.playable-meter-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--mango), var(--terracotta));
}

.playable-meter-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 62%;
  width: 18%;
  background: rgba(61, 99, 66, 0.45);
  border-left: 2px solid #2a4a2f;
  border-right: 2px solid #2a4a2f;
}

.playable-meter-cursor {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 5px;
  left: 0%;
  background: var(--ink);
  border-radius: 3px;
}

.action-btn {
  margin-top: 12px;
  width: 100%;
  padding: 9px 14px;
  background: var(--terracotta);
  color: #fffaf0;
  font-weight: 700;
  font-size: 0.9rem;
}

/* Crosshair */
.gulel-crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.crosshair-ring {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(255, 250, 240, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(45, 22, 8, 0.65);
}

.crosshair-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: var(--mango);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* Toast */
.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(54, 34, 22, 0.92);
  color: #fbf4e6;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  z-index: 30;
}

/* Info Modal */
.info-modal {
  position: fixed;
  inset: 0;
  z-index: 32;
  background: rgba(38, 22, 12, 0.42);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  pointer-events: auto;
}

.info-card {
  position: relative;
  width: min(560px, 100%);
  background: var(--cream);
  border-radius: 18px;
  padding: 26px 26px 22px;
  box-shadow: 0 18px 46px rgba(34, 18, 8, 0.45);
  transform: rotate(-0.8deg);
}

.close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  font-size: 1.3rem;
  font-weight: 700;
  transform: rotate(6deg);
}

.info-era {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--terracotta);
}

.info-card h2 {
  font-family: Georgia, serif;
  font-size: 1.65rem;
  margin-top: 3px;
}

.info-lead {
  margin-top: 8px;
  font-size: 0.92rem;
  line-height: 1.48;
  color: var(--ink-soft);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.info-grid h3 {
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--terracotta);
  margin-bottom: 6px;
}

.info-grid ul {
  list-style: none;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--ink);
}

.info-progress {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(196, 91, 40, 0.1);
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 700;
}

.info-v2 {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

/* Mobile Touch */
.touch-controls {
  position: fixed;
  bottom: 24px;
  right: 20px;
  display: flex;
  gap: 10px;
}

.touch-btn {
  padding: 12px 16px;
  font-weight: 800;
  font-size: 0.82rem;
}
