:root {
  --bg-primary: #000000;
  --surface: #101010;
  --surface-strong: #181818;
  --text-primary: #ffffff;
  --text-secondary: #dddddd;
  --text-muted: #aaaaaa;
  --border: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 600px;
  height: 600px;
  margin: 0;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

#app,
.screen {
  position: relative;
  width: 600px;
  height: 600px;
}

.screen {
  padding: 8px;
}

.hud {
  position: absolute;
  z-index: 10;
  top: 8px;
  left: 8px;
  right: 8px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px;
  background: transparent;
}

.hud h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: 0;
}

.hud p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.2;
}

.text-panel {
  position: absolute;
  z-index: 5;
  top: 76px;
  left: 24px;
  right: 24px;
  height: 72px;
  border: 3px solid var(--border);
  background: var(--surface);
}

.view-tabs {
  position: absolute;
  z-index: 5;
  left: 24px;
  right: 24px;
  top: 164px;
  display: flex;
  justify-content: space-between;
  gap: 0;
}

.view-button {
  width: 118px;
  height: 42px;
  padding: 0;
  position: relative;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 17px;
  font-weight: 800;
  transform: scale(1);
  transition: transform 100ms ease, background-color 100ms ease, color 100ms ease;
}

.view-button::before {
  content: "";
  position: absolute;
  inset: 4px;
  z-index: -1;
  border: 3px solid var(--border);
  background: var(--bg-primary);
}

.action-button {
  width: 132px;
}

.view-button.active::before {
  background: var(--surface);
}

.typed-output {
  width: 100%;
  height: 100%;
  padding: 14px 16px;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 29px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.typed-output::after {
  content: "|";
  display: inline-block;
  margin-left: 3px;
  animation: blink 900ms steps(1, end) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.keyboard {
  position: absolute;
  z-index: 5;
  left: 24px;
  right: 24px;
  top: 224px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.key-row {
  display: flex;
  justify-content: center;
  gap: 0;
}

.key {
  width: 55px;
  height: 54px;
  padding: 0;
  position: relative;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 21px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  transform: scale(1);
  transition: transform 100ms ease, background-color 100ms ease, color 100ms ease;
}

.key::before {
  content: "";
  position: absolute;
  inset: 4px;
  z-index: -1;
  border: 3px solid var(--border);
  background: var(--bg-primary);
}

.key-wide {
  width: 104px;
  font-size: 18px;
}

.key-space {
  width: 328px;
}

.key:hover,
.key.targeted,
.view-button:hover,
.view-button.targeted {
  color: var(--bg-primary);
  transform: scale(1.14);
  z-index: 6;
}

.key:hover::before,
.key.targeted::before,
.view-button:hover::before,
.view-button.targeted::before {
  background: var(--text-primary);
}

.key:active,
.key.pressed,
.view-button:active,
.view-button.pressed {
  transform: scale(0.88);
}

#cursor {
  position: absolute;
  z-index: 30;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  border: 4px solid var(--border);
  background: transparent;
  pointer-events: none;
  transform: translate3d(var(--cursor-x, 284px), var(--cursor-y, 284px), 0);
  will-change: transform;
}

.calibrating .hud,
.calibrating .text-panel,
.calibrating .view-tabs,
.calibrating .keyboard,
.calibrating .readout,
.calibrating .version {
  opacity: 0.18;
}

.calibration-overlay {
  position: absolute;
  z-index: 25;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  color: var(--text-primary);
  text-align: center;
  pointer-events: none;
}

.calibration-overlay.hidden {
  display: none;
}

.calibration-title {
  position: absolute;
  top: 188px;
  left: 0;
  right: 0;
  font-size: 48px;
  font-weight: 900;
  line-height: 1;
}

.calibration-subtitle {
  position: absolute;
  top: 362px;
  left: 0;
  right: 0;
  font-size: 25px;
  font-weight: 700;
  color: var(--text-secondary);
}

.calibration-count {
  position: absolute;
  top: 404px;
  left: 0;
  right: 0;
  font-size: 82px;
  font-weight: 900;
  line-height: 1;
}

#cursor span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  margin-top: -4px;
  background: var(--border);
}

#cursor.recalibrating {
  animation: recalibrate-cursor 3000ms linear forwards;
}

@keyframes recalibrate-cursor {
  0% {
    transform: translate3d(var(--cursor-x, 284px), var(--cursor-y, 284px), 0) scale(3.1);
  }
  100% {
    transform: translate3d(var(--cursor-x, 284px), var(--cursor-y, 284px), 0) scale(1);
  }
}

.readout {
  position: absolute;
  z-index: 10;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
}

.readout span {
  white-space: nowrap;
}

#sensitivity {
  color: var(--text-primary);
  font-weight: 800;
}

.version {
  position: absolute;
  z-index: 11;
  right: 18px;
  bottom: 48px;
  min-width: 42px;
  padding: 5px 8px;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 88px;
  max-width: 536px;
  padding: 12px 20px;
  border: 0;
  background: var(--surface-strong);
  color: var(--text-primary);
  font-size: 14px;
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  transition: opacity 120ms ease, transform 120ms ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
