*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #0b0c10;
  color: #c5c6c7;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* Self-hosted terminal font - WOFF2 for better mobile support */
@font-face {
  font-family: 'CascadiaMono';
  src: url('../fonts/CascadiaMono-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

/* Also register with quoted name for compatibility */
@font-face {
  font-family: "Cascadia Mono";
  src: url('../fonts/CascadiaMono-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  align-items: center;
  justify-content: center;
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  justify-content: center;
}

header h1 {
  margin: 0;
  font-size: 20px;
  color: #66fcf1;
}

header p {
  margin: 4px 0 0;
  color: #9da1a3;
  font-size: 13px;
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

button {
  background: #45a29e;
  color: #0b0c10;
  border: none;
  border-radius: 4px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

button:hover {
  background: #66fcf1;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

main {
  background: #0d1117;
  border: 1px solid #1f2833;
  border-radius: 6px;
  padding: 6px;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#terminal {
  display: inline-block;
  width: auto;
  height: auto;
  min-width: 80ch;
  overflow: hidden;
}

.mobile-input-hidden {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  height: 1px;
  width: 1px;
  border: 0;
  padding: 0;
  margin: 0;
}

.terminal {
  width: auto;
  height: auto;
  min-height: 0;
  min-width: 80ch;
  overflow: hidden;
  font-family: "Courier New", Courier, monospace;
  -webkit-text-size-adjust: 100%;
  font-variant-ligatures: none;
  letter-spacing: 0;
  text-rendering: optimizeSpeed;
}

/* Dark themed scrollbar - target all possible scrolling containers */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: #0b0c10;
}
::-webkit-scrollbar-thumb {
  background: #3a3f4a;
  border-radius: 6px;
  border: 2px solid #0b0c10;
}
::-webkit-scrollbar-thumb:hover {
  background: #4c5361;
}

/* Firefox scrollbar styling */
* {
  scrollbar-color: #3a3f4a #0b0c10;
  scrollbar-width: thin;
}

/* Force consistent rendering on mobile - prevent subpixel issues */
x-screen,
x-screen * {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
  font-variant-ligatures: none;
  font-feature-settings: normal;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  letter-spacing: 0 !important;
  word-spacing: 0 !important;
  white-space: pre !important;
}

/* Ensure hterm rows don't have fractional heights or widths */
x-row {
  height: auto !important;
  line-height: 1 !important;
  display: block;
  margin: 0;
  padding: 0;
  letter-spacing: 0 !important;
  word-spacing: 0 !important;
  white-space: pre !important;
  transform: translateZ(0);
  will-change: auto;
}

/* Force x-screen to use exact integer pixel measurements */
x-screen {
  line-height: 1;
  font-size-adjust: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  transform: translateZ(0);
}

/* Target the actual text spans within rows */
x-row > span {
  letter-spacing: 0 !important;
  word-spacing: 0 !important;
  white-space: pre !important;
  display: inline;
  font-kerning: none;
  -webkit-font-kerning: none;
}

/* Mobile-specific fixes for character alignment */
@media (max-width: 1023px) {
  x-screen,
  x-screen *,
  x-row,
  x-row * {
    text-rendering: geometricPrecision !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  #terminal {
    width: auto !important;
    max-width: 100%;
    overflow-x: auto;
  }
}

footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #9da1a3;
}

.hint {
  color: #6bb8ff;
}

.xterm {
  padding: 6px;
  border-radius: 4px;
}

/* hterm blink support (SGR 5). */
.terminal .blink {
  animation: hterm-blink 1s steps(1, start) infinite;
}
@keyframes hterm-blink {
  0% { opacity: 1; }
  50% { opacity: 0; }
  100% { opacity: 1; }
}

/* Enable ANSI blink (SGR 5) if the terminal marks blinkable cells. */
.xterm .xterm-blink {
  animation: xterm-blink 1s steps(1, start) infinite;
}
@keyframes xterm-blink {
  0% { opacity: 1; }
  50% { opacity: 0; }
  100% { opacity: 1; }
}
