:root {
  --bg:       #0d1112eb;
  --bg-panel: #111216eb;
  --border:   #2a2838;
  --text:     #8888a8;
  --text-dim: #4a4860;
  --link:     #6b7968;
  --accent:   #b84040;
  --link-hover: #c09489;
}

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

body {
  font-family: "Courier New", Courier, monospace;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background-color: #000;
  /* background-image: url("/img/site/tenshi-no-tamago-view.jpg"); */
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

a {
  color: var(--link);
  text-decoration: none;

  &:hover {
    color: var(--link-hover);
  }
}

/* site wrapper */

.site-wrapper {
  max-width: 720px;
  width: 100%;
  margin: 24px 0;
}

/* site sidebar */

.site-sidebar {
  position: fixed;
  left: min(calc(50% + 360px + 16px), calc(100vw - 160px - 16px));
  top: 50%;
  transform: translateY(-50%);
  width: 160px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  font-size: 13px;
  overflow: visible;
  z-index: 20;
}

.site-title {
  color: var(--text);
  font-size: 13px;
  font-weight: normal;
}

/* site footer */

.site-footer {
  background: var(--bg);
  border: 1px solid var(--border);
  margin-top: 16px;
  padding: 16px 28px;
  font-size: 13px;
  color: var(--text-dim);
}

.footer-updated {
  color: var(--accent);
  display: block;
  text-align: center;
  letter-spacing: 1px;
}

/* sidebar controls */

.sidebar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  color: var(--text-dim);
  background: none;
  border: 1px solid transparent;
  padding: 6px 8px;
  width: 5em;
  height: 2em;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;

  &:hover {
    color: var(--text);
    border-color: var(--border);
  }
}

.palette-dropdown {
  position: relative;
}

.palette-dropdown.open .sidebar-btn {
  color: var(--text);
  border-color: var(--border);
}

.palette-preview {
  display: flex;
  gap: 3px;
}

.pd {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: block;
}

.palette-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  min-width: 180px;
  z-index: 10;
}

.palette-dropdown.open .palette-menu {
  display: block;
}

.palette-menu li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.1s, background 0.1s;

  &:hover {
    color: var(--text);
    background: var(--bg-panel);
  }

  &.active {
    color: var(--link);
  }
}

.palette-item-dots {
  display: flex;
  gap: 3px;
}

/* nav */

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;

  a {
    display: block;
    padding-left: 14px;
    position: relative;

    &::before {
      content: "";
      position: absolute;
      left: 0;
    }

    &:hover::before,
    &.current::before {
      content: "▸";
      color: var(--accent);
    }
  }
}

/* content */

.content {
  padding: 28px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  position: relative;

  h1 {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 24px;
    color: var(--text);
    text-align: center;
  }

  h2 {
    font-size: 16px;
    font-weight: bold;
    margin-top: 32px;
    margin-bottom: 16px;
    color: var(--text);
  }

  p {
    margin-bottom: 16px;

    &:last-child {
      margin-bottom: 0;
    }
  }

  hr {
    border: none;
    text-align: center;
    margin: 32px 0;
    color: var(--text-dim);

    &::before {
      content: "· · ·";
    }
  }

  ul, ol {
    margin-bottom: 16px;
    padding-left: 20px;
  }
}

/* status */

.status {
  margin-bottom: 24px;
  padding: 12px 16px;
  border-left: 2px solid var(--accent);
  background: var(--bg);
}

.status-label {
  display: block;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: bold;
}

.status-list {
  list-style: none;
  padding-left: 0;
  font-size: 14px;
}

.status-list li {
  margin-bottom: 4px;

  &:last-child {
    margin-bottom: 0;
  }
}

.status-kind {
  color: var(--text-dim);
}

/* social panel */

.social {
  background: var(--bg);
  border: 1px solid var(--border);
  margin-top: 16px;
  padding: 16px 28px;
}

/* 88x31 buttons */

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;

  img {
    display: block;
    image-rendering: pixelated;
  }
}

/* vn scene */

.vn-scene {
  display: flex;
  flex-direction: column;
  user-select: none;
  border: 1px solid var(--border);
  background: #0a0a10;
  background-size: cover;
  background-position: center;
  margin-bottom: 16px;
  overflow: hidden;
  min-height: 300px;
  padding: 0 16px 16px;
  position: relative;
}

.vn-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.vn-bg.active {
  opacity: 1;
}

.vn-speaker {
  margin-top: auto;
  display: flex;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.vn-portrait {
  transition: opacity 0.3s ease;
}

.vn-portrait.fade,
.vn-portrait.hidden {
  opacity: 0;
}

.vn-name.visitor {
  color: var(--link);
}

.vn-name:empty {
  display: none;
}

.vn-dialogue-wrap {
  position: relative;
  z-index: 1;
}

.vn-name {
  font-size: 13px;
  color: var(--accent);
  font-weight: bold;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 12px;
}

.vn-dialogue.narrator p {
  font-style: italic;
}

.vn-dialogue {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 16px 20px;
  min-height: 120px;
  overflow-y: auto;
  position: relative;
  cursor: pointer;

  &::after {
    content: "▼";
    position: absolute;
    bottom: 10px;
    right: 14px;
    font-size: 10px;
    color: var(--accent);
    animation: blink 1.2s step-end infinite;
  }

  &.has-choices,
  &.ended {
    cursor: default;

    &::after {
      display: none;
    }
  }

  &.typing::after {
    display: none;
  }

  p {
    margin-bottom: 0;
  }
}

.vn-choices:empty {
  display: none;
}

.vn-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.vn-choice-btn {
  display: block;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 8px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;

  &::before {
    content: "▸ ";
    color: var(--accent);
  }

  &:hover {
    color: var(--link-hover);
    border-color: var(--accent);
    background: var(--bg);
  }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* home gallery */

.home-gallery {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;

  img {
    height: 160px;
    width: auto;
    display: block;
  }
}

/* shrines */

.shrine-list {
  list-style: none;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shrine-card a {
  font-weight: bold;
}

.shrine-desc {
  color: var(--text-dim);
  margin-left: 8px;
  font-size: 14px;
}

/* responsive */

@media (max-width: 1080px) {
  .site-wrapper {
    margin: 12px auto;
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .site-sidebar {
    position: static;
    left: auto;
    top: auto;
    transform: none;
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
    order: -1;
    border-left: none;
    border-right: none;

  }

  .nav-links {
    flex-direction: row;
    gap: 12px;

    a {
      padding-left: 0;
      text-align: center;

      &::before {
        display: none;
      }

      &::after {
        content: "";
        display: block;
        height: 0;
        color: var(--accent);
      }

      &:hover::after,
      &.current::after {
        content: "▴";
        height: auto;
      }
    }
  }

  .palette-menu {
    left: auto;
    right: 0;
  }

  .content,
  .social,
  .site-footer {
    border-left: none;
    border-right: none;
  }
}
