* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background: #050506;
  touch-action: none;
  user-select: 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; }

#setup-button {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: max(104px, calc(env(safe-area-inset-bottom) + 94px));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0;
  padding: 10px 18px;
  transform: translateX(-50%);
  background: rgba(20, 20, 20, 0.88);
  color: #e9e9e9;
  white-space: nowrap;
}
#setup-button[hidden] { display: none; }
body.calibrating { touch-action: none; overscroll-behavior: none; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  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; }

#credit {
  position: fixed;
  z-index: 2;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  color: rgba(233, 233, 233, 0.58);
  font: 11px/1.2 ui-monospace, Menlo, monospace;
  letter-spacing: 0.04em;
  pointer-events: none;
}

@media (max-width: 600px) {
  #welcome {
    padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
    gap: 12px;
    font-size: 14px;
  }
  #welcome h1 { font-size: clamp(20px, 6vw, 28px); }
  #welcome p { max-width: 34ch; }
  #welcome p br { display: none; }
  .button { min-height: 44px; display: inline-flex; align-items: center; }
  #toast {
    bottom: max(44px, calc(env(safe-area-inset-bottom) + 34px));
    width: calc(100vw - 24px);
    max-width: 640px;
    max-height: 45vh;
    overflow: auto;
    padding: 10px 12px;
    font-size: 12px;
  }
  #toast pre { overflow-wrap: anywhere; }
  #credit { font-size: 10px; }
}
