* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: #050506;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
body[data-theme="paper"] { background: #f2f2f2; }

#portrait { position: fixed; inset: 0; display: block; cursor: crosshair; }

#welcome {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  font: 15px/1.6 ui-monospace, Menlo, monospace;
  color: #e9e9e9;
}
#welcome[hidden], #toast[hidden] { display: none; }
#welcome h1 { font-size: 28px; letter-spacing: 0.08em; }
#welcome .small { color: #888; font-size: 13px; }
.button {
  margin-top: 8px;
  padding: 10px 22px;
  border: 1px solid #e9e9e9;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.button:hover { background: #e9e9e9; color: #000; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  max-width: min(640px, 92vw);
  padding: 12px 18px;
  border-radius: 10px;
  background: rgba(20, 20, 20, 0.88);
  color: #eee;
  font: 13px/1.5 ui-monospace, Menlo, monospace;
}
#toast pre { margin-top: 8px; padding: 8px; background: #000; border-radius: 6px; white-space: pre-wrap; user-select: text; }

#controls {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 8px;
  z-index: 10;
  opacity: 0.45;
  transition: opacity 0.25s;
}
#controls[hidden] { display: none; }
#controls:hover, #controls:focus-within { opacity: 0.95; }
#controls button {
  padding: 7px 12px;
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(12, 12, 14, 0.65);
  color: #eee;
  font: 12px/1 ui-monospace, Menlo, monospace;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  touch-action: manipulation;
}
#controls button:hover, #controls button:active { background: rgba(255, 255, 255, 0.18); }
body[data-theme="paper"] #controls button {
  border-color: rgba(0, 0, 0, 0.25);
  background: rgba(245, 245, 245, 0.75);
  color: #111;
}
body[data-theme="paper"] #controls button:hover,
body[data-theme="paper"] #controls button:active { background: rgba(0, 0, 0, 0.12); }

@media (max-width: 640px) {
  #controls {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    opacity: 0.7;
  }
  #controls button {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 13px;
  }
  #welcome h1 { font-size: 22px; padding: 0 16px; }
  #welcome p { padding: 0 20px; font-size: 14px; }
}
