@font-face {
  font-family: "TeletextOTF";
  src: url("../fonts/font.otf") format("opentype");
  font-display: swap;
}

:root {
  --bg: #07080b;
  --panel: #0a0d12;
  --glass: rgba(255, 255, 255, 0.04);
  --glow: rgba(120, 220, 255, 0.12);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: radial-gradient(1200px 700px at 50% 35%, #101423 0%, var(--bg) 55%, #000 100%);
  color: #d7e7ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.crt-shell {
  position: relative;
  width: min(960px, 96vw);
  aspect-ratio: 4 / 3;
  background: linear-gradient(180deg, #0c1220 0%, #05070c 100%);
  border-radius: 22px;
  box-shadow:
    0 20px 70px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 0 120px rgba(90, 200, 250, 0.07);
  overflow: hidden;
  padding: 14px;
}

#crt {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 16px;
  background: #000;

  /* keep pixels crisp */
  image-rendering: pixelated;
  image-rendering: crisp-edges;

  /* CRT-ish “fizz” */
  filter:
    contrast(1.18)
    saturate(1.08)
    brightness(1.02)
    drop-shadow(0 0 18px var(--glow));

  outline: none;
}

.crt-overlay {
  position: absolute;
  inset: 14px;
  border-radius: 16px;
  pointer-events: none;
}

/* scanlines */
.scanlines {
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.00) 0px,
      rgba(0, 0, 0, 0.00) 2px,
      rgba(0, 0, 0, 0.10) 3px,
      rgba(0, 0, 0, 0.10) 4px
    );
  mix-blend-mode: multiply;
  opacity: 0.55;
}

/* subtle vignette */
.vignette {
  background: radial-gradient(closest-side at 50% 50%, rgba(0,0,0,0) 60%, rgba(0,0,0,0.45) 100%);
  opacity: 0.9;
}

/* glass sheen */
.glass {
  background:
    linear-gradient(120deg, rgba(255,255,255,0.05), rgba(255,255,255,0.00) 40%),
    radial-gradient(700px 240px at 50% 0%, rgba(255,255,255,0.06), rgba(255,255,255,0.00) 60%);
  opacity: 0.55;
}

.hint {
  margin-top: 18px;
  opacity: 0.65;
  font-size: 12px;
  letter-spacing: 0.02em;
}

/* Mobile on-screen keyboard */
.mobile-keyboard {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, rgba(10, 13, 18, 0.98) 0%, rgba(7, 8, 11, 0.98) 100%);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 8px 12px 8px;
  display: none;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.7);
}

.mobile-keyboard.active {
  display: flex;
}

.keyboard-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.keyboard-key {
  flex: 1;
  max-width: 46px;
  height: 44px;
  background: linear-gradient(180deg, #1a2233 0%, #0f1621 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #d7e7ff;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.keyboard-key:active {
  background: linear-gradient(180deg, #0f1621 0%, #1a2233 100%);
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.keyboard-key.wide {
  flex: 2;
  max-width: none;
}

.keyboard-key.space {
  flex: 4;
  max-width: none;
}

.keyboard-key.enter {
  background: linear-gradient(180deg, #0a84ff 0%, #0766cc 100%);
  border-color: rgba(10, 132, 255, 0.4);
}

.keyboard-key.enter:active {
  background: linear-gradient(180deg, #0766cc 0%, #0a84ff 100%);
}

.keyboard-key.backspace {
  background: linear-gradient(180deg, #cc3333 0%, #992222 100%);
  border-color: rgba(204, 51, 51, 0.4);
}

.keyboard-key.backspace:active {
  background: linear-gradient(180deg, #992222 0%, #cc3333 100%);
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
  .wrap {
    padding: 12px;
    padding-bottom: 0;
  }

  .crt-shell {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 12px;
    padding: 8px;
    box-shadow:
      0 8px 24px rgba(0, 0, 0, 0.6),
      0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  }

  .crt-overlay {
    inset: 8px;
    border-radius: 8px;
  }

  #crt {
    border-radius: 8px;
  }

  .hint {
    margin-top: 8px;
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  .wrap {
    padding: 8px;
    padding-bottom: 0;
  }

  .crt-shell {
    border-radius: 8px;
    padding: 6px;
  }

  .crt-overlay {
    inset: 6px;
    border-radius: 6px;
  }

  #crt {
    border-radius: 6px;
  }

  .keyboard-key {
    max-width: 38px;
    height: 38px;
    font-size: 14px;
  }
}

/* Landscape mobile adjustments */
@media (max-width: 900px) and (max-height: 500px) {
  .wrap {
    padding: 8px;
  }

  .crt-shell {
    width: auto;
    height: calc(100vh - 16px);
    aspect-ratio: 4 / 3;
  }
}
