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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #06080c;
  font-family: Georgia, 'Times New Roman', serif;
  color: #cfd6dd;
  user-select: none;
}

#game { position: fixed; inset: 0; display: block; }

.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
}
.hidden { display: none !important; }

/* ---------- START ---------- */
#start {
  background: radial-gradient(ellipse at 50% 110%, #1b2a36 0%, #0a0f16 55%, #04060a 100%);
  text-align: center;
  z-index: 40;
}
.start-inner { max-width: 620px; padding: 24px; }
#start h1 {
  font-size: clamp(34px, 6vw, 58px);
  letter-spacing: 0.28em;
  font-weight: normal;
  color: #dbe4ec;
  text-shadow: 0 0 24px rgba(120,170,200,0.25);
}
.tagline {
  letter-spacing: 0.5em; font-size: 12px; color: #6f8294;
  margin: 10px 0 28px; text-transform: uppercase;
}
.brief { font-size: 16px; line-height: 1.55; color: #9fb0bf; font-style: italic; }
.controls-grid {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px;
  margin: 30px 0 26px; font-size: 13px; color: #7d8fa0; font-style: normal;
}
.controls-grid b { color: #c4d2de; font-weight: normal; border: 1px solid #3a4a58; border-radius: 4px; padding: 1px 7px; margin-right: 5px; font-family: monospace; }
#beginBtn, #againBtn {
  background: none; color: #d8e2ea; border: 1px solid #5a6f80;
  font-family: Georgia, serif; font-size: 17px; letter-spacing: 0.18em;
  padding: 12px 38px; cursor: pointer; transition: all 0.25s;
}
#beginBtn:hover, #againBtn:hover { background: #20303d; border-color: #9db4c6; }

/* ---------- PAUSE ---------- */
#pause { background: rgba(4,7,10,0.72); z-index: 30; }
.pause-inner { text-align: center; }
.pause-inner h2 { letter-spacing: 0.4em; font-weight: normal; color: #b9c7d3; }
.pause-inner p { margin-top: 12px; color: #7d8fa0; font-style: italic; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#compass {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  opacity: 0.85;
}
#crosshair {
  position: absolute; top: 50%; left: 50%; width: 4px; height: 4px;
  margin: -2px 0 0 -2px; border-radius: 50%;
  background: rgba(220,230,240,0.65);
  box-shadow: 0 0 6px rgba(0,0,0,0.8);
}
#prompt {
  position: absolute; top: 58%; left: 50%; transform: translateX(-50%);
  font-size: 16px; font-style: italic; color: #e9e2c8;
  text-shadow: 0 1px 4px #000, 0 0 14px rgba(0,0,0,0.9);
  letter-spacing: 0.04em;
}
#objective {
  position: absolute; top: 52px; left: 50%; transform: translateX(-50%);
  font-size: 13px; color: #93a4b3; font-style: italic;
  text-shadow: 0 1px 3px #000;
}
#hint {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: #6c7d8c; letter-spacing: 0.08em;
  text-shadow: 0 1px 3px #000;
  transition: opacity 3s; white-space: nowrap;
}

