body {
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 6vh 20px;
  position: relative;
}

main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 86vh;
  height: 86dvh;
  max-height: 760px;
}

main.party-mode {
  animation: partyGlow 0.7s linear infinite;
}
@keyframes partyGlow {
  0%   { box-shadow: 0 0 40px 4px rgba(255, 60, 60, 0.55); }
  20%  { box-shadow: 0 0 40px 4px rgba(255, 170, 40, 0.55); }
  40%  { box-shadow: 0 0 40px 4px rgba(255, 240, 40, 0.55); }
  60%  { box-shadow: 0 0 40px 4px rgba(56, 189, 248, 0.55); }
  80%  { box-shadow: 0 0 40px 4px rgba(99, 102, 241, 0.55); }
  100% { box-shadow: 0 0 40px 4px rgba(236, 72, 153, 0.55); }
}

main.crashing {
  transition: transform 0.6s ease, opacity 0.6s ease;
  transform: scale(0.85);
  opacity: 0;
}

.crash-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #0b0f14;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.crash-screen.show { opacity: 1; pointer-events: auto; }
.crash-code {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
}
.crash-title {
  font-size: clamp(1.6rem, 7vw, 2.4rem);
  font-weight: 700;
  color: var(--err);
  letter-spacing: 0.04em;
}
.crash-btn {
  margin-top: 8px;
  padding: 10px 22px;
  border: 1px solid var(--err);
  border-radius: 6px;
  background: none;
  color: var(--err);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.crash-btn:hover { background: var(--err); color: #fff; }

.whiteout {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 3.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.whiteout.active { opacity: 1; pointer-events: auto; }
.whiteout-content {
  text-align: center;
  opacity: 0;
  transition: opacity 0.8s ease 2.6s;
}
.whiteout.active .whiteout-content { opacity: 1; }
.whiteout-title {
  font-size: clamp(1.3rem, 6vw, 2rem);
  font-weight: 700;
  color: #111;
  letter-spacing: 0.03em;
}
.whiteout-btn {
  margin-top: 16px;
  padding: 10px 22px;
  border: 1px solid #111;
  border-radius: 6px;
  background: none;
  color: #111;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.whiteout-btn:hover { background: #111; color: #fff; }

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.titlebar-dots {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  opacity: 0.85;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}
.dot:hover {
  transform: scale(1.2);
  opacity: 1;
}
.dot.r { background: #ff5f56; }
.dot.r:hover { box-shadow: 0 0 8px rgba(255, 95, 86, 0.8); }
.dot.y { background: #ffbd2e; }
.dot.y:hover { box-shadow: 0 0 8px rgba(255, 189, 46, 0.8); }
.dot.g { background: #27c93f; }
.dot.g:hover { box-shadow: 0 0 8px rgba(39, 201, 63, 0.8); }

.titlebar span.path {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.titlebar-action-btn {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.titlebar-action-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent);
}

main {
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease, max-width 0.3s ease, height 0.3s ease;
}

main.closed-view {
  transform: scale(0.9) translateY(40px);
  opacity: 0;
  pointer-events: none;
}

main.maximized-view {
  max-width: 95vw;
  height: 92vh;
  max-height: 92vh;
}

.restore-term-btn {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  background: rgba(11, 15, 20, 0.92);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 10px 22px;
  border-radius: 9999px;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.7), 0 0 20px rgba(56, 189, 248, 0.35);
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 32px);
  white-space: nowrap;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(12px);
  animation: restoreBounce 2s ease infinite alternate;
}
.restore-term-btn:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  transform: translateX(-50%) translateY(-3px) scale(1.04);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.8), 0 0 30px rgba(56, 189, 248, 0.6);
}
.restore-term-btn .prompt-icon {
  color: var(--accent);
  font-weight: 700;
}
.restore-term-btn .badge-key {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.75rem;
  color: #94a3b8;
}

/* No Esc key on touch devices */
@media (hover: none) and (pointer: coarse) {
  .restore-term-btn .badge-key { display: none; }
}

@keyframes restoreBounce {
  0% { transform: translateX(-50%) translateY(0); }
  100% { transform: translateX(-50%) translateY(-4px); }
}

.term {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px 22px 16px;
  cursor: text;
}

#output {
  flex: 1 1 auto;
  overflow-y: auto;
  font-size: 0.88rem;
  line-height: 1.65;
  padding-right: 4px;
}
#output::-webkit-scrollbar { width: 6px; }
#output::-webkit-scrollbar-thumb { background: var(--line-light); border-radius: 3px; }
#output::-webkit-scrollbar-track { background: transparent; }

.motd { color: var(--muted); margin-bottom: 14px; font-size: 0.86rem; }
.motd strong { color: var(--fg); }

.histline { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.histline .prompt { color: var(--accent); white-space: nowrap; font-weight: 600; }
.histline .cmdtext { color: var(--fg); word-break: break-all; }

.result { margin: 4px 0 2px 0; white-space: pre-wrap; word-break: break-word; }
.result.err { color: var(--err); }
.result.dim { color: var(--muted); }
.result a { color: var(--accent); text-decoration: underline; }
.result a:hover { color: #bae6fd; }

.kv { display: flex; gap: 10px; }
.kv .k { color: var(--accent); min-width: 92px; flex: 0 0 auto; font-weight: 500; }

.inputline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
}
.inputline .prompt { color: var(--accent); white-space: nowrap; font-size: 0.88rem; font-weight: 600; }
.inputline input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font: inherit;
  font-size: 0.88rem;
  caret-color: var(--accent);
}
.send-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line-light);
  border-radius: 6px;
  color: var(--accent);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
}
.send-btn:hover, .send-btn:active { background: rgba(56, 189, 248, 0.12); border-color: var(--accent); }

