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

body {
  font-family: 'Courier New', monospace;
  background-color: #000;
  color: #0ff;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

button {
  font: inherit;
}

/* Login Screen */
#login-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #0a1a1a 0%, #000 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
}

#login-window {
  width: min(600px, calc(100vw - 32px));
  background: #000080;
  border: 4px solid #0ff;
  box-shadow: 0 0 40px rgba(0, 255, 255, 0.8);
}

#login-title {
  background: #0a4a4a;
  color: #0ff;
  padding: 16px;
  font-weight: bold;
  border-bottom: 3px solid #0ff;
  text-align: center;
  font-size: 18px;
  text-transform: uppercase;
}

#login-content {
  padding: 40px;
  text-align: center;
}

#login-logo {
  margin-bottom: 30px;
}

#login-logo pre {
  display: inline-block;
  text-align: left;
  color: #ff6b9d;
  font-size: 24px;
  line-height: 1.2;
  font-weight: bold;
  text-shadow: 0 0 12px rgba(255, 107, 157, 0.6);
}

#login-window.shake {
  animation: shake 0.4s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}

#login-hint {
  margin-top: 20px;
  padding: 10px;
  border: 1px dashed #ff6b9d;
  color: #ff6b9d;
  font-weight: bold;
  letter-spacing: 1px;
}

#login-form {
  margin-top: 30px;
}

#login-form label {
  display: block;
  color: #0ff;
  font-size: 16px;
  margin-bottom: 12px;
  font-weight: bold;
  letter-spacing: 1px;
}

#password-input {
  width: 100%;
  padding: 12px;
  background: #000;
  border: 3px solid #0ff;
  color: #0ff;
  font-family: 'Courier New', monospace;
  font-size: 16px;
  margin-bottom: 20px;
  text-align: center;
  letter-spacing: 2px;
}

#password-input:focus {
  outline: none;
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.6);
}

#login-form button {
  background: #0a4a4a;
  border: 3px solid #0ff;
  color: #0ff;
  padding: 14px 30px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  cursor: pointer;
  margin: 5px;
  font-weight: bold;
  letter-spacing: 1px;
  transition: all 0.3s;
}

#login-form button:hover,
#login-form button:focus-visible {
  background: #0ff;
  color: #000;
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.8);
  outline: none;
}

#login-form button:disabled {
  opacity: 0.6;
  cursor: wait;
}

#login-error {
  margin-top: 20px;
  color: #f00;
  font-weight: bold;
  font-size: 16px;
  animation: pulse 1s infinite;
  letter-spacing: 2px;
}

#main-app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Header styling - SGI look */
#header {
  flex: none;
  background: linear-gradient(180deg, #d4d4d4 0%, #a8a8a8 100%);
  border-bottom: 2px solid #666;
}

#menu-bar {
  background: #c0c0c0;
  padding: 4px 8px;
  font-size: 14px;
  color: #000;
  border-bottom: 1px solid #808080;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.menu-item {
  padding: 2px 12px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: inline-block;
  background: none;
  border: none;
  font-size: 14px;
}

.menu-item.inert {
  cursor: default;
}

.menu-right {
  margin-left: auto;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: #fff;
  outline: none;
}

#title-bar {
  background: #b0b0b0;
  padding: 6px 12px;
  font-weight: bold;
  color: #000;
  font-size: 13px;
}

#path-bar {
  background: #fff;
  padding: 4px 8px;
  color: #000;
  font-size: 12px;
  border: 1px inset #999;
  margin: 4px;
  min-height: 24px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.path-segment {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: #000080;
  text-decoration: underline;
  cursor: pointer;
}

.path-segment:disabled {
  color: inherit;
  text-decoration: none;
  cursor: default;
}

.path-current {
  font-weight: bold;
}

#info-bar {
  background: #b0b0b0;
  padding: 4px 8px;
  color: #000;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

#info-listing {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#alert-status {
  flex: none;
  font-weight: bold;
  color: #b00000;
  animation: pulse 1.5s infinite;
}

#alert-status.clear {
  color: #006000;
  animation: none;
}

/* 3D Scene Container */
#scene-container {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, #0a4a4a 0%, #000 50%);
  touch-action: manipulation;
}

#scene-container canvas {
  display: block;
}

/* HUD overlay */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

#hud-up {
  position: absolute;
  top: 12px;
  left: 12px;
  pointer-events: auto;
  background: rgba(0, 0, 128, 0.85);
  border: 2px solid #0ff;
  color: #0ff;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
}

#hud-up:hover,
#hud-up:focus-visible {
  background: #0ff;
  color: #000;
  outline: none;
}

#hud-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(0, 255, 255, 0.35);
  color: rgba(0, 255, 255, 0.85);
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#hud-hint.error-text {
  white-space: normal;
  color: #f66;
  border-color: #f00;
}

