:root {
  --bg: #000;
  --green: #00d700;
  --bright: #00ff00;
  --dim: #2e8b2e;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  color-scheme: dark;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  color: var(--green);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  color: var(--bright);
}

:focus-visible {
  outline: 1px solid var(--bright);
  outline-offset: 2px;
}

/* Rain area */

#screen {
  position: relative;
  flex: 1;
  min-height: 0;
}

#rain {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* Boot and final screens: sized so the 52-character rule fits any width */

.console {
  position: absolute;
  inset: 0;
  margin: 0;
  overflow: auto;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    1rem
    max(1rem, env(safe-area-inset-left));
  font: 400 clamp(10px, calc((100vw - 2rem) / 32), 18px) / 1.4 var(--mono);
  white-space: pre;
}

.console.typing::after {
  content: "\2588";
  animation: blink 1s steps(1) infinite;
}

.bright {
  color: var(--bright);
  font-weight: 700;
}

.again {
  color: var(--dim);
}

/* Status and controls beneath the rain */

#hud {
  flex: none;
  padding:
    0.25rem
    max(1rem, env(safe-area-inset-right))
    max(0.5rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
  font-size: clamp(11px, calc((100vw - 2rem) / 40), 14px);
  line-height: 1.5;
}

#status {
  overflow: hidden;
  color: var(--bright);
  font-weight: 700;
  white-space: pre;
}

/* The longest status line (61 characters) doesn't fit on a phone, so wrap it
   into a fixed two-line block; a fixed height keeps the rain from resizing. */
@media (max-width: 480px) {
  #status {
    height: 3em;
    white-space: pre-wrap;
  }
}

#controls {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 1ch;
  color: var(--dim);
}

#controls button {
  padding-block: 0.2rem;
}

#controls .solo {
  padding-inline: 0.6ch;
}

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

@media (prefers-reduced-motion: reduce) {
  .console.typing::after {
    animation: none;
  }
}
