:root {
  color-scheme: dark;
  --panel-bg: rgba(0, 0, 0, 0.92);
  --white: #ffffff;
  --black: #000000;
}

@font-face {
  font-family: "Press Start 2P";
  src: url("PressStart2P.ttf") format("truetype");
  font-display: swap;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  padding: 24px;
  overflow-x: hidden;
  color: var(--white);
  background-color: var(--black);
  background-image: url("Background.gif");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  font-family: "Press Start 2P", monospace;
  font-weight: 400;
}

.topbar {
  width: min(1440px, 100%);
  min-height: 82px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: clamp(24px, 4vw, 64px);
  background: var(--panel-bg);
  border: 3px solid var(--white);
  box-shadow:
    0 0 0 3px var(--black),
    0 8px 0 rgba(0, 0, 0, 0.55);
}

.brand,
.main-nav a,
.account-link {
  color: var(--white);
  text-decoration: none;
  letter-spacing: 0;
  text-shadow: 2px 2px 0 var(--black);
}

.account-link {
  appearance: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-family: inherit;
  font-weight: inherit;
  cursor: pointer;
}

.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 14px;
}

.brand__soul {
  width: 30px;
  height: 30px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(2px 2px 0 #650000);
}

.brand__name {
  font-size: clamp(0.66rem, 1vw, 0.8rem);
  white-space: nowrap;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: clamp(18px, 2.8vw, 42px);
}

.main-nav a,
.account-link {
  position: relative;
  padding: 10px 4px;
  font-size: 0.63rem;
  line-height: 1;
}

.main-nav a::before,
.account-link--signin::before {
  content: "";
  position: absolute;
  left: 50%;
  right: 50%;
  bottom: 1px;
  height: 3px;
  background: var(--white);
  transition: left 120ms steps(2), right 120ms steps(2);
}

.main-nav a:hover::before,
.main-nav a:focus-visible::before,
.account-link--signin:hover::before,
.account-link--signin:focus-visible::before {
  left: 4px;
  right: 4px;
}

.account-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.account-link--register,
.account-link--signout {
  padding: 12px 14px;
  border: 2px solid var(--white);
  background: var(--black);
}

.account-link--register:hover,
.account-link--register:focus-visible,
.account-link--signout:hover,
.account-link--signout:focus-visible {
  color: var(--black);
  background: var(--white);
  text-shadow: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--white);
  outline-offset: 4px;
}

.account-name {
  max-width: 190px;
  padding: 12px 14px;
  overflow: hidden;
  color: var(--white);
  background: var(--black);
  border: 2px solid var(--white);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.6rem;
  font-family: inherit;
  font-weight: inherit;
  line-height: 1.2;
  text-shadow: 2px 2px 0 var(--black);
  cursor: pointer;
}

.account-name:hover,
.account-name:focus-visible {
  color: var(--black);
  background: var(--white);
  text-shadow: none;
}

.story {
  width: min(1440px, 100%);
  min-height: calc(100vh - 154px);
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  padding: clamp(48px, 9vh, 104px) 24px clamp(48px, 12vh, 140px);
  text-align: center;
}

.chapter-page,
.story-editor-page {
  width: min(1200px, 100%);
  min-height: calc(100vh - 154px);
  margin: 0 auto;
  padding: clamp(48px, 7vh, 82px) 24px;
}

.chapter-page-header {
  text-align: center;
  text-shadow: 4px 4px 0 var(--black);
}

.back-link {
  display: inline-block;
  margin-bottom: 28px;
  color: var(--white);
  font-size: 0.58rem;
  text-decoration: none;
}

.chapter-page-header h1 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 2.1rem);
  font-weight: 400;
}

.chapter-page-header p {
  margin: 22px 0 0;
  font-size: 0.62rem;
  line-height: 1.8;
}

.chapter-editor-button {
  margin-top: 30px;
}

.parts-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px;
  margin-top: 46px;
}