/* Hover label for file nodes */
#hover-label {
  position: fixed;
  padding: 8px 12px;
  background-color: rgba(0, 0, 128, 0.92);
  color: #0ff;
  font-size: 14px;
  border: 1px solid #0ff;
  pointer-events: none;
  z-index: 900;
  white-space: nowrap;
}

#hover-label.alert {
  border-color: #f00;
  box-shadow: 0 0 12px rgba(255, 0, 0, 0.6);
}

#hover-label.cleared {
  border-color: #0f0;
}

.hover-name {
  display: block;
  font-weight: bold;
}

.hover-meta {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  opacity: 0.75;
}

#hover-label.alert .hover-meta {
  color: #f66;
  opacity: 1;
}

#hover-label.cleared .hover-meta {
  color: #0f0;
  opacity: 1;
}

/* Bottom Panel */
#bottom-panel {
  flex: none;
  height: 100px;
  background: #000;
  border-top: 2px solid #0ff;
  display: flex;
  align-items: center;
  justify-content: center;
}

#mini-map {
  width: 90%;
  height: 80px;
  border: 1px solid #0ff;
  background: #001a1a;
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 4px;
  padding: 4px;
}

.map-island {
  position: relative;
  min-width: 0;
  background: rgba(255, 107, 157, 0.18);
  border: 1px solid rgba(255, 107, 157, 0.7);
  color: #ffc2d8;
  font-size: 11px;
  cursor: pointer;
  padding: 0 6px;
  transition: background 0.2s, box-shadow 0.2s;
}

.map-island-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-island:hover,
.map-island:focus-visible {
  background: rgba(255, 107, 157, 0.4);
  outline: none;
}

.map-island.current {
  background: rgba(0, 255, 255, 0.25);
  border-color: #0ff;
  color: #fff;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.6) inset;
}

.map-island.secured::after {
  content: '\2713';
  position: absolute;
  top: 1px;
  right: 4px;
  color: #0f0;
  font-weight: bold;
}

/* Terminal Modal */
#terminal-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#terminal-window {
  width: min(700px, calc(100vw - 32px));
  background: #000080;
  border: 3px solid #c0c0c0;
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

#terminal-title {
  background: #000080;
  color: #fff;
  padding: 8px;
  font-weight: bold;
  border-bottom: 2px solid #0ff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#terminal-close {
  background: #c0c0c0;
  border: 2px outset #fff;
  color: #000;
  width: 24px;
  height: 22px;
  line-height: 1;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
}

#terminal-close:active {
  border-style: inset;
}

#terminal-content {
  background: #000080;
  color: #0ff;
  padding: 20px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  min-height: min(400px, 60vh);
  max-height: min(500px, 70vh);
  overflow-y: auto;
  line-height: 1.6;
}

#hack-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px 12px;
  background: #000080;
  color: #0f0;
  font-size: 13px;
  font-weight: bold;
  border-top: 1px solid rgba(0, 255, 255, 0.4);
}

#hack-progress-track {
  flex: 1;
  height: 12px;
  border: 1px solid #0f0;
  background: #000040;
}

#hack-progress-fill {
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(90deg, #0f0 0 8px, #0a0 8px 10px);
}

#hack-progress-pct {
  min-width: 4ch;
  text-align: right;
}

.terminal-line {
  margin: 4px 0;
}

.terminal-line:empty {
  min-height: 0.8em;
}

.terminal-prompt {
  color: #fff;
}

.terminal-input {
  background: transparent;
  border: none;
  color: #0ff;
  font-family: inherit;
  font-size: inherit;
  outline: none;
  width: calc(100% - 20px);
}

.terminal-cursor {
  animation: blink 1s infinite;
  background: #0ff;
  display: inline-block;
  width: 8px;
  height: 14px;
  margin-left: 2px;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}


/* Help Modal */
#help-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500;
}

#help-window {
  width: min(700px, calc(100vw - 32px));
  max-height: 90vh;
  background: #1a1a1a;
  border: 3px solid #0ff;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.7);
  overflow-y: auto;
}

#help-title {
  background: #0a4a4a;
  color: #0ff;
  padding: 12px;
  font-weight: bold;
  border-bottom: 2px solid #0ff;
  position: sticky;
  top: 0;
  z-index: 1;
}

#help-content {
  padding: 30px;
  color: #0ff;
  line-height: 1.8;
}

#help-content h3 {
  color: #0ff;
  margin-top: 20px;
  margin-bottom: 12px;
  font-size: 16px;
  border-bottom: 1px solid #0a4a4a;
  padding-bottom: 6px;
}

#help-content h3:first-child {
  margin-top: 0;
}

#help-content p {
  margin: 8px 0;
  font-size: 14px;
}

