html,
body {
  height: 100%;
  margin: 0;
  background: #0d0f12;
  color: #cdd6f4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu,
    "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0d0f12 0%, #1a1d24 100%);
}

canvas {
  display: block;
  cursor: grab;
}

canvas:active {
  cursor: grabbing;
}

/* 移动端优化 */
@media (max-width: 768px) {
  body {
    font-size: 14px;
  }

  #app {
    touch-action: none;
  }
}

/* Terminal Modal */
.terminal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
}

.terminal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.terminal-window {
  width: 800px;
  height: 600px;
  max-width: 95vw;
  max-height: 90vh;
  background: #111;
  border-radius: 4px;
  padding: 0; /* Remove padding to let iframe fill the window */
  box-shadow: 0 0 0 2px #333, 0 0 20px rgba(0, 0, 0, 0.8),
    0 20px 50px rgba(0, 0, 0, 0.5);
  position: relative;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden; /* Ensure iframe doesn't overflow rounded corners */
}

.terminal-overlay.visible .terminal-window {
  transform: scale(1);
}

.terminal-screen {
  flex: 1;
  background: #0a0a0a;
  border-radius: 4px;
  padding: 20px;
  font-family: "Courier New", Courier, monospace;
  font-size: 18px;
  line-height: 1.4;
  color: #00ff66;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  text-shadow: 0 0 2px rgba(0, 255, 102, 0.5);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
}

/* CRT Scanline Effect */
.terminal-screen::before {
  content: " ";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
  background-size: 100% 4px;
  z-index: 2;
  pointer-events: none;
}

/* CRT Flicker Animation */
@keyframes flicker {
  0% {
    opacity: 0.97;
  }
  5% {
    opacity: 0.95;
  }
  10% {
    opacity: 0.9;
  }
  15% {
    opacity: 0.95;
  }
  20% {
    opacity: 0.99;
  }
  25% {
    opacity: 0.95;
  }
  30% {
    opacity: 0.9;
  }
  35% {
    opacity: 0.96;
  }
  40% {
    opacity: 0.98;
  }
  45% {
    opacity: 0.95;
  }
  50% {
    opacity: 0.99;
  }
  55% {
    opacity: 0.93;
  }
  60% {
    opacity: 0.9;
  }
  65% {
    opacity: 0.96;
  }
  70% {
    opacity: 1;
  }
  75% {
    opacity: 0.97;
  }
  80% {
    opacity: 0.95;
  }
  85% {
    opacity: 0.92;
  }
  90% {
    opacity: 0.98;
  }
  95% {
    opacity: 0.95;
  }
  100% {
    opacity: 0.98;
  }
}

.terminal-content {
  position: relative;
  z-index: 1;
  white-space: pre-wrap;
  word-break: break-all;
  animation: flicker 0.15s infinite;
}

.terminal-cursor {
  display: inline-block;
  width: 10px;
  height: 1.2em;
  background: #00ff66;
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

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

.terminal-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: pointer;
  z-index: 20;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.terminal-close-btn::before,
.terminal-close-btn::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 2px;
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 1px;
  transition: background-color 0.2s;
}

.terminal-close-btn::before {
  transform: rotate(45deg);
}

.terminal-close-btn::after {
  transform: rotate(-45deg);
}

.terminal-close-btn:hover {
  background: #ff5f56;
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(255, 95, 86, 0.4);
}

.terminal-close-btn:hover::before,
.terminal-close-btn:hover::after {
  background-color: #fff;
}
