*, *::before, *::after { box-sizing: border-box; }

:root {
  --ink: #fff6e0;
  --night: #1b1930;
  --panel: rgba(22, 20, 43, 0.97);
  --edge: #4b3f7a;
  --prompt: #8fe388;
  --dim: #b9b2d6;
  --warn: #ffcd75;
  --red: #d9536b;
}

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  /* fallback sky in case the canvas can't draw */
  background: linear-gradient(#2b2d5c, #58477f 30%, #cf7286 55%, #ffdca2 68%, #8a86b6 68%, #68b6b8 88%, #e8c49a 88%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "VT323", ui-monospace, "Courier New", monospace;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  z-index: -1;
}

.page {
  width: 100%;
  max-width: 34rem;
  margin-top: -8vh;
}

.name {
  margin: 0;
  font-size: clamp(3rem, 12vw, 5.25rem);
  font-weight: 400;
  line-height: 0.95;
  text-shadow: 4px 4px 0 var(--night);
}

.role {
  margin: 0.5rem 0 1.75rem;
  font-size: clamp(1.25rem, 4vw, 1.6rem);
  color: var(--warn);
  text-shadow: 3px 3px 0 var(--night);
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Dialog with notched pixel border */
.dialog {
  margin: 4px;
  max-width: 24rem;
  background: var(--panel);
  box-shadow:
    -4px 0 0 var(--ink), 4px 0 0 var(--ink),
    0 -4px 0 var(--ink), 0 4px 0 var(--ink),
    inset 0 0 0 4px var(--edge),
    8px 12px 0 rgba(27, 25, 48, 0.45);
}

.dialog.shake { animation: shake 0.35s steps(6); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px 6px 14px;
  border-bottom: 4px solid var(--edge);
  font-size: 1.25rem;
  color: var(--dim);
}

.close {
  width: 28px; height: 28px;
  border: 0;
  background: var(--red);
  color: var(--ink);
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset -3px -3px 0 #7d2338;
}
.close:active { box-shadow: inset 3px 3px 0 #7d2338; }

.body {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px 4px;
}

/* Pixel warning sign */
.warn-icon {
  flex: none;
  position: relative;
  width: 40px; height: 36px;
  background: var(--warn);
  clip-path: polygon(50% 0, 60% 10%, 60% 20%, 70% 30%, 70% 40%, 80% 50%, 80% 60%, 90% 70%, 90% 80%, 100% 90%, 100% 100%, 0 100%, 0 90%, 10% 80%, 10% 70%, 20% 60%, 20% 50%, 30% 40%, 30% 30%, 40% 20%, 40% 10%);
}
.warn-icon span {
  position: absolute;
  inset: 8px 0 0;
  text-align: center;
  color: var(--night);
  font-size: 1.6rem;
  line-height: 1;
}

.msg {
  margin: 0;
  font-size: clamp(1.3rem, 4.2vw, 1.5rem);
  line-height: 1.2;
  min-height: 3.6em;
  white-space: pre-line;
}

.actions {
  display: flex;
  justify-content: flex-end;
  padding: 4px 14px 14px;
}

.ok {
  display: inline-flex;
  align-items: center;
  padding: 2px 16px 4px;
  border: 0;
  background: #38b764;
  color: var(--night);
  font: inherit;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: inset -4px -4px 0 #257179;
}
.ok::before {
  content: "";
  width: 8px; height: 12px;
  margin-right: 10px;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  visibility: hidden;
}
.ok:hover::before,
.ok:focus-visible::before { visibility: visible; animation: blink 0.8s steps(2) infinite; }
.ok:active { box-shadow: inset 4px 4px 0 #257179; }

.ok:focus-visible,
.close:focus-visible { outline: 4px solid var(--warn); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .dialog.shake, .ok::before { animation: none !important; }
}