.part-card,
.empty-parts,
.editor-denied,
.story-editor-sidebar,
.scene-editor {
  padding: 24px;
  background: rgba(0, 0, 0, 0.93);
  border: 3px solid var(--white);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.62);
}

.part-card h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.7;
}

.part-actions,
.scene-form-actions,
.scene-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.part-actions { margin-top: 26px; }

.secondary-action {
  margin: 0;
  color: var(--white);
  background: #111;
}

.secondary-action:hover,
.secondary-action:focus-visible {
  color: var(--black);
  background: var(--white);
}

.form-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.empty-parts,
.editor-denied {
  margin: 46px auto 0;
  max-width: 700px;
  text-align: center;
  font-size: 0.62rem;
  line-height: 1.8;
}

.story-editor-layout {
  display: grid;
  grid-template-columns: minmax(230px, 310px) minmax(0, 1fr);
  align-items: start;
  gap: 26px;
  margin-top: 44px;
}

.story-editor-sidebar h2,
.scene-editor h2,
.scene-editor h3 {
  margin: 0;
  font-weight: 400;
}

.story-editor-sidebar h2 { font-size: 0.85rem; }

.part-form,
.scene-form {
  display: grid;
  gap: 12px;
}

.part-form { margin-top: 28px; }

.part-form label,
.scene-form label,
.scene-editor-actions label {
  font-size: 0.54rem;
  line-height: 1.6;
}

.part-form input,
.scene-form input,
.scene-form textarea,
.scene-form select,
.scene-editor-actions select {
  width: 100%;
  padding: 12px;
  color: var(--white);
  background: #111;
  border: 2px solid var(--white);
  border-radius: 0;
  font: 0.74rem/1.5 "Courier New", monospace;
  font-weight: 700;
}

.scene-form textarea { resize: vertical; }

.scene-canvas {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background-color: #111;
  background-position: center;
  background-size: cover;
  border: 2px solid var(--white);
  touch-action: none;
}

.scene-canvas-empty {
  margin: 0;
  padding: 22px;
  color: #bdbdbd;
  font: 0.66rem/1.7 "Courier New", monospace;
  font-weight: 700;
  text-align: center;
}

.canvas-layer {
  position: absolute;
  z-index: 1;
  max-width: none;
  transform: translate(-50%, -100%);
  object-fit: contain;
  image-rendering: pixelated;
  cursor: grab;
  filter: drop-shadow(3px 3px 0 rgba(0, 0, 0, 0.75));
}

.canvas-layer.is-selected { outline: 2px solid #ffe870; }

.layer-tools,
.layer-editor {
  padding: 14px;
  display: grid;
  gap: 10px;
  background: #111;
  border: 2px solid rgba(255, 255, 255, 0.6);
}

.layer-numbers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.layer-numbers label {
  display: grid;
  gap: 6px;
}

.preview-stage { position: relative; overflow: hidden; }

.preview-visuals {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-position: center;
  background-size: cover;
}

.preview-visuals::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
}

.preview-visuals img {
  position: absolute;
  z-index: 1;
  max-width: none;
  transform: translate(-50%, -100%);
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(3px 3px 0 rgba(0, 0, 0, 0.75));
}

.preview-stage > :not(.preview-visuals) { position: relative; z-index: 2; }

.editor-parts-list {
  display: grid;
  gap: 9px;
  margin-top: 28px;
}

.editor-part,
.scene-control {
  padding: 11px;
  color: var(--white);
  background: var(--black);
  border: 2px solid var(--white);
  font: 0.55rem/1.55 "Press Start 2P", monospace;
  text-align: left;
  cursor: pointer;
}

.editor-part:hover,
.editor-part:focus-visible,
.editor-part.is-active,
.scene-control:hover,
.scene-control:focus-visible {
  color: var(--black);
  background: var(--white);
}

.scene-editor-topline {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
}

.scene-editor h2 { font-size: 0.92rem; }

.scene-editor-actions { justify-content: flex-end; }