#help-content strong {
  color: #fff;
}

#help-content button {
  margin-top: 30px;
  background: #0a4a4a;
  border: 2px solid #0ff;
  color: #0ff;
  padding: 12px 30px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  cursor: pointer;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

#help-content button:hover,
#help-content button:focus-visible {
  background: #0ff;
  color: #000;
  outline: none;
}

/* Victory Modal */
#victory-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

#victory-window {
  width: min(600px, calc(100vw - 32px));
  background: #000080;
  border: 4px solid #f00;
  box-shadow: 0 0 40px rgba(255, 0, 0, 0.8);
}

#victory-title {
  background: #000080;
  color: #f00;
  padding: 12px;
  font-weight: bold;
  border-bottom: 3px solid #f00;
  text-align: center;
  font-size: 16px;
}

#victory-content {
  padding: 40px;
  text-align: center;
  color: #0ff;
}

#victory-content h2 {
  color: #f00;
  font-size: 32px;
  margin-bottom: 20px;
  animation: pulse 1s infinite;
}

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

#victory-content p {
  margin: 15px 0;
  font-size: 16px;
}

#victory-content button {
  margin-top: 30px;
  background: #0a4a4a;
  border: 2px solid #0ff;
  color: #0ff;
  padding: 15px 40px;
  font-family: 'Courier New', monospace;
  font-size: 16px;
  cursor: pointer;
}

#victory-content button:hover {
  background: #0ff;
  color: #000;
}

/* Polling text animation */
.polling-text {
  color: #ff0;
  margin-top: 20px;
  animation: pulse 1.5s infinite;
}

.dots::after {
  content: '...';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* Chat Modal */
#chat-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
}

#chat-window {
  width: min(800px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 32px));
  background: #000;
  border: 3px solid #0ff;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.7);
  display: flex;
  flex-direction: column;
}

#chat-title {
  background: #0a4a4a;
  color: #0ff;
  padding: 12px;
  font-weight: bold;
  border-bottom: 2px solid #0ff;
  font-size: 14px;
}

#chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #000;
  color: #0ff;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
}

.chat-message {
  margin: 10px 0;
  padding: 8px 0;
}

.chat-message.anonymous {
  color: #ff0;
}

.chat-message.user {
  color: #0ff;
}

.chat-sender {
  font-weight: bold;
  margin-right: 8px;
}

#chat-input-area {
  padding: 15px;
  background: #0a1a1a;
  border-top: 2px solid #0ff;
  display: flex;
  align-items: center;
}

.chat-prompt {
  color: #0ff;
  font-weight: bold;
  margin-right: 10px;
}

#chat-input {
  flex: 1;
  background: #000;
  border: 2px solid #0ff;
  color: #0ff;
  padding: 8px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
}

#chat-input:focus {
  outline: none;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

/* Lockdown Modal */
#lockdown-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.98);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
}

#lockdown-window {
  width: min(700px, calc(100vw - 32px));
  background: #000;
  border: 4px solid #f00;
  box-shadow: 0 0 50px rgba(255, 0, 0, 0.9);
}

#lockdown-title {
  background: #000;
  color: #f00;
  padding: 12px;
  font-weight: bold;
  border-bottom: 3px solid #f00;
  text-align: center;
  font-size: 18px;
  animation: pulse 1s infinite;
}

#lockdown-content {
  padding: 50px;
  text-align: center;
  color: #0ff;
  background: #000;
}

.lockdown-message h2 {
  color: #0ff;
  font-size: 28px;
  margin-bottom: 30px;
}

.lockdown-message p {
  font-size: 16px;
  margin: 20px 0;
  color: #0ff;
}

.lockdown-spinner {
  margin: 40px 0;
  font-size: 14px;
}

.spinner-line {
  color: #f00;
  margin: 5px 0;
  animation: pulse 1.5s infinite;
}

.lockdown-status {
  color: #f00;
  font-size: 24px;
  font-weight: bold;
  margin-top: 40px;
  animation: pulse 1s infinite;
}

/* Hidden class */
.hidden {
  display: none !important;
}

/* Error/Warning text */
.error-text {
  color: #f00;
}

.warning-text {
  color: #ff0;
}

.success-text {
  color: #0f0;
}

@media (max-width: 640px) {
  #login-content,
  #victory-content,
  #lockdown-content {
    padding: 24px 16px;
  }

  #login-logo pre {
    font-size: 16px;
  }

  #hud-hint {
    white-space: normal;
  }

  #bottom-panel {
    height: 84px;
  }

  #mini-map {
    width: calc(100% - 16px);
    height: 70px;
  }
}

@media (max-height: 560px) {
  #bottom-panel {
    height: 52px;
  }

  #mini-map {
    height: 44px;
    gap: 2px;
    padding: 2px;
  }

  .map-island {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
