* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #9cc7e6;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: #fff;
  user-select: none;
}
#scene-container, #scene-container canvas { position: fixed; inset: 0; display: block; }

#underwater {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(40, 110, 120, 0.35), rgba(10, 50, 60, 0.75));
  opacity: 0; transition: opacity 0.15s;
}
#underwater.on { opacity: 1; }

#hud { position: fixed; inset: 0; pointer-events: none; }
.hidden { display: none !important; }

#stats {
  position: absolute; top: 12px; left: 12px;
  background: rgba(20, 28, 24, 0.6); border-radius: 10px; padding: 8px 12px; min-width: 150px;
  backdrop-filter: blur(4px);
}
.stat-row { display: flex; justify-content: space-between; gap: 16px; font-size: 15px; line-height: 1.6; }
.stat-label { opacity: 0.85; }

#place {
  position: absolute; top: 12px; right: 12px; max-width: 300px; text-align: right;
  background: rgba(20, 28, 24, 0.6); border-radius: 10px; padding: 8px 12px;
  backdrop-filter: blur(4px);
}
#place-name { font-weight: 700; font-size: 16px; }
#place-hint { font-size: 12px; opacity: 0.85; margin-top: 2px; }
#place-water { font-size: 12px; margin-top: 4px; color: #a6e3ff; }

#crosshair {
  position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px;
  border-radius: 50%; background: rgba(255, 255, 255, 0.85); box-shadow: 0 0 3px #000;
}
#crosshair.active { width: 14px; height: 14px; margin: -7px 0 0 -7px; background: none; border: 2px solid #ffe27a; }
#aim-label {
  position: absolute; left: 50%; top: calc(50% + 18px); transform: translateX(-50%);
  font-size: 14px; text-shadow: 0 1px 3px #000; white-space: nowrap;
}

#toast {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%);
  font-size: 15px; text-shadow: 0 1px 3px #000; opacity: 0; transition: opacity 0.4s;
}
#toast.show { opacity: 1; }

#found-card {
  position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px));
  background: rgba(18, 22, 20, 0.85); border-radius: 14px; padding: 12px 16px;
  border: 2px solid var(--tier, #888); text-align: center;
  animation: pop 0.25s ease-out;
}
@keyframes pop { from { transform: translateX(-50%) scale(0.85); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
#found-tier { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--tier, #ccc); font-weight: 700; }
#found-name { font-size: 22px; font-weight: 800; margin: 2px 0; }
#found-new { display: inline-block; font-size: 11px; font-weight: 800; background: #ffcf3a; color: #222; border-radius: 6px; padding: 1px 6px; }
#found-fact { font-size: 13px; opacity: 0.9; margin-top: 6px; line-height: 1.4; }
#found-points { font-size: 13px; margin-top: 6px; color: #ffe27a; }

#controls-hint {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  font-size: 12px; opacity: 0.75; text-shadow: 0 1px 2px #000; white-space: nowrap;
}

.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 20, 16, 0.55); padding: 16px;
}
.panel {
  background: rgba(24, 32, 28, 0.95); border-radius: 16px; padding: 22px 26px;
  max-width: 560px; width: 100%; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  max-height: calc(100vh - 32px); overflow: auto;
}
.panel.wide { max-width: 900px; }
.panel h1 { margin: 0 0 4px; font-size: 32px; }
.panel h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; color: #a6e3ff; }
.panel p { line-height: 1.5; font-size: 15px; }
.panel .small { font-size: 13px; opacity: 0.75; }
#play-btn {
  font-size: 18px; font-weight: 700; padding: 12px 28px; border-radius: 10px; border: none; cursor: pointer;
  background: #ffcf3a; color: #2a2108; margin: 6px 0;
}
#play-btn:hover { background: #ffd95e; }

#journal-head { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 800; margin-bottom: 12px; }
#journal-summary { flex: 1; font-size: 14px; font-weight: 500; opacity: 0.8; }
#journal-close { background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; }
#journal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.jcard {
  border-radius: 10px; padding: 10px; background: rgba(255, 255, 255, 0.05);
  border-left: 4px solid var(--tier, #888);
}
.jcard .swatch { width: 28px; height: 28px; border-radius: 50%; float: right; border: 2px solid rgba(255, 255, 255, 0.25); }
.jcard .jtier { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--tier); font-weight: 700; }
.jcard .jname { font-weight: 700; font-size: 15px; }
.jcard .jcount { font-size: 12px; opacity: 0.75; }
.jcard .jfact { font-size: 12px; opacity: 0.85; margin-top: 6px; line-height: 1.35; clear: both; }
.jcard.unknown .jname { opacity: 0.5; }

@media (max-width: 600px) {
  #controls-hint { display: none; }
  #place { max-width: 180px; }
}
