:root {
  color-scheme: dark;
  --bg: #08070b;
  --gold: #dfbb7b;
  --cream: #efe4cd;
  --ink: #0c0a0f;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--cream);
  font-family: "Source Sans Pro", Arial, sans-serif;
}

.hidden { display: none !important; }
.hidden-hud { position: absolute; width: 0; height: 0; overflow: hidden; opacity: 0; pointer-events: none; }

.screen { position: fixed; inset: 0; z-index: 30; }

#title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0 0 5vh;
  background: #060406 url('images/IMG_0452.png') center center / cover no-repeat;
  overflow: hidden;
}

.title-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.1) 35%, rgba(0,0,0,0) 55%, rgba(0,0,0,0.15) 100%);
}

.title-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.15;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.1) 0.9px, transparent 0);
  background-size: 3px 3px;
  animation: grain 0.8s steps(2) infinite;
}

.title-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.tap-prompt {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #e8d4a0;
  opacity: 0.7;
  min-height: 1.2em;
}

.start-btn {
  border: 1px solid rgba(200,170,100,0.6);
  border-radius: 2px;
  background: rgba(20,14,10,0.85);
  color: #e8d0a0;
  padding: 0.65rem 2.2rem;
  font-family: "Source Sans Pro", Arial, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,220,160,0.1);
  animation: pulse-btn 2s ease-in-out infinite;
}

.start-btn:hover { background: rgba(40,28,16,0.92); border-color: rgba(230,190,110,0.8); }
.start-btn:active { transform: scale(0.97); }

#typewriter-screen {
  background: #000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 10vh;
}

.typewriter-card {
  width: min(980px, 92vw);
  min-height: 130px;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(0,0,0,0.74);
  border-radius: 9px;
  padding: 0.95rem 1rem;
}

#typewriter-text {
  margin: 0;
  color: #fff;
  white-space: pre-line;
  font-family: "Courier New", monospace;
  font-size: clamp(1rem, 2.3vw, 1.52rem);
  line-height: 1.44;
}

.type-cursor {
  display: inline-block;
  width: 11px;
  height: 1.28rem;
  margin-top: 0.35rem;
  background: #fff;
  animation: blink 1s step-end infinite;
}

#game-root { position: fixed; inset: 0; }
#game-canvas { width: 100%; height: 100%; display: block; }

.hud {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 8;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  background: rgba(6,7,10,0.5);
  backdrop-filter: blur(3px);
}

.hud p {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
}

.objective-box {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom, 0px));
  z-index: 8;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(226,186,120,0.35);
  background: rgba(6,7,10,0.65);
  backdrop-filter: blur(3px);
  pointer-events: none;
}

.objective-box p { margin: 0; }
#objective-text { font-size: 0.86rem; }
#interaction-text { margin-top: 0.1rem; font-size: 0.72rem; color: #d8c7a5; }

.dialogue-box {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 116px;
  z-index: 10;
  width: min(920px, 92vw);
  border-radius: 10px;
  border: 1px solid rgba(236,208,156,0.72);
  background: rgba(0,0,0,0.86);
  padding: 0.85rem 0.95rem;
  font-family: "Libre Baskerville", serif;
  font-size: clamp(0.95rem, 2vw, 1.14rem);
  line-height: 1.36;
  white-space: pre-line;
}

.evidence-overlay {
  position: absolute;
  inset: 0;
  z-index: 14;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.74);
}

.evidence-card {
  width: min(680px, 92vw);
  border: 1px solid rgba(242,214,161,0.84);
  border-radius: 12px;
  background: rgba(10,7,7,0.95);
  padding: 1rem;
}

.evidence-card h3 { margin: 0 0 0.45rem; font-family: "Playfair Display", serif; }
.evidence-card p { margin: 0; line-height: 1.45; }

.close-evidence-btn {
  margin-top: 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(244,216,166,0.72);
  background: rgba(26,20,16,0.82);
  color: #efdcb9;
  padding: 0.42rem 0.78rem;
  cursor: pointer;
}

.controls-layer {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 58px;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 12;
}

.joystick { width: 140px; height: 140px; position: relative; pointer-events: auto; touch-action: none; }

.joystick-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(226,186,120,0.74);
  background: radial-gradient(circle at 30% 25%, rgba(255,201,110,0.22), rgba(0,0,0,0.2));
}

.joystick-knob {
  position: absolute;
  width: 62px;
  height: 62px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(255,237,205,0.92);
  background: radial-gradient(circle at 30% 30%, #e6d4b6 0%, #9f8768 55%, #594636 100%);
}

.button-stack { display: flex; gap: 14px; pointer-events: auto; touch-action: none; }

.type-key {
  width: 78px;
  height: 78px;
  border-radius: 999px;
  border: 2px solid rgba(245,229,195,0.9);
  background: radial-gradient(circle at 32% 30%, #f8edd5 0%, #bfaa8e 45%, #62503e 78%);
  color: #18120a;
  font-family: "Libre Baskerville", serif;
  font-size: 1.35rem;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(0,0,0,0.34);
}

.type-key:active { transform: translateY(2px); }

@keyframes pulse-btn {
  0%, 100% { box-shadow: 0 4px 20px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,220,160,0.1); }
  50% { box-shadow: 0 4px 28px rgba(200,160,60,0.25), inset 0 1px 0 rgba(255,220,160,0.15); }
}

@keyframes blink { 50% { opacity: 0; } }
@keyframes grain { from { transform: translate(0,0); } to { transform: translate(-3px,3px); } }

@media (hover: none) and (pointer: coarse), (max-width: 930px) {
  .controls-layer { display: flex; }
}
