:root {
  color-scheme: dark;
  --ink: #e9e2cf;
  --muted: #8ea5aa;
  --night: #061721;
  --panel: rgba(5, 24, 34, 0.92);
  --line: rgba(174, 208, 202, 0.22);
  --gold: #f4ca71;
  --warm: #ed884f;
  --safe: #8ed7b0;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% -25%, #183c4b 0, #081d28 42%, #030e15 100%);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button { font: inherit; }

.shell {
  height: 100dvh;
  width: min(1180px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  gap: 9px;
}

.masthead {
  min-height: 54px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.identity h1 {
  margin: 2px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-size: clamp(19px, 2.5vw, 30px);
  letter-spacing: 0.12em;
}

.eyebrow, .overline, .logline {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.watch { display: flex; gap: 10px; }

.watch-mark {
  color: rgba(142, 165, 170, 0.32);
  font-size: 15px;
  transition: color 300ms, filter 300ms, transform 300ms;
}

.watch-mark.active { color: #d4b669; filter: drop-shadow(0 0 7px #c88b45); }
.watch-mark.home { color: var(--safe); filter: drop-shadow(0 0 8px #6fc69a); transform: rotate(45deg); }
.watch-mark.lost { color: #c86c5c; }

.actions { justify-self: end; display: flex; gap: 7px; }

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(4, 20, 29, 0.62);
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover, .icon-button:focus-visible { border-color: var(--gold); outline: none; }

.stage {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  border: 1px solid rgba(174, 208, 202, 0.18);
  border-radius: 4px 32px 4px 32px;
  background: #082632;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42), inset 0 0 90px rgba(0, 0, 0, 0.26);
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(246, 215, 148, 0.04), inset 0 0 110px rgba(0, 5, 10, 0.4);
  z-index: 4;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  outline: none;
}

canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--gold); }

.announcement {
  position: absolute;
  left: 50%;
  top: 9%;
  transform: translate(-50%, -8px);
  z-index: 6;
  min-width: min(310px, 78%);
  text-align: center;
  color: #f7e7b8;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(15px, 2.3vw, 20px);
  letter-spacing: 0.06em;
  opacity: 0;
  transition: opacity 260ms, transform 260ms;
  pointer-events: none;
  text-shadow: 0 2px 12px #00131d;
}

.announcement.show { opacity: 1; transform: translate(-50%, 0); }

.controls-hint {
  position: absolute;
  z-index: 5;
  right: 17px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(225, 231, 216, 0.62);
  background: rgba(4, 18, 26, 0.52);
  border: 1px solid rgba(184, 209, 205, 0.13);
  border-radius: 18px;
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 0.1em;
  transition: opacity 500ms;
}

.controls-hint.used { opacity: 0; }
.pointer-glyph { color: var(--gold); font-size: 20px; transform: rotate(-20deg); }

.modal-card {
  position: absolute;
  z-index: 10;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(410px, calc(100% - 34px));
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: clamp(24px, 5vw, 44px);
  border: 1px solid rgba(230, 204, 143, 0.3);
  border-radius: 3px 28px 3px 28px;
  background: linear-gradient(145deg, rgba(8, 34, 44, 0.97), rgba(3, 18, 27, 0.97));
  text-align: center;
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.56);
}

.modal-card[hidden] { display: none; }
.modal-card h2 { margin: 8px 0 10px; font: 500 clamp(24px, 5vw, 38px)/1.05 Georgia, serif; }
.modal-card p:not(.overline) { margin: 0 0 24px; color: #adc1c0; line-height: 1.5; }

.seal {
  width: 78px;
  height: 78px;
  margin: 0 auto 18px;
  border: 1px solid rgba(244, 202, 113, 0.45);
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: 0 0 35px rgba(244, 202, 113, 0.14);
}

.seal span { width: 9px; height: 42px; border-radius: 5px 5px 2px 2px; background: linear-gradient(#f8db8a 0 35%, #d3c9ad 36% 68%, #7d9aa1 69%); box-shadow: 0 0 18px #f8d074; }

.primary-button, .danger-button, .text-button {
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 23px;
  cursor: pointer;
}

.primary-button {
  border: 1px solid #f3d28a;
  color: #10232a;
  background: linear-gradient(135deg, #ffe9aa, #e2ae59);
  box-shadow: 0 8px 25px rgba(202, 143, 57, 0.22);
}

.danger-button { border: 1px solid #d98d78; background: #7d3d38; color: white; }
.text-button { border: 1px solid var(--line); color: var(--ink); background: transparent; }
.primary-button:hover, .primary-button:focus-visible, .danger-button:hover, .danger-button:focus-visible, .text-button:hover, .text-button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.button-row { display: flex; flex-direction: column; gap: 10px; }

.end-sun { width: 72px; height: 36px; margin: 0 auto 18px; border-radius: 72px 72px 0 0; background: #efad68; box-shadow: 0 0 45px #ed8457; }

.logline { display: flex; justify-content: space-between; min-height: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 600px) {
  .shell { padding-left: 0; padding-right: 0; padding-bottom: 0; gap: 5px; }
  .masthead { padding: 0 10px; grid-template-columns: minmax(0, 1fr) auto auto; min-height: 59px; gap: 8px; }
  .identity { min-width: 0; }
  .identity h1 { overflow: hidden; font-size: 16px; letter-spacing: .09em; text-overflow: ellipsis; white-space: nowrap; }
  .identity .eyebrow { font-size: 8px; }
  .watch { gap: 5px; }
  .watch-mark { font-size: 12px; }
  .actions { grid-column: 3; grid-row: 1; gap: 5px; }
  .stage { border-left: 0; border-right: 0; border-radius: 0 22px 0 22px; }
  .logline { padding: 0 9px 4px; font-size: 7px; letter-spacing: 0.12em; }
  .controls-hint { right: 9px; bottom: 10px; }
  .modal-card { padding: 27px 22px; }
}

@media (max-width: 360px) {
  .identity h1 { font-size: 14px; letter-spacing: .06em; }
  .identity .eyebrow { display: none; }
  .masthead { min-height: 50px; padding-inline: 7px; gap: 5px; }
  .watch { gap: 3px; }
  .watch-mark { font-size: 10px; }
}

@media (max-height: 500px) {
  .shell { padding-top: 4px; padding-bottom: 3px; gap: 4px; }
  .masthead { min-height: 42px; }
  .identity h1 { margin-top: 0; font-size: 15px; }
  .identity .eyebrow, .logline { display: none; }
  .modal-card { width: min(460px, calc(100% - 24px)); max-height: calc(100% - 12px); padding: 14px 22px; }
  .modal-card h2 { margin: 4px 0 7px; font-size: clamp(20px, 5vh, 27px); }
  .modal-card p:not(.overline) { margin-bottom: 12px; line-height: 1.3; }
  .seal { width: 40px; height: 40px; margin-bottom: 7px; }
  .seal span { width: 6px; height: 24px; }
  .button-row { flex-direction: row; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