/* ---------- NOTE PAPER ---------- */
#noteModal { background: rgba(3,5,8,0.55); z-index: 25; }
.paper {
  position: relative;
  width: min(560px, 92vw); max-height: 80vh; overflow-y: auto;
  background: linear-gradient(176deg, #efe7d0 0%, #e6dcc0 60%, #ddd2b2 100%);
  color: #2b2317;
  padding: 42px 46px 30px;
  transform: rotate(-0.6deg);
  box-shadow: 0 18px 60px rgba(0,0,0,0.75), inset 0 0 50px rgba(120,95,50,0.18);
}
.paper-pin {
  position: absolute; top: 12px; left: 50%; width: 12px; height: 12px;
  margin-left: -6px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #b08c5a, #5e4524);
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.paper h3 {
  font-size: 15px; letter-spacing: 0.14em; text-transform: uppercase;
  color: #5a4a2e; border-bottom: 1px solid #b7a87f;
  padding-bottom: 10px; margin-bottom: 16px; font-weight: normal;
}
#noteBody { font-size: 16.5px; line-height: 1.6; font-style: italic; white-space: pre-line; }
.paper-close { margin-top: 24px; font-size: 12px; color: #8a7850; text-align: center; letter-spacing: 0.1em; }

/* ---------- JOURNAL ---------- */
#journal { background: rgba(3,5,8,0.82); z-index: 25; }
.journal-inner {
  width: min(640px, 94vw); height: 82vh;
  background: #11181f; border: 1px solid #2c3a47;
  padding: 26px 8px 26px 30px; display: flex; flex-direction: column;
}
.journal-inner h2 { font-weight: normal; letter-spacing: 0.24em; font-size: 18px; color: #c2cfdb; }
#journalCount { color: #6f8294; font-size: 14px; }
.journal-tip { font-size: 11px; color: #5c6c7a; margin: 6px 0 14px; font-style: italic; }
#journalList { overflow-y: auto; padding-right: 20px; flex: 1; }
#journalList::-webkit-scrollbar { width: 6px; }
#journalList::-webkit-scrollbar-thumb { background: #34465a; }
.journal-entry { margin-bottom: 26px; border-left: 2px solid #3a4c5e; padding-left: 16px; }
.journal-entry h4 { font-weight: normal; color: #d8cfa8; letter-spacing: 0.08em; font-size: 14px; text-transform: uppercase; }
.journal-entry .where { font-size: 11px; color: #61788c; margin: 3px 0 8px; font-style: italic; }
.journal-entry p { font-size: 14px; line-height: 1.55; color: #a8b4bf; font-style: italic; white-space: pre-line; }
.journal-empty { color: #5c6c7a; font-style: italic; }

/* ---------- KEYPAD ---------- */
#keypad { background: rgba(3,5,8,0.6); z-index: 25; }
.keypad-inner {
  background: linear-gradient(180deg, #2b3138, #1b2026);
  border: 1px solid #454f59; border-radius: 8px;
  padding: 26px 30px; text-align: center;
  box-shadow: 0 16px 50px rgba(0,0,0,0.8);
}
.keypad-label { font-family: monospace; font-size: 11px; letter-spacing: 0.2em; color: #76858f; margin-bottom: 16px; }
#keypadDisplay {
  font-family: monospace; font-size: 34px; letter-spacing: 0.3em;
  background: #0c1410; color: #7dff9a; border: 1px solid #2e4a36;
  padding: 10px 0; margin-bottom: 18px; border-radius: 4px;
  text-shadow: 0 0 10px rgba(90,255,140,0.5);
}
#keypadDisplay.wrong { color: #ff6a5a; text-shadow: 0 0 10px rgba(255,90,70,0.6); animation: shake 0.35s; }
#keypadDisplay.right { color: #b8ffc9; }
@keyframes shake {
  0%,100% { transform: translateX(0); } 20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); }
}
.keypad-grid { display: grid; grid-template-columns: repeat(3, 64px); gap: 8px; justify-content: center; }
.keypad-grid button {
  font-family: monospace; font-size: 20px; padding: 12px 0;
  background: #313a43; color: #cfd9e2; border: 1px solid #4a565f;
  border-radius: 4px; cursor: pointer;
}
.keypad-grid button:hover { background: #3e4a55; }
.keypad-grid button:active { background: #29323a; }
.keypad-tip { margin-top: 14px; font-size: 11px; color: #66747f; font-style: italic; }

/* ---------- FADE / ENDING ---------- */
#fade {
  position: fixed; inset: 0; background: #000; opacity: 0;
  pointer-events: none; transition: opacity 0.9s; z-index: 50;
}
#ending {
  position: fixed; inset: 0; background: #000; z-index: 60;
  display: flex; align-items: center; justify-content: center;
}
#endText {
  max-width: 720px; padding: 30px; font-size: clamp(17px, 2.4vw, 23px);
  line-height: 1.7; color: #c9d2da; font-style: italic; text-align: center;
  text-shadow: 0 0 20px rgba(110,150,180,0.15);
}
#endText.said { color: #d8cfa8; }
#endTitle { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #000; animation: fadeIn 4s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
#endTitle h1 { font-size: clamp(30px, 5.5vw, 54px); letter-spacing: 0.3em; font-weight: normal; color: #dbe4ec; }
#endTitle p { margin: 18px 0 44px; letter-spacing: 0.34em; font-size: 13px; color: #8c4a42; }
