* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  /* Kill the iOS "swipe selects everything and turns blue" behaviour */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0e0c0a;
  font-family: "Inter", sans-serif;
  /* Prevent the page itself from scrolling / rubber-banding on touch drags */
  touch-action: none;
  overscroll-behavior: none;
}
canvas {
  display: block;
}
/* Even if a selection somehow occurs, don't paint it blue */
::selection {
  background: transparent;
}
::-moz-selection {
  background: transparent;
}

/* ---------- Reticle & prompt ---------- */
#reticle {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.65);
  pointer-events: none;
  z-index: 5;
  transition:
    transform 0.15s,
    background 0.15s;
}
#reticle.hot {
  transform: scale(1.9);
  background: #9ab89a;
}
#prompt {
  position: fixed;
  left: 50%;
  bottom: 9%;
  transform: translateX(-50%);
  padding: 10px 22px;
  background: rgba(20, 16, 12, 0.78);
  color: #f3ead9;
  border: 1px solid rgba(154, 184, 154, 0.45);
  border-radius: 30px;
  font-size: 14px;
  letter-spacing: 0.4px;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(6px);
}
#prompt b {
  color: #9ab89a;
  font-weight: 500;
}
@media (pointer: coarse) {
  #prompt { display: none; }
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 26px;
  z-index: 6;
  pointer-events: none;
  background: linear-gradient(rgba(10, 8, 6, 0.55), transparent);
}
#hud h1 {
  font-family: "Cormorant Garamond", serif;
  font-size: 16px;
  font-weight: 600;
  color: #f3ead9;
  letter-spacing: 2px;
}
#hud .btns {
  pointer-events: auto;
  display: flex;
  gap: 10px;
}
.hud-btn {
  padding: 8px 18px;
  background: rgba(243, 234, 217, 0.08);
  color: #f3ead9;
  border: 1px solid rgba(243, 234, 217, 0.35);
  border-radius: 24px;
  font-size: 13px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: 0.2s;
  font-family: "Inter", sans-serif;
}
.hud-btn:hover {
  background: rgba(154, 184, 154, 0.22);
  border-color: #9ab89a;
}
#hint {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(243, 234, 217, 0.45);
  font-size: 12px;
  letter-spacing: 0.6px;
  z-index: 5;
  pointer-events: none;
}

/* ===================== Idle controls hint ===================== */
#idleHint {
  position: fixed;
  left: 50%;
  bottom: clamp(24px, 7vh, 64px);
  transform: translate(-50%, 16px) scale(0.97);
  max-width: calc(100vw - 32px);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.3, 1);
  font-family: "Inter", sans-serif;
  color: #e9dcc3;
  text-align: center;
  background: rgba(12, 9, 6, 0.84);
  border: 1px solid rgba(255, 227, 180, 0.16);
  border-radius: 16px;
  padding: 18px 26px 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 227, 180, 0.06);
}
#idleHint.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

/* On touch, lift the hint clear of the joystick (≈132px tall, sits 30px
   from the bottom) so it never overlaps the control. */
#idleHint.touch {
  bottom: calc(132px + 54px + env(safe-area-inset-bottom));
}

/* Desktop / mobile variants (the .touch class is set from JS) */
#idleHint .ih-mobile { display: none; }
#idleHint.touch .ih-desktop { display: none; }
#idleHint.touch .ih-mobile { display: block; }

/* ---------- Key caps ---------- */
#idleHint .key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 9px;
  border-radius: 7px;
  font: 500 13px/1 "Inter", sans-serif;
  letter-spacing: 0.02em;
  color: #f5e7c8;
  background: linear-gradient(180deg, rgba(255, 227, 180, 0.14), rgba(255, 227, 180, 0.05));
  border: 1px solid rgba(255, 227, 180, 0.32);
  box-shadow: 0 2px 0 rgba(255, 227, 180, 0.14), 0 3px 6px rgba(0, 0, 0, 0.35);
}
#idleHint .key.small {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 5px;
  font-size: 11px;
  box-shadow: 0 1.5px 0 rgba(255, 227, 180, 0.14), 0 2px 4px rgba(0, 0, 0, 0.35);
}