/* Map mode switch (live ping / 24h heat map), shown while the terminal is hidden */
.map-toggle {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 2;
  display: none;
  gap: 2px;
  padding: 3px;
  transform: translateX(-50%);
  background: rgba(11, 15, 20, 0.85);
  border: 1px solid var(--line-light);
  border-radius: 9999px;
  backdrop-filter: blur(10px);
}
body:has(main.closed-view) .map-toggle { display: flex; }
body.race-open .map-toggle { display: none; }
.map-toggle button {
  padding: 5px 14px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  white-space: nowrap;
}
.map-toggle button:hover { color: var(--fg); }
.map-toggle button[data-mode="ping"][aria-pressed="true"] { color: var(--bg); background: var(--accent); }
.map-toggle button[data-mode="heat"][aria-pressed="true"] { color: var(--bg); background: #fb923c; }

/* Live-visitors privacy notice, pinned under the terminal / restore button */
.privacy-note {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 6px;
  z-index: 1;
  margin: 0;
  padding: 0 16px;
  text-align: center;
  font-family: var(--font);
  font-size: 10px;
  line-height: 1.4;
  color: var(--muted);
  opacity: 0.8;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.privacy-note .privacy-short { display: none; }

@media (max-width: 640px) {
  .privacy-note .privacy-long { display: none; }
  .privacy-note .privacy-short { display: inline; }
}

@media (max-width: 480px) {
  body { padding: 3vh 10px; }
  main { height: 92vh; height: 92dvh; }
  .term { padding: 14px 14px 10px; }
  .inputline input { font-size: 16px; }
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: opacity 0.9s ease;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-domain {
  font-size: clamp(1.4rem, 5vw, 2.4rem);
  font-weight: 700;
  color: var(--fg);
  letter-spacing: 0.04em;
}
.splash-name {
  font-size: clamp(1rem, 3vw, 1.3rem);
  color: var(--muted);
}
.splash-cursor {
  display: inline-block;
  width: 8px;
  height: 1em;
  background: var(--accent);
  margin-left: 4px;
  vertical-align: middle;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Interactive Converter Component ---------- */
.converter-card {
  margin: 10px 0;
  padding: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.converter-dropzone {
  border: 2px dashed var(--line-light);
  border-radius: 8px;
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(0, 0, 0, 0.2);
}
.converter-dropzone:hover, .converter-dropzone.dragover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}
.converter-dropzone .drop-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
}
.converter-dropzone .drop-hint {
  font-size: 0.85rem;
  color: var(--muted);
}
.converter-dropzone .drop-hint strong {
  color: var(--accent);
}

.converter-file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  font-size: 0.85rem;
}
.converter-file-name {
  color: var(--fg);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.converter-file-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.converter-section-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.converter-formats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.format-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 5px 10px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.format-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.format-pill.active {
  background: var(--accent);
  color: #0b0f14;
  font-weight: 700;
  border-color: var(--accent);
}

.converter-preview-box {
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.converter-thumb {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 4px;
  background: #111;
  border: 1px solid var(--line);
}
.converter-stats {
  flex: 1;
  font-size: 0.84rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.converter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.conv-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}
.conv-btn-primary {
  background: var(--accent);
  color: #0b0f14;
}
.conv-btn-primary:hover {
  background: #7dd3fc;
}
.conv-btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line-light);
  color: var(--fg);
}
.conv-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}


/* ---------- race: live typing duel ---------- */
.race {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 35;
  width: min(760px, calc(100vw - 20px));
  max-height: calc(100dvh - 24px);
  display: none;
  flex-direction: column;
  transform: translate(-50%, -50%);
  background: rgba(11, 17, 30, 0.96);
  border: 1px solid var(--line-light);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(14px);
  overflow: hidden;
  font-family: var(--font);
  color: var(--fg);
}
.race.open { display: flex; }
body.race-open main#terminal { opacity: 0.15; pointer-events: none; }

.race-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.9);
}
.race-dots { display: flex; gap: 6px; }
.race-dots span { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.race-dots span:nth-child(2) { background: #febc2e; }
.race-dots span:nth-child(3) { background: #28c840; }
.race-title { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.race-close {
  background: none;
  border: 1px solid var(--line-light);
  color: var(--muted);
  border-radius: 6px;
  width: 26px;
  height: 24px;
  cursor: pointer;
  font: inherit;
}
.race-close:hover { color: var(--fg); border-color: var(--accent); }

.race-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px 14px;
  overflow-y: auto;
}
.race-status { font-size: 13px; line-height: 1.6; min-height: 22px; }
.race-status .hot { color: var(--warn); }
.race-status .go { color: var(--success); }
.race-count {
  display: inline-block;
  min-width: 34px;
  padding: 0 8px;
  margin-right: 6px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--bg);
  background: var(--warn);
  border-radius: 6px;
}
.race-notice { margin-top: 4px; color: var(--warn); font-size: 12px; }

.race-rows { display: flex; flex-direction: column; gap: 7px; }
.race-row {
  display: grid;
  grid-template-columns: minmax(0, 200px) 1fr 92px;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}
.race-row.result { grid-template-columns: 36px minmax(0, 1fr) auto; }
.race-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.race-who i { color: var(--accent); font-style: normal; }
.race-row.me .race-who { color: var(--accent); font-weight: 700; }
.race-row.bot .race-who { color: var(--muted); }
.race-row.left { opacity: 0.4; }
.race-track { height: 6px; background: rgba(56, 189, 248, 0.1); border-radius: 3px; overflow: hidden; }
.race-fill { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.15s linear; }
.race-row.me .race-fill { background: var(--success); }
.race-row.bot .race-fill { background: var(--muted); }
.race-wpm { text-align: right; color: var(--muted); white-space: nowrap; }
.race-row.me .race-wpm { color: var(--success); }
.race-place { font-size: 15px; text-align: center; }
.race-best {
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  color: var(--bg);
  background: var(--warn);
  border-radius: 4px;
}

.race-text {
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.75;
  background: rgba(2, 6, 23, 0.55);
  border: 1px solid var(--line);
  border-radius: 8px;
  user-select: none;
  -webkit-user-select: none;
}
.race-text .ok { color: var(--success); }
.race-text .bad { color: #fff; background: rgba(244, 63, 94, 0.55); border-radius: 2px; }
.race-text .cur { color: var(--fg); border-bottom: 2px solid var(--accent); }
.race-text .todo { color: #94a3b8; }
.race-placeholder { color: var(--muted); font-size: 13px; }

.race-input {
  width: 100%;
  padding: 11px 14px;
  font: inherit;
  font-size: 15px;
  color: var(--fg);
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--line-light);
  border-radius: 8px;
  outline: none;
}
.race-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.race-input:disabled { opacity: 0.5; }

.race-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; min-height: 30px; }
.race-foot .dim { color: var(--muted); }
.race-again {
  padding: 6px 14px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.race-again:hover { filter: brightness(1.1); }
.race .dim { color: var(--muted); }

/* Phones: full-screen, text + input on top so the on-screen keyboard never hides them */
@media (max-width: 640px) {
  .race {
    left: 0;
    top: 0;
    width: 100%;
    height: var(--race-vh, 100dvh);
    max-height: none;
    transform: none;
    border: none;
    border-radius: 0;
    background: var(--bg);
  }
  body.race-open main#terminal,
  body.race-open .privacy-note,
  body.race-open .restore-term-btn { visibility: hidden; }
  .race-bar { padding: 10px 12px; }
  .race-body { flex: 1; padding: 12px 12px 14px; gap: 10px; }
  .race-status { order: 1; font-size: 12px; }
  .race-text { order: 2; font-size: 14px; line-height: 1.65; padding: 10px 12px; }
  .race-input { order: 3; font-size: 16px; padding: 10px 12px; }
  .race-foot { order: 4; min-height: 0; }
  .race-rows { order: 5; }
  .race-row { grid-template-columns: minmax(0, 118px) 1fr 62px; gap: 8px; font-size: 11px; }
  .race-row.result { grid-template-columns: 28px minmax(0, 1fr) auto; }
  .race-row.result .race-wpm { font-size: 10px; }
}
