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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d0c07;
  font-family: ui-monospace, 'SFMono-Regular', 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  text-transform: lowercase;
  color: #e8dfa8;
}

#screen {
  display: block;
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
}

#hud {
  position: fixed;
  top: 10px;
  left: 10px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#coords {
  font-size: 13px;
  text-shadow: 1px 1px 0 #000;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 8px;
  border: 1px solid rgba(232, 223, 168, 0.3);
  width: fit-content;
}

#level-name {
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 2px;
  color: #f2e37a;
  text-shadow: 2px 2px 0 #000;
  background: rgba(0, 0, 0, 0.45);
  padding: 5px 10px;
  border-left: 3px solid #f2e37a;
  width: fit-content;
}

#fragments {
  font-size: 14px;
  letter-spacing: 1px;
  color: #ffe08a;
  text-shadow: 1px 1px 0 #000;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 10px;
  border: 1px solid rgba(255, 224, 138, 0.35);
  width: fit-content;
}

#fragments.ready {
  color: #1a1806;
  background: #ffe08a;
  border-color: #fff6cc;
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* health */
#health {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.4);
  padding: 5px 10px;
  border: 1px solid rgba(232, 223, 168, 0.3);
  width: fit-content;
}

#health-bar {
  width: 130px;
  height: 10px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(232, 223, 168, 0.35);
}

#health-fill {
  height: 100%;
  width: 100%;
  background: #7ad46b;
  transition: width 0.18s linear, background 0.25s;
}

#health-fill.warn { background: #e0c04a; }
#health-fill.crit {
  background: #e04a4a;
  animation: pulse 0.65s ease-in-out infinite;
}

#health-num {
  font-size: 12px;
  letter-spacing: 1px;
  min-width: 30px;
}

#stamina {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 10px;
  border: 1px solid rgba(232, 223, 168, 0.3);
  width: fit-content;
}

#stamina-bar {
  width: 130px;
  height: 6px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(232, 223, 168, 0.3);
}

#stamina-fill {
  height: 100%;
  width: 100%;
  background: #6fb0e0;
  transition: width 0.1s linear, background 0.2s;
}

/* spent: you cannot start another sprint until it recovers */
#stamina-fill.spent { background: #8a5a5a; }

#stamina-label {
  font-size: 10px;
  letter-spacing: 2px;
  opacity: 0.45;
}

#stamina.active #stamina-label { opacity: 0.95; color: #9fd0f0; }

/* help */
#help-btn {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 15;
  width: 34px;
  height: 34px;
  font-family: inherit;
  font-size: 18px;
  font-weight: bold;
  color: #e8dfa8;
  background: rgba(0, 0, 0, 0.5);
  border: 1px dashed rgba(232, 223, 168, 0.4);
  cursor: pointer;
  transition: background 0.15s;
}

#help-btn:hover {
  background: rgba(232, 223, 168, 0.08);
  color: #e8dfa8;
}

#help {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 6, 3, 0.9);
  overflow-y: auto;
  padding: 24px;
}

#help.hidden { display: none; }

.help-panel {
  max-width: 640px;
  width: 100%;
  border: 1px solid rgba(232, 223, 168, 0.35);
  background: #14130a;
  padding: 26px 30px 30px;
}

.help-panel h2 {
  font-size: 26px;
  letter-spacing: 5px;
  color: #f2e37a;
  margin-bottom: 6px;
}

.help-panel h3 {
  font-size: 14px;
  letter-spacing: 2px;
  color: #f2e37a;
  margin: 20px 0 7px;
  border-bottom: 1px solid rgba(232, 223, 168, 0.2);
  padding-bottom: 4px;
}

.help-panel p { font-size: 13px; line-height: 1.6; opacity: 0.88; }
.help-panel b { color: #ffe08a; }

.help-panel table { width: 100%; border-collapse: collapse; font-size: 13px; }
.help-panel td { padding: 5px 10px 5px 0; vertical-align: top; line-height: 1.5; }
.help-panel td:first-child { white-space: nowrap; width: 1%; opacity: 0.95; }
.help-panel td:last-child { opacity: 0.82; }

.help-panel kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid rgba(232, 223, 168, 0.4);
  background: rgba(0, 0, 0, 0.4);
  font-size: 12px;
}

