@font-face {
  font-family: "IM Fell English";
  src: url("fonts/im-fell-english.woff2") format("woff2");
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IM Fell English";
  src: url("fonts/im-fell-english-italic.woff2") format("woff2");
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "IM Fell English SC";
  src: url("fonts/im-fell-english-sc.woff2") format("woff2");
  font-display: swap;
}

:root {
  --desk: #16130f;
  --desk-lit: #2a231b;
  --paper: #eadfc4;
  --ink: #3b2a1b;
  --chalk: #b9ab8f;
  --chalk-dim: #7d7260;
  --serif: "IM Fell English", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --caps: "IM Fell English SC", "IM Fell English", Georgia, serif;
  --rail: 3rem;
  --gap: clamp(0.5rem, 2.2vmin, 1.75rem);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: radial-gradient(ellipse at 50% 38%, var(--desk-lit), var(--desk) 72%) var(--desk);
  color: var(--chalk);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#desk {
  position: fixed;
  inset: 0 0 var(--rail) 0;
  padding: var(--gap) var(--gap) 0;
  padding-top: max(var(--gap), env(safe-area-inset-top));
}

/* Sized and placed by app.js, which knows the sheet's proportions. */
#sheet {
  position: absolute;
  background: var(--paper);
  box-shadow: 0 1px 0 #fff2 inset, 0 1.2rem 3.5rem #000b, 0 0.2rem 0.6rem #0008;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  opacity: 0;
  transition: opacity 1.2s ease;
}
#sheet.laid { opacity: 1; }
#sheet.gone { opacity: 0.12; transition-duration: 2.4s; }
#sheet:focus-visible { outline: 1px solid var(--chalk); outline-offset: 4px; }

#sheet canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#lettering { pointer-events: none; }

#gazes { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.gaze {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  color: var(--ink);
  font-family: var(--caps);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  transition: opacity 0.6s ease;
  will-change: transform;
}
.gaze::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -5px;
  width: 10px;
  height: 10px;
  border: 1.25px solid currentColor;
  border-radius: 50%;
  background: #fff6;
}
.gaze span { position: absolute; left: 9px; top: -0.62rem; white-space: nowrap; text-shadow: 0 0 3px var(--paper), 0 0 3px var(--paper); }
.gaze.away { opacity: 0; }

#words {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 0.35rem;
  padding: 8%;
  text-align: center;
  color: var(--ink);
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.6s ease;
}
#words.shown { opacity: 1; }
#words p { margin: 0; text-wrap: balance; }
#claim { font-style: italic; font-size: clamp(1.6rem, 4.6vmin, 3.1rem); line-height: 1.15; }
#sub { font-size: clamp(0.95rem, 2vmin, 1.2rem); opacity: 0.78; }

#notice {
  position: fixed;
  left: 50%;
  bottom: calc(var(--rail) + 0.9rem);
  transform: translate(-50%, 0.4rem);
  margin: 0;
  padding: 0.3rem 0.95rem;
  max-width: calc(100vw - 2rem);
  background: var(--paper);
  color: var(--ink);
  font-style: italic;
  font-size: 1.02rem;
  text-align: center;
  box-shadow: 0 0.4rem 1.2rem #0009;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
#notice.shown { opacity: 1; transform: translate(-50%, 0); }

#rail {
  position: fixed;
  inset: auto 0 0 0;
  height: var(--rail);
  padding: 0 max(var(--gap), env(safe-area-inset-right)) env(safe-area-inset-bottom) max(var(--gap), env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.95rem;
}
#status { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#status b { font-weight: normal; font-family: var(--caps); letter-spacing: 0.06em; color: #d8ccb0; }
#rail nav { display: flex; gap: 1.1rem; flex: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0.35rem 0;
  cursor: pointer;
  font-style: italic;
  border-bottom: 1px solid #0000;
}
button:hover, button:focus-visible { color: #efe5cb; border-bottom-color: currentColor; outline: none; }
#release.sure { color: #e0a070; }

dialog {
  width: min(34rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: clamp(1.25rem, 4vmin, 2.25rem);
  border: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 1.06rem;
  line-height: 1.55;
  box-shadow: 0 1.5rem 4rem #000c;
  outline: 1px solid #3b2a1b55;
  outline-offset: -0.5rem;
}
dialog::backdrop { background: #0c0a08c4; }
dialog h1 { margin: 0 0 0.6rem; font-family: var(--caps); font-weight: normal; font-size: 1.7rem; letter-spacing: 0.14em; }
dialog p { margin: 0 0 0.85rem; }
dialog .facts { font-size: 0.92rem; font-style: italic; opacity: 0.8; }
dialog a { color: inherit; }
dialog form { margin-top: 1.25rem; }
dialog button { color: var(--ink); border-bottom: 1px solid currentColor; }
dialog button:hover, dialog button:focus-visible { color: #000; }

.fallback {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  margin: 0;
  padding: 2rem;
  text-align: center;
  font-style: italic;
  font-size: 1.2rem;
}

@media (max-width: 40rem) {
  :root { --rail: 4.6rem; }
  #rail { flex-direction: column; justify-content: center; gap: 0; font-size: 0.9rem; }
  #rail nav { gap: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  #sheet, #words, #notice, .gaze { transition-duration: 0.01s; }
}