/* WASD / arrow clusters laid out as real keyboards */
#idleHint .ih-keygroup {
  display: grid;
  grid-template-columns: repeat(3, 32px);
  gap: 5px;
  justify-items: center;
}
#idleHint .ih-keygroup .key { width: 32px; padding: 0; }
#idleHint .ih-keygroup .key.blank { visibility: hidden; }

/* "W / ↑" gently press themselves to say: go forward */
@keyframes ihPress {
  0%, 68%, 92%, 100% {
    transform: translateY(0);
    background: linear-gradient(180deg, rgba(255, 227, 180, 0.14), rgba(255, 227, 180, 0.05));
    box-shadow: 0 2px 0 rgba(255, 227, 180, 0.14), 0 3px 6px rgba(0, 0, 0, 0.35);
  }
  76%, 84% {
    transform: translateY(2px);
    background: linear-gradient(180deg, rgba(255, 227, 180, 0.32), rgba(255, 227, 180, 0.14));
    box-shadow: 0 0 0 rgba(255, 227, 180, 0), 0 0 16px rgba(255, 227, 180, 0.28);
  }
}
#idleHint .key.pulse { animation: ihPress 2.6s ease-in-out infinite; }

/* ---------- Top row: movement ---------- */
#idleHint .ih-move {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 15px;
}
#idleHint .ih-or {
  font-size: 12px;
  font-style: italic;
  color: rgba(233, 220, 195, 0.45);
}
#idleHint .ih-label {
  font-family: "Cormorant Garamond", serif;
  font-size: 19px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #d9c79f;
  margin-left: 8px;
}

/* ---------- Bottom row: everything else ---------- */
#idleHint .ih-extras {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
  font-size: 12.5px;
  color: rgba(233, 220, 195, 0.8);
  white-space: nowrap;
}
#idleHint .ih-extras > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
#idleHint .ih-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 227, 180, 0.35);
}

/* Tiny CSS mouse with an animated scroll line */
#idleHint .ih-mouse {
  position: relative;
  display: inline-block;
  width: 13px;
  height: 19px;
  border: 1.5px solid rgba(245, 231, 200, 0.85);
  border-radius: 7px;
}
#idleHint .ih-mouse::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 3px;
  width: 1.5px;
  height: 4px;
  margin-left: -0.75px;
  border-radius: 1px;
  background: rgba(245, 231, 200, 0.85);
  animation: ihWheel 2.6s ease-in-out infinite;
}
@keyframes ihWheel {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.85; }
  75%, 88% { transform: translateY(3px); opacity: 1; }
}