.c-harm { color: #b3a6d9; }
.c-chase { color: #ff8a5c; }
.c-term { color: #5cf0a8; }
.c-watch { color: #c98fd0; }

#help-close {
  margin-top: 24px;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 3px;
  padding: 10px 26px;
  background: transparent;
  color: #f2e37a;
  border: 1px dashed rgba(242, 227, 122, 0.55);
  cursor: pointer;
  font-weight: bold;
  transition: background 0.15s;
}

#help-close:hover {
  background: rgba(242, 227, 122, 0.08);
}

#enter-btn.secondary, .panel button.secondary {
  display: block;
  margin: 12px auto 0;
  background: transparent;
  color: #e8dfa8;
  border: 1px dashed rgba(232, 223, 168, 0.4);
  font-size: 13px;
  letter-spacing: 2px;
  padding: 9px 22px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.panel button.secondary:hover {
  background: rgba(232, 223, 168, 0.08);
}

/* blackout */
#blackout {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

#blackout.on { opacity: 1; }

#blackout span {
  font-size: 15px;
  letter-spacing: 4px;
  opacity: 0.7;
}

/* level transition card */
#descend {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 20;
  pointer-events: none;
  transition: opacity 0.45s ease;
}

#descend.hidden { opacity: 0; }

.descend-inner { text-align: center; }

#descend-level {
  font-size: 40px;
  font-weight: bold;
  letter-spacing: 7px;
  color: #f2e37a;
  text-shadow: 3px 3px 0 #000;
}

#descend-tag {
  margin-top: 14px;
  font-size: 15px;
  font-style: italic;
  opacity: 0.7;
}

#minimap {
  border: 1px solid rgba(232, 223, 168, 0.3);
  background: rgba(0, 0, 0, 0.5);
}

#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #030303;
  z-index: 10;
  overflow: hidden;
}

#overlay.hidden { display: none; }

#febu-ascii {
  display: inline-block;
  text-align: left;
  font-size: 22px;
  line-height: 1.3;
  color: #f2e37a;
  opacity: 0.6;
  margin: 0 0 40px;
  padding: 0;
  white-space: pre;
  letter-spacing: 2px;
}

@media (max-height: 580px) {
  #febu-ascii { font-size: 9px; line-height: 1.15; margin-bottom: 12px; }
}

@media (max-height: 420px) {
  #febu-ascii { display: none; }
}

.panel {
  text-align: center;
  padding: 40px;
  position: relative;
  z-index: 1;
}

.panel h1 {
  font-size: 28px;
  letter-spacing: 12px;
  color: #f2e37a;
  opacity: 0.7;
  margin-bottom: 8px;
  font-weight: normal;
}

.panel .tag {
  font-size: 13px;
  opacity: 0.3;
  margin-bottom: 50px;
  font-style: italic;
}

#enter-btn {
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 4px;
  padding: 12px 30px;
  background: transparent;
  color: #f2e37a;
  border: 1px dashed rgba(242, 227, 122, 0.25);
  cursor: pointer;
  font-weight: normal;
  transition: background 0.15s, border-color 0.15s;
}

#continue-btn {
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 2px;
  padding: 11px 26px;
  margin-bottom: 12px;
  background: transparent;
  color: #7ad46b;
  border: 1px dashed rgba(122, 212, 107, 0.55);
  cursor: pointer;
  font-weight: bold;
  display: block;
  width: 100%;
  transition: background 0.15s;
}

#continue-btn.hidden { display: none; }

#continue-btn:hover {
  background: rgba(122, 212, 107, 0.08);
}

#enter-btn:hover {
  background: rgba(242, 227, 122, 0.08);
}

.panel .hint {
  margin-top: 22px;
  font-size: 12px;
  opacity: 0.5;
}

.panel .hint.warn {
  margin-top: 8px;
  color: #f2b53a;
  opacity: 0.35;
}

#chat {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(3, 3, 3, 0.7);
  padding: 24px;
}

#chat.hidden { display: none; }

.chat-panel {
  max-width: 480px;
  width: 100%;
  border: 1px dashed rgba(92, 240, 168, 0.35);
  background: rgba(10, 18, 14, 0.95);
  padding: 16px 20px;
  margin-bottom: 40px;
}

.chat-header {
  font-size: 13px;
  letter-spacing: 3px;
  color: #5cf0a8;
  opacity: 0.7;
  margin-bottom: 12px;
  border-bottom: 1px dashed rgba(92, 240, 168, 0.2);
  padding-bottom: 8px;
}

#chat-messages {
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.6;
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: rgba(92, 240, 168, 0.2); }

.chat-msg {
  margin-bottom: 8px;
  padding: 4px 0;
}

.chat-msg.user {
  color: #e8dfa8;
  opacity: 0.8;
}

.chat-msg.user::before {
  content: '> ';
  opacity: 0.4;
}

.chat-msg.keeper {
  color: #5cf0a8;
  opacity: 0.9;
}

#chat-form {
  display: flex;
}

#chat-input {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.5);
  color: #e8dfa8;
  border: 1px dashed rgba(232, 223, 168, 0.3);
  outline: none;
}

#chat-input:focus {
  border-color: rgba(92, 240, 168, 0.5);
}

#chat-input::placeholder {
  color: rgba(232, 223, 168, 0.3);
}

.chat-hint {
  font-size: 11px;
  opacity: 0.3;
  margin-top: 8px;
  text-align: right;
}
