* { margin: 0; box-sizing: border-box; }
body { background: #000; font-family: Georgia, serif; color: #e8f4ff; overflow: hidden; }
.hidden { display: none !important; }
#game { position: fixed; inset: 0; }

/* Title */
#title-screen { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 26px;
  background-size: cover; background-position: center;
  background-image: linear-gradient(rgba(0,0,10,.35), rgba(0,0,10,.65)), url('../assets/images/cg/cg_title.png'); }
#title-logo { max-width: min(80vw, 640px); filter: drop-shadow(0 4px 18px #000); animation: logo-flicker 6s infinite; }
@keyframes logo-flicker {
  0%, 93%, 100% { opacity: 1; transform: none; }
  94% { opacity: .55; transform: translateX(3px) skewX(-2deg); filter: hue-rotate(90deg) drop-shadow(0 4px 18px #000); }
  95% { opacity: 1; transform: none; }
  97% { opacity: .7; transform: translateX(-3px); filter: saturate(2) drop-shadow(0 4px 18px #000); }
}
.title-buttons { display: flex; flex-direction: column; gap: 12px; align-items: center; }
#title-screen button, #choices button, .modal button { font-family: inherit; cursor: pointer; color: #e8f4ff;
  background-color: rgba(13,21,38,.9); background-size: 100% 100%; border: 2px solid #00e5ff;
  border-radius: 10px; padding: 12px 30px; font-size: 17px; transition: box-shadow .15s, transform .15s, border-color .15s; }
#title-screen button:hover, #choices button:hover, .modal button:hover {
  box-shadow: 0 0 16px #00e5ffaa; transform: translateY(-1px); }
#title-screen button:active, #choices button:active, .modal button:active { transform: translateY(1px); }
#title-screen button:focus-visible, #choices button:focus-visible, .modal button:focus-visible,
.modal input:focus-visible { outline: 2px solid #ff3d81; outline-offset: 2px; }
#title-screen .title-buttons button { min-width: 240px; letter-spacing: 2px; }
#credits { font-size: 11px; color: #5a6a8f; max-width: 640px; text-align: center; }

/* Modals (settings / gallery / menu) */
.modal { position: fixed; inset: 0; z-index: 300; display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: rgba(2,5,12,.72);
  backdrop-filter: blur(4px); animation: modal-in .18s ease-out; }
@keyframes modal-in { from { opacity: 0 } to { opacity: 1 } }
.settings-panel { width: min(92vw, 480px); max-height: 86vh; overflow: auto;
  background: linear-gradient(#101c33f5, #0d1526f8); border: 2px solid #00e5ff;
  border-radius: 16px; padding: 26px 30px; color: #e8f4ff; box-shadow: 0 0 40px #00e5ff33; }
.settings-panel h3 { color: #00e5ff; letter-spacing: 5px; text-align: center;
  margin-bottom: 18px; text-shadow: 2px 0 #ff3d81; }
.settings-row { display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 9px 0; font-size: 16px; border-bottom: 1px solid #1d2b45; }
.settings-row:last-of-type { border-bottom: none; }
.settings-row em { font-style: normal; color: #7fd8ef; font-size: 14px; min-width: 56px; text-align: right; }
.settings-row input[type="range"] { accent-color: #00e5ff; width: 170px; cursor: pointer; }
.settings-row label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.settings-row input[type="checkbox"] { accent-color: #ff3d81; width: 17px; height: 17px; cursor: pointer; }
.settings-panel hr { border: none; border-top: 1px dashed #33415c; margin: 12px 0; width: 100%; }
.modal-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 20px; }
.modal-buttons .primary { border-color: #ff3d81; color: #ffb3cd; }
.modal-buttons .primary:hover { box-shadow: 0 0 16px #ff3d81aa; }
.gallery-entry { display: flex; flex-direction: column; gap: 2px; padding: 10px 4px;
  border-bottom: 1px solid #1d2b45; }
.gallery-entry b { color: #ffd98a; }
.gallery-entry b.locked { color: #44506b; }
.gallery-entry span { font-size: 13px; color: #9db4d8; }

/* Stage */
#stage { position: absolute; inset: 0; }
#bg-layer { position: absolute; inset: 0; background-size: cover; background-position: center; transition: filter .3s; }
#sprite-layer { position: absolute; inset: 0; pointer-events: none; }
.sprite { position: absolute; bottom: 15%; height: 78%; transition: opacity .3s, transform .3s; z-index: 5; }
.sprite img { height: 100%; filter: drop-shadow(0 8px 14px rgba(0,0,0,.7)); }
.sprite.pos-left { left: 8%; }
.sprite.pos-center { left: 50%; transform: translateX(-50%); }
.sprite.pos-right { right: 8%; }

/* Dialogue */
#dialogue { position: absolute; left: 50%; bottom: 3vh; transform: translateX(-50%);
  width: min(94vw, 900px); min-height: 150px; padding: 46px 28px 20px;
  background-color: rgba(13,21,38,.88); background-size: 100% 100%;
  background-image: url('../assets/images/ui/ui_textbox.png');
  border-radius: 14px; cursor: pointer; }
#nametag { position: absolute; top: -20px; left: 22px; padding: 8px 26px; font-weight: bold;
  font-size: 17px; letter-spacing: 2px; color: #ff9ec4;
  background-color: #0d1526; background-image: var(--nametag-img);
  background-size: 100% 100%; border-radius: 12px; text-shadow: 0 0 8px #000; }
#nametag.empty { visibility: hidden; }
#dialogue-text { font-size: clamp(15px, 2.2vw, 21px); line-height: 1.55; white-space: pre-wrap; min-height: 66px; }
#choices { position: absolute; left: 0; right: 0; bottom: calc(100% + 18px);
  display: flex; flex-direction: column; gap: 10px; align-items: center; }
#choices button { width: min(92%, 560px); text-align: left; }
#click-catch { position: absolute; inset: 0; z-index: -1; }

/* Meters */
#meters { position: absolute; top: 10px; right: 10px; font-size: 13px; background: #0d1526cc;
  padding: 8px 14px; border-radius: 8px; border: 1px solid #33415c; z-index: 40; }

/* FX */
.shake { animation: shake .35s; }
@keyframes shake { 0%,100%{transform:none} 20%{transform:translate(-9px,4px)} 40%{transform:translate(8px,-5px)}
  60%{transform:translate(-6px,3px)} 80%{transform:translate(5px,-2px)} }
.glitching #bg-layer { animation: gl .25s steps(2) infinite; }
@keyframes gl { 0%{filter:none} 50%{filter:hue-rotate(160deg) contrast(1.7) saturate(1.6); transform:translateX(8px);} 100%{filter:none} }
#jumpscare-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 50; }

/* Ending */
#ending-card { position: absolute; inset: 0; z-index: 60; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; padding-bottom: 12vh; gap: 18px;
  background: linear-gradient(transparent 30%, rgba(0,0,8,.85)); }
#ending-card h2 { font-size: clamp(26px, 5vw, 52px); letter-spacing: 4px; color: #00e5ff;
  text-shadow: 3px 0 #ff3d81, -3px 0 #ffffff33; }
#ending-card p { max-width: 640px; text-align: center; font-size: clamp(15px, 2vw, 19px);
  background: rgba(13,21,38,.75); padding: 12px 20px; border-radius: 10px; }
#ending-card button { font-family: inherit; cursor: pointer; color: #e8f4ff; font-size: 16px;
  background: rgba(13,21,38,.92); border: 2px solid #ff3d81; border-radius: 10px; padding: 12px 30px; }

@media (max-width: 600px) {
  .sprite { height: 62%; bottom: 28%; }
  #dialogue { min-height: 120px; padding: 40px 16px 14px; }
}