.scene-editor-actions label {
  display: grid;
  gap: 7px;
  min-width: 135px;
  text-align: left;
}

.scene-editor-actions .form-submit { margin: auto 0 0; }

.editor-hint {
  margin: 25px 0 0;
  color: #d6d6d6;
  font: 0.72rem/1.7 "Courier New", monospace;
  font-weight: 700;
}

.scene-workspace {
  display: grid;
  grid-template-columns: minmax(230px, 0.85fr) minmax(280px, 1.15fr);
  gap: 20px;
  margin-top: 28px;
}

.scene-list {
  max-height: 610px;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow-y: auto;
}

.editor-scene {
  padding: 16px;
  background: #111;
  border: 2px solid var(--white);
}

.editor-scene strong { font-size: 0.6rem; }

.editor-scene p {
  margin: 14px 0 0;
  font: 0.72rem/1.55 "Courier New", monospace;
  font-weight: 700;
  white-space: pre-wrap;
}

.scene-controls {
  display: grid;
  gap: 7px;
  margin-top: 16px;
}

.empty-scenes {
  margin: 0;
  padding: 18px;
  color: #d6d6d6;
  border: 2px solid rgba(255, 255, 255, 0.6);
  font: 0.7rem/1.6 "Courier New", monospace;
  font-weight: 700;
}

.story-preview-dialog {
  width: min(920px, calc(100vw - 32px));
  min-height: min(600px, calc(100vh - 32px));
  margin: auto;
  padding: 30px;
  color: var(--white);
  background: #000;
  border: 3px solid var(--white);
  box-shadow: 0 0 0 4px #000, 8px 8px 0 rgba(0, 0, 0, 0.65);
}

.story-preview-dialog::backdrop { background: rgba(0, 0, 0, 0.8); }

.preview-label {
  margin: 0;
  font-size: 0.6rem;
  text-align: center;
}

.preview-stage {
  min-height: 430px;
  margin-top: 30px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: #111;
  border: 3px solid var(--white);
}

.preview-speaker {
  margin: 0 0 18px;
  color: #ffe870;
  font-size: 0.7rem;
}

.preview-text {
  min-height: 100px;
  margin: 0;
  white-space: pre-wrap;
  font: 1rem/1.8 "Courier New", monospace;
  font-weight: 700;
}

.preview-prompt {
  min-height: 18px;
  margin: 26px 0 0;
  color: #d6d6d6;
  font-size: 0.54rem;
  text-align: right;
}

.news-page {
  width: min(940px, 100%);
  min-height: calc(100vh - 154px);
  margin: 0 auto;
  padding: clamp(48px, 7vh, 82px) 24px;
}

.community-page {
  width: min(1160px, 100%);
  min-height: calc(100vh - 154px);
  margin: 0 auto;
  padding: clamp(48px, 7vh, 82px) 24px;
}

.about-page {
  width: min(900px, 100%);
  min-height: calc(100vh - 154px);
  margin: 0 auto;
  padding: clamp(48px, 7vh, 82px) 24px;
}

.about-card {
  padding: clamp(26px, 5vw, 52px);
  color: var(--white);
  background: rgba(0, 0, 0, 0.93);
  border: 3px solid var(--white);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.62);
}

.about-card h1,
.about-card h2 {
  font-weight: 400;
  text-shadow: 3px 3px 0 var(--black);
}

.about-card h1 {
  margin: 0 0 36px;
  font-size: clamp(1.1rem, 2.5vw, 1.75rem);
  text-align: center;
}

.about-card h2 {
  margin: 44px 0 22px;
  font-size: clamp(0.8rem, 1.5vw, 1rem);
}

.about-card p {
  margin: 22px 0 0;
  font: 0.88rem/1.9 "Courier New", monospace;
  font-weight: 700;
}

.community-header {
  text-align: center;
  text-shadow: 4px 4px 0 var(--black);
}

.community-header h1 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2.3rem);
  font-weight: 400;
}