/* ---------- Mobile ---------- */
#idleHint .ih-stick {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 2px auto 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 227, 180, 0.38);
  background: radial-gradient(circle at 50% 40%,
    rgba(255, 227, 180, 0.1), rgba(255, 227, 180, 0.03) 62%, transparent 74%);
}
#idleHint .ih-stick span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: rgba(255, 227, 180, 0.22);
  border: 1px solid rgba(255, 227, 180, 0.6);
  box-shadow: 0 0 14px rgba(255, 227, 180, 0.2);
  animation: ihStick 3s ease-in-out infinite;
}
@keyframes ihStick {
  0%, 100% { transform: translate(0, 0); }
  28% { transform: translate(0, -13px); }
  52% { transform: translate(0, 0); }
  76% { transform: translate(11px, 0); }
}
#idleHint .ih-mobile p {
  margin: 0;
  font-size: 13px;
  color: rgba(233, 220, 195, 0.85);
}
#idleHint .ih-mobile b { color: #f5e7c8; font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  #idleHint .key.pulse,
  #idleHint .ih-mouse::before,
  #idleHint .ih-stick span { animation: none; }
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 6, 0.88);
  backdrop-filter: blur(10px);
  transition: opacity 0.4s;
}
.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.card {
  max-width: 760px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 54px 60px;
  margin: 18px;
  background: #171310;
  border: 1px solid rgba(154, 184, 154, 0.28);
  border-radius: 6px;
  color: #e9dfcd;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.card::-webkit-scrollbar {
  width: 8px;
}
.card::-webkit-scrollbar-thumb {
  background: #3a322a;
  border-radius: 4px;
}
.card h2 {
  font-family: "Cormorant Garamond", serif;
  font-size: 44px;
  font-weight: 600;
  color: #f3ead9;
  letter-spacing: 2px;
  line-height: 1.1;
}
.card h3 {
  font-family: "Cormorant Garamond", serif;
  font-size: 22px;
  color: #9ab89a;
  margin: 28px 0 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
}
.card .sub {
  color: #b8a98e;
  font-size: 14px;
  letter-spacing: 1.5px;
  margin-top: 6px;
  text-transform: uppercase;
}
.card p {
  font-size: 15px;
  line-height: 1.75;
  font-weight: 300;
  color: #d8cdb8;
  margin-bottom: 10px;
}
.card ul {
  list-style: none;
}
.card li {
  font-size: 14px;
  line-height: 1.65;
  font-weight: 300;
  color: #d8cdb8;
  padding: 10px 0 10px 18px;
  border-left: 2px solid rgba(154, 184, 154, 0.35);
  margin-bottom: 8px;
}
.card li b {
  color: #9ab89a;
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
}
.enter-btn {
  display: block;
  margin: 36px auto 0;
  padding: 15px 52px;
  background: #9ab89a;
  color: #171310;
  border: none;
  border-radius: 32px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: 0.2s;
  font-family: "Inter", sans-serif;
}
.enter-btn:hover {
  background: #b2ccb2;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(154, 184, 154, 0.3);
}
.keys {
  display: flex;
  gap: 26px;
  justify-content: center;
  margin-top: 26px;
  flex-wrap: wrap;
  color: #b8a98e;
  font-size: 12.5px;
  letter-spacing: 0.5px;
}
.keys span b {
  display: inline-block;
  padding: 3px 9px;
  border: 1px solid #4a4036;
  border-radius: 5px;
  margin-right: 6px;
  color: #e9dfcd;
  font-weight: 400;
}
#loadbar {
  height: 2px;
  background: #2a241d;
  margin-top: 30px;
  border-radius: 2px;
  overflow: hidden;
}
#loadbar div {
  height: 100%;
  width: 0%;
  background: #9ab89a;
  transition: width 0.3s;
}

/* ---------- Artwork panel ---------- */
#panelBackdrop {
  position: fixed;
  inset: 0;
  z-index: 24;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}
#panelBackdrop.open {
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}
#artPanel {
  position: fixed;
  top: 0;
  right: -460px;
  width: 440px;
  height: 100%;
  z-index: 25;
  background: #171310;
  border-left: 1px solid rgba(154, 184, 154, 0.3);
  transition: right 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow-y: auto;
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5);
}
#artPanel.open {
  right: 0;
}
#artPanel img {
  width: 100%;
  display: block;
  background: #0e0c0a;
}
#artPanel .inner {
  padding: 30px 34px 50px;
  color: #e9dfcd;
}
#artPanel h2 {
  font-family: "Cormorant Garamond", serif;
  font-size: 32px;
  font-weight: 600;
  color: #f3ead9;
  line-height: 1.15;
}
#artPanel .meta {
  margin-top: 18px;
  border-top: 1px solid #2e2820;
}
#artPanel .meta div {
  display: flex;
  justify-content: space-between;
  padding: 11px 2px;
  border-bottom: 1px solid #2e2820;
  font-size: 14px;
}
#artPanel .meta span:first-child {
  color: #9c8e74;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 11.5px;
  padding-top: 2px;
}
#artPanel .meta span:last-child {
  color: #e9dfcd;
  font-weight: 300;
  text-align: right;
  max-width: 65%;
}
#artPanel .desc {
  margin-top: 18px;
  font-size: 14px;
  line-height: 1.7;
  font-weight: 300;
  color: #c9bda6;
  font-style: italic;
}
#closePanel {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(14, 12, 10, 0.85);
  border: 1px solid rgba(243, 234, 217, 0.4);
  color: #f3ead9;
  font-size: 17px;
  cursor: pointer;
  z-index: 26;
  opacity: 0;
  pointer-events: none;
  transition: background 0.2s, color 0.2s, opacity 0.3s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
#closePanel.open {
  opacity: 1;
  pointer-events: auto;
}
#closePanel:hover {
  background: #9ab89a;
  color: #171310;
}
@media (max-width: 560px) {
  #artPanel {
    width: 100%;
    right: -100%;
  }
  .card {
    padding: 34px 26px;
  }
}
