:root {
  color-scheme: dark;
  --ink: #f5f5f5;
  --accent: #ff2e63;
  --muted: #9aa0a6;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #000;
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  /* No text selection, no callout, no double-tap zoom: every touch during play
     is a game touch. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

/* Any rule that sets `display` beats the browser's own `[hidden]` rule, so a
   hidden element with `display: flex` on its class stays on screen. That is
   what put an empty "Viimeksi käytetty huone" box on the first screen. One
   global rule, so the next control to get a class cannot repeat it. */
[hidden] {
  display: none !important;
}

.panel {
  min-height: 100%;
  padding: max(2rem, env(safe-area-inset-top)) 1.5rem max(2rem, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: center;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: 2rem;
}

.lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.code {
  margin: 0;
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: 0.15em;
}

button {
  font: inherit;
  border-radius: 999px;
  border: 2px solid transparent;
  padding: 1rem 1.5rem;
  min-height: 3.25rem;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

button.primary:disabled {
  background: #3a3a3a;
  color: var(--muted);
  cursor: default;
}

button.secondary {
  background: transparent;
  border-color: #444;
  color: var(--ink);
}

button.link {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  min-height: 0;
  padding: 0.25rem;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

input {
  font: inherit;
  font-size: 2rem;
  text-align: center;
  letter-spacing: 0.2em;
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 2px solid #444;
  background: #111;
  color: var(--ink);
}

.resume {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px solid #333;
  border-radius: 1rem;
}

.settings {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px solid #333;
  border-radius: 1rem;
  text-align: left;
}

.settings label {
  font-size: 0.95rem;
}

/* A slider a thumb can actually hit on a phone. */
.settings input[type='range'] {
  width: 100%;
  height: 2.5rem;
  accent-color: var(--accent);
  background: none;
  border: none;
  padding: 0;
}

.notice:empty {
  display: none;
}

.notice {
  margin: 0;
  color: var(--accent);
}

.hint,
.status {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* The one screen that is allowed to show a technical message to a person. */
.fatal {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 10;
  background: #300;
  border-bottom: 2px solid var(--accent);
  padding: 1rem;
  font-size: 0.85rem;
}

.fatal pre {
  margin: 0.5rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
}

/* Flexbox `gap` is Chrome 84. An older phone ignores it and every button in a
   column touches the one above, which on a screen of full-width buttons is
   genuinely hard to use. Only applied where `gap` is missing. */
@supports not (gap: 1rem) {
  .panel > * + *,
  .resume > * + *,
  .settings > * + *,
  .adult > * + *,
  form > * + * {
    margin-top: 0.75rem;
  }
}

/* The child-facing surface: a black rectangle and nothing else. Any chrome
   added here would show on an inactive phone, which the game must never do. */
.game {
  position: fixed;
  /* Spelled out rather than `inset`, which is Chrome 87. On an older phone
     `inset` is dropped and the surface collapses to nothing. */
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: #000;
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Only reachable through the deliberate long press, so it is safe for it to be
   a normal, easily tapped dialog once it is open. */
.adult {
  position: fixed;
  top: auto;
  right: 1rem;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: 1rem;
  background: #141414;
  border: 1px solid #333;
  border-radius: 1rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: center;
}