.community-header p {
  margin: 24px 0 0;
  font-size: clamp(0.58rem, 1vw, 0.8rem);
  line-height: 1.8;
}

.community-layout {
  display: grid;
  grid-template-columns: minmax(210px, 260px) minmax(0, 1fr);
  align-items: start;
  gap: 28px;
  margin-top: 42px;
}

.community-sidebar,
.community-post {
  padding: 22px;
  background: rgba(0, 0, 0, 0.93);
  border: 3px solid var(--white);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.62);
}

.community-sidebar label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.56rem;
}

.community-sidebar input,
.community-dialog select {
  box-sizing: border-box;
  width: 100%;
  padding: 12px;
  color: var(--white);
  background: #111;
  border: 2px solid var(--white);
  border-radius: 0;
  font: 0.76rem/1.55 "Courier New", monospace;
  font-weight: 700;
}

.community-categories {
  display: grid;
  gap: 9px;
  margin-top: 26px;
}

.community-category {
  padding: 11px 10px;
  color: var(--white);
  background: var(--black);
  border: 2px solid var(--white);
  font: 0.56rem/1.45 "Press Start 2P", monospace;
  text-align: left;
  cursor: pointer;
}

.community-category:hover,
.community-category:focus-visible,
.community-category.is-active {
  color: var(--black);
  background: var(--white);
}

.community-login-note,
.empty-community {
  margin: 0 0 26px;
  font-size: 0.58rem;
  line-height: 1.8;
  text-align: center;
}

.community-actions {
  margin: 0 0 26px;
  display: flex;
  justify-content: flex-end;
}

.community-create-button {
  margin: 0;
}

.community-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 28px);
  overflow-y: auto;
}

.community-dialog select {
  width: 100%;
  padding: 13px;
  color: var(--white);
  background: #111;
  border: 2px solid var(--white);
  border-radius: 0;
  font: 0.75rem "Courier New", monospace;
  font-weight: 700;
}

.community-list {
  padding-bottom: 50px;
}

.community-post {
  margin-top: 22px;
}

.community-post-meta {
  display: flex;
  align-items: center;
  gap: 13px;
}

.community-post-meta img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  image-rendering: pixelated;
  border: 2px solid var(--white);
  background: #111;
}

.community-post-meta div {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.community-post-meta strong {
  overflow: hidden;
  font-size: 0.62rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.community-post-meta time,
.community-post-category {
  color: #bdbdbd;
  font: 0.58rem "Courier New", monospace;
  font-weight: 700;
}

.community-post-category {
  margin-left: auto;
  padding: 7px;
  border: 1px solid var(--white);
  color: var(--white);
  text-align: right;
}

.community-post h2 {
  margin: 25px 0 0;
  font-size: 0.78rem;
  line-height: 1.7;
  font-weight: 400;
}

.community-post > p {
  margin: 20px 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font: 0.86rem/1.75 "Courier New", monospace;
  font-weight: 700;
}

.news-header {
  text-align: center;
  text-shadow: 4px 4px 0 var(--black);
}

.news-header h1,
.news-header p,
.creator-editor h2 {
  font-weight: 400;
}

.news-header h1 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2.3rem);
}

.news-header p {
  margin: 24px 0 0;
  font-size: clamp(0.6rem, 1vw, 0.8rem);
}

.creator-editor,
.news-post {
  margin-top: 42px;
  padding: clamp(22px, 4vw, 36px);
  background: rgba(0, 0, 0, 0.93);
  border: 3px solid var(--white);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.62);
}

.creator-editor h2 {
  margin: 0 0 28px;
  font-size: clamp(0.8rem, 1.4vw, 1rem);
}

.creator-editor form {
  display: grid;
  gap: 14px;
}

.creator-editor label {
  margin-top: 6px;
  font-size: 0.58rem;
}

.creator-editor input[type="text"] {
  width: 100%;
  padding: 13px;
  color: var(--white);
  background: #111;
  border: 2px solid var(--white);
  border-radius: 0;
  font: 0.75rem "Courier New", monospace;
  font-weight: 700;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: #111;
}

.editor-toolbar button,
.editor-toolbar select {
  min-height: 32px;
  color: var(--white);
  background: var(--black);
  border: 1px solid var(--white);
  font: 0.58rem "Courier New", monospace;
  cursor: pointer;
}

.editor-toolbar button {
  min-width: 36px;
}

.editor-toolbar select {
  padding: 0 6px;
}

.editor-color {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 !important;
}

.editor-color input {
  width: 34px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--white);
  cursor: pointer;
}

.news-editor {
  min-height: 160px;
  padding: 15px;
  color: var(--white);
  background: #111;
  border: 2px solid var(--white);
  font: 0.82rem/1.7 "Courier New", monospace;
  font-weight: 700;
  outline: none;
}

.news-editor:empty::before {
  content: attr(data-placeholder);
  color: #a4a4a4;
}

.news-editor:focus {
  box-shadow: 0 0 0 3px var(--white);
}

.news-attachments {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.news-attachments label {
  margin: 0;
}

.news-attachments input[type="file"] {
  min-width: 0;
  padding: 8px;
  color: var(--white);
  background: #111;
  border: 1px solid var(--white);
  font: 0.58rem "Courier New", monospace;
}

.news-viewer-note,
.empty-news {
  margin: 40px auto;
  text-align: center;
  font-size: 0.6rem;
  line-height: 1.7;
  text-shadow: 2px 2px 0 var(--black);
}

.news-list {
  padding-bottom: 50px;
}

.news-post {
  margin-top: 28px;
}

.news-post h2 {
  margin: 28px 0 0;
  font-size: clamp(0.75rem, 1.4vw, 1rem);
  line-height: 1.6;
  font-weight: 400;
}

.news-author {
  display: flex;
  align-items: center;
  gap: 14px;
}

.news-author-avatar {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  object-fit: cover;
  image-rendering: pixelated;
  border: 2px solid var(--white);
  background: #111;
}

.news-author-details {
  min-width: 0;
}

.news-author-name,
.news-metadata {
  margin: 0;
}

.news-author-name {
  overflow: hidden;
  font-size: 0.66rem;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.news-metadata {
  margin-top: 8px;
  color: #bdbdbd;
  font: 0.62rem "Courier New", monospace;
  font-weight: 700;
}

.news-content {
  margin-top: 22px;
  overflow-wrap: anywhere;
  font: 0.9rem/1.75 "Courier New", monospace;
  font-weight: 700;
}

.news-post-image {
  width: min(100%, 580px);
  max-height: 430px;
  margin-top: 26px;
  display: block;
  object-fit: contain;
  border: 2px solid var(--white);
}

.news-download {
  margin-top: 24px;
  padding: 13px;
  display: inline-block;
  color: var(--white);
  background: var(--black);
  border: 2px solid var(--white);
  font-size: 0.58rem;
  line-height: 1.6;
  text-decoration: none;
}

.news-download:hover,
.news-download:focus-visible {
  color: var(--black);
  background: var(--white);
}

.news-actions {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.news-action,
.comments-more,
.comment-submit {
  padding: 10px 12px;
  color: var(--white);
  background: var(--black);
  border: 2px solid var(--white);
  font: 0.56rem "Press Start 2P", monospace;
  cursor: pointer;
}

.news-action:hover,
.news-action:focus-visible,
.news-action.is-active,
.comments-more:hover,
.comments-more:focus-visible,
.comment-submit:hover,
.comment-submit:focus-visible {
  color: var(--black);
  background: var(--white);
}

.comments-panel {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid rgba(255, 255, 255, 0.45);
}

.comments-list {
  display: grid;
  gap: 14px;
}

.comment {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.comment > img {
  width: 34px;
  height: 34px;
  object-fit: cover;
  image-rendering: pixelated;
  border: 1px solid var(--white);
}

.comment strong {
  display: block;
  font-size: 0.56rem;
}

.comment p,
.empty-comments {
  margin: 7px 0 0;
  font: 0.76rem/1.55 "Courier New", monospace;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.empty-comments {
  color: #bdbdbd;
}

.comments-more {
  justify-self: start;
  margin-top: 2px;
}

.comment-form {
  margin-top: 20px;
  display: flex;
  gap: 10px;
}

.comment-form input {
  min-width: 0;
  flex: 1;
  padding: 11px;
  color: var(--white);
  background: #111;
  border: 2px solid var(--white);
  font: 0.75rem "Courier New", monospace;
  font-weight: 700;
}

.story-title {
  align-self: start;
  text-shadow: 4px 4px 0 var(--black);
}

.story-title h1,
.story-title p {
  margin: 0;
  font-weight: 400;
}

.story-title h1 {
  font-size: clamp(1.8rem, 4.5vw, 3.6rem);
  line-height: 1.25;
}

.story-title p {
  margin-top: clamp(16px, 2.2vw, 28px);
  font-size: clamp(0.85rem, 2vw, 1.45rem);
  line-height: 1.7;
}

.chapter-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vw, 32px);
}

.chapter-arrow,
.chapter-button {
  font: inherit;
  color: var(--white);
  background: var(--black);
  border: 3px solid var(--white);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
  cursor: pointer;
}

.chapter-arrow {
  width: clamp(46px, 7vw, 62px);
  height: clamp(46px, 7vw, 62px);
  padding: 0 0 4px;
  font-size: clamp(1.2rem, 2.3vw, 1.7rem);
  line-height: 1;
}

.chapter-button {
  min-width: min(340px, 56vw);
  min-height: 92px;
  padding: 20px 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-size: clamp(0.66rem, 1.25vw, 0.9rem);
  line-height: 1.6;
}

.chapter-arrow:hover:not(:disabled),
.chapter-arrow:focus-visible,
.chapter-button:hover,
.chapter-button:focus-visible {
  color: var(--black);
  background: var(--white);
  box-shadow: 4px 4px 0 var(--black);
}

.chapter-arrow:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.lock-icon {
  font-family: "Segoe UI Emoji", "Apple Color Emoji", sans-serif;
  font-size: 1.3em;
  line-height: 1;
}

.auth-dialog {
  width: min(430px, calc(100vw - 32px));
  margin: auto;
  padding: clamp(28px, 5vw, 42px);
  color: var(--white);
  background: var(--black);
  border: 3px solid var(--white);
  box-shadow: 0 0 0 4px var(--black), 8px 8px 0 rgba(0, 0, 0, 0.65);
}

.auth-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.auth-dialog h2 {
  margin: 0 0 30px;
  text-align: center;
  font-size: clamp(0.95rem, 2vw, 1.2rem);
  font-weight: 400;
}

.auth-required-dialog p {
  margin: 0;
  color: #d6d6d6;
  text-align: center;
  font: 0.74rem/1.7 "Courier New", monospace;
  font-weight: 700;
}

.auth-required-actions {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.auth-required-actions .form-submit {
  margin-top: 0;
}

.auth-dialog form {
  display: grid;
  gap: 14px;
}

.auth-dialog label {
  margin-top: 6px;
  font-size: 0.58rem;
}

.auth-dialog input {
  width: 100%;
  padding: 13px;
  color: var(--white);
  background: #111;
  border: 2px solid var(--white);
  border-radius: 0;
  font: 0.75rem "Courier New", monospace;
  font-weight: 700;
}

.auth-dialog textarea {
  width: 100%;
  min-height: 108px;
  padding: 13px;
  resize: vertical;
  color: var(--white);
  background: #111;
  border: 2px solid var(--white);
  border-radius: 0;
  font: 0.75rem/1.5 "Courier New", monospace;
  font-weight: 700;
}

.profile-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 28px);
  overflow-y: auto;
}

.profile-avatar-preview {
  width: 112px;
  height: 112px;
  margin: 0 auto 14px;
  overflow: hidden;
  border: 3px solid var(--white);
  background: #111;
}

.profile-avatar-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  image-rendering: pixelated;
}

.avatar-options {
  max-height: 210px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  gap: 8px;
  overflow-y: auto;
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.avatar-option {
  aspect-ratio: 1;
  padding: 3px;
  background: #111;
  border: 2px solid transparent;
  cursor: pointer;
}

.avatar-option:hover,
.avatar-option:focus-visible,
.avatar-option.is-selected {
  border-color: var(--white);
}

.avatar-option img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  image-rendering: pixelated;
}

.custom-avatar-label {
  margin-top: 12px !important;
}

.auth-dialog input[type="file"] {
  padding: 9px;
  font-size: 0.56rem;
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 13px;
  width: 32px;
  height: 32px;
  padding: 0 0 4px;
  color: var(--white);
  background: transparent;
  border: 0;
  font: 1.5rem Arial, sans-serif;
  cursor: pointer;
}

.form-message {
  min-height: 18px;
  margin: 4px 0 0;
  color: #ff4c4c;
  font: 0.64rem/1.5 "Courier New", monospace;
  font-weight: 700;
}

.form-submit {
  margin-top: 8px;
  padding: 15px 16px;
  color: var(--white);
  background: var(--black);
  border: 2px solid var(--white);
  font: inherit;
  font-size: 0.62rem;
  cursor: pointer;
}

.form-submit:hover,
.form-submit:focus-visible {
  color: var(--black);
  background: var(--white);
}

.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: 960px) {
  body {
    padding: 16px;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 8px 24px;
  }

  .brand {
    min-height: 48px;
  }

  .account-actions {
    order: 2;
  }

  .main-nav {
    order: 3;
    width: 100%;
    justify-content: center;
    border-top: 2px solid rgba(255, 255, 255, 0.35);
    padding-top: 8px;
  }

  .community-layout {
    grid-template-columns: 1fr;
  }

  .community-sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 12px 20px;
    align-items: end;
  }

  .community-sidebar label {
    grid-column: 1;
    margin: 0;
  }

  .community-sidebar input {
    grid-column: 1;
  }

  .community-categories {
    grid-column: 2;
    grid-row: 1 / span 2;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
  }

  .story-editor-layout,
  .scene-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  body {
    padding: 10px;
    background-position: center bottom;
  }

  .topbar {
    justify-content: center;
    padding: 12px;
  }

  .brand {
    width: 100%;
    justify-content: center;
  }

  .account-actions {
    margin-left: 0;
  }

  .main-nav {
    flex-wrap: wrap;
    gap: 4px 18px;
  }

  .main-nav a,
  .account-link {
    font-size: 0.55rem;
  }

  .story {
    min-height: calc(100vh - 190px);
    padding-inline: 0;
  }

  .chapter-picker {
    gap: 10px;
  }

  .chapter-button {
    min-width: 0;
    width: min(250px, 56vw);
    padding-inline: 10px;
    gap: 12px;
  }

  .community-page,
  .news-page {
    padding-inline: 8px;
  }

  .community-sidebar {
    display: block;
  }

  .community-sidebar label {
    display: block;
    margin-bottom: 10px;
  }

  .community-categories {
    display: grid;
    grid-template-columns: 1fr;
    margin-top: 24px;
  }

  .community-sidebar,
  .community-post {
    padding: 16px;
  }

  .community-post-meta {
    flex-wrap: wrap;
  }

  .community-post-category {
    margin-left: 0;
  }

  .chapter-page,
  .story-editor-page,
  .about-page {
    padding-inline: 8px;
  }

  .scene-editor-topline {
    display: grid;
  }

  .scene-editor-actions {
    justify-content: start;
  }

  .scene-editor-actions label {
    width: 100%;
  }

  .story-preview-dialog {
    min-height: calc(100vh - 22px);
    padding: 18px;
  }

  .preview-stage {
    min-height: 60vh;
    padding: 20px;
  }

  .layer-numbers {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
