:root {
  --ink: #e6dcc8;
  --ink-muted: #9c8c70;
  --ink-dim: #5c4e3a;
  --accent: #c84b4b;
  --gold: #d4a959;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
  font-family: "Courier New", Courier, monospace;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: pan-x pan-y pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
}

img {
  -webkit-user-drag: none;
  user-select: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

#stage-container {
  position: relative;
  width: min(100vw, 177.78vh);
  height: min(100vh, 56.25vw);
  overflow: hidden;
  flex-shrink: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 95;
  background: radial-gradient(ellipse at 50% 46%, transparent 55%, rgba(0, 0, 0, 0.42) 100%);
}

.content-scene {
  position: absolute;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 65%;
  height: 46%;
  background: transparent;
  color: var(--ink);
  padding: 0 22px clamp(10px, 1.5vh, 16px);
  border: none;
  border-radius: 0;
  text-align: center;
  overflow-y: hidden;
  box-sizing: border-box;
  z-index: 1;
  user-select: text;
  -webkit-user-select: text;
}

@supports not selector(::-webkit-scrollbar) {
  .content-scene {
    scrollbar-width: thin;
    scrollbar-color: var(--ink-dim) transparent;
  }
}

.content-scene::-webkit-scrollbar {
  width: 4px;
}
.content-scene::-webkit-scrollbar-button {
  display: none;
}
.content-scene::-webkit-scrollbar-track {
  background: transparent;
}
.content-scene::-webkit-scrollbar-thumb {
  background: var(--ink-dim);
}

.content-scene h2 {
  position: sticky;
  top: 0;
  z-index: 5;
  flex-shrink: 0;
  margin: 0 0 clamp(6px, 1.1vh, 12px);
  padding: clamp(8px, 1.4vh, 16px) 0 8px;
  background: linear-gradient(to bottom, #000 76%, rgba(0, 0, 0, 0) 100%);
  font-size: clamp(18px, 2.2vh, 22px);
  font-weight: normal;
  letter-spacing: 3px;
  text-transform: lowercase;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(212, 169, 89, 0.2);
}

.content-scene a {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.content-scene a:hover {
  color: var(--accent);
}

.content-scene iframe {
  width: 100%;
  height: 100%;
  padding-top: clamp(8px, 1.4vh, 16px);
  box-sizing: border-box;
  border: none;
  border-radius: 0;
}

.character-slot {
  position: absolute;
  bottom: 7.4%;
  z-index: 2;
}
.character-slot.left { left: 15.6%; }
.character-slot.right { right: 15.6%; }

.character {
  display: block;
  width: auto;
  height: auto;
  max-width: min(10.2vw, 18.1vh);
  max-height: min(23.6vh, 13.3vw);
  animation: floatMove 6.5s ease-in-out infinite alternate;
  cursor: pointer;
  pointer-events: auto;
  will-change: transform;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.75));
}
.character[src*="character7"] {
  image-rendering: pixelated;
}
.character[src*="character8"],
.character[src*="character9"] {
  -webkit-mask-image: linear-gradient(to bottom, #000 74%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 74%, transparent 100%);
}
.character-slot.right .character {
  animation-duration: 7.4s;
  animation-delay: -2.8s;
}

.character[src*="character1"] { --tilt: -6deg; }
.character[src*="character2"] { --tilt: 0deg; }

@keyframes floatMove {
  0% { transform: translate(0, 0) rotate(var(--tilt, 0deg)); }
  50% { transform: translate(8px, -12px) rotate(var(--tilt, 0deg)); }
  100% { transform: translate(-8px, 8px) rotate(var(--tilt, 0deg)); }
}

.speech-bubble {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 150px;
  max-width: 230px;
  padding: 7px 10px;
  background: #0a0907;
  color: var(--ink);
  border: 1px dashed var(--ink-dim);
  border-radius: 0;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 20;
}
.speech-bubble.visible {
  opacity: 1;
}

.movable-curtain {
  position: absolute;
  top: 0;
  width: 60%;
  height: 100%;
  z-index: 40;
  transition: transform 1.1s cubic-bezier(0.7, 0, 0.3, 1);
  pointer-events: none;
  object-fit: fill;
}
.movable-curtain.left { left: -5%; transform: translateX(-120%); }
.movable-curtain.right { right: -5%; transform: translateX(120%); }

.static-curtain {
  position: absolute;
  top: 0;
  left: -2.5%;
  width: 105%;
  height: auto;
  z-index: 45;
  pointer-events: none;
  animation: stageFlicker 8s ease-in-out infinite;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.9));
}

@keyframes stageFlicker {
  0%, 100% { opacity: 0.94; }
  38% { opacity: 0.98; }
  40% { opacity: 0.88; }
  42% { opacity: 0.97; }
  74% { opacity: 0.93; }
  76% { opacity: 0.87; }
  78% { opacity: 0.96; }
}

.gear {
  position: absolute;
  width: 10.4%;
  height: auto;
  bottom: -8.3%;
  z-index: 50;
  pointer-events: none;
  will-change: transform;
  filter: drop-shadow(0 0 18px rgba(0, 0, 0, 0.9));
}
.gear.left {
  right: -5.5%;
}
.gear.right {
  left: -5.5%;
}

.books {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: min(4.2vw, 7.4vh);
  z-index: 4;
  padding-bottom: min(1.8vh, 1vw);
}

.book-btn {
  position: relative;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  outline: none;
}

.book-btn:focus-visible .book-label {
  opacity: 1;
  text-decoration: underline;
}

.clickable-book {
  width: min(9.4vw, 16.7vh);
  height: auto;
  display: block;
  animation: bookFloat 5.2s ease-in-out infinite alternate;
  transition: transform 0.25s ease;
  will-change: transform;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.8));
}
.book-btn:nth-child(2) .clickable-book { animation-duration: 5.8s; animation-delay: -1.4s; }
.book-btn:nth-child(3) .clickable-book { animation-duration: 4.9s; animation-delay: -2.7s; }
.book-btn:nth-child(4) .clickable-book { animation-duration: 6.1s; animation-delay: -3.6s; }

.book-btn:hover .clickable-book {
  transform: scale(1.08);
  animation-play-state: paused;
}

.book-label {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--ink-muted);
  font-family: "Courier New", Courier, monospace;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: lowercase;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
  text-shadow: 0 1px 4px #000;
}

.book-btn:hover .book-label {
  opacity: 1;
  color: var(--ink);
}

.book-btn.active.label-visible .book-label,
.book-btn.active:hover .book-label {
  opacity: 1;
  color: var(--gold);
}
.book-btn.active .book-label::before {
  content: "[ ";
}
.book-btn.active .book-label::after {
  content: " ]";
}

@keyframes bookFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-12px); }
}

.links {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}
.links a {
  color: var(--ink);
  font-size: 26px;
  text-decoration: none;
}
.links a:hover {
  color: var(--accent);
}

.mal-icon {
  display: block;
  opacity: 0.9;
}
.mal-icon:hover {
  filter: brightness(0) saturate(100%) invert(39%) sepia(47%) saturate(1352%) hue-rotate(322deg) brightness(92%) contrast(90%);
}

.about-template {
  max-width: 720px;
  margin: 0 auto;
}
.about-template .tagline {
  font-size: 15px;
  color: var(--ink-muted);
  margin: 0 0 10px;
  font-style: italic;
}
.about-template p {
  margin: 6px 0;
  font-size: 15px;
  line-height: 1.5;
}

.exp-footer {
  padding-top: clamp(6px, 1.1vh, 12px);
  border-top: 1px dashed var(--ink-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.exp-footer-label {
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: lowercase;
  color: var(--ink-muted);
  white-space: nowrap;
}

.exp-squares {
  display: flex;
  gap: 14px;
  align-items: center;
}

.exp-square {
  position: relative;
  width: clamp(30px, 3.8vh, 38px);
  height: clamp(30px, 3.8vh, 38px);
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
}

.exp-square:focus-visible {
  outline: 1px dashed var(--gold);
  outline-offset: 4px;
}

.exp-logo {
  width: clamp(28px, 3.5vh, 36px);
  height: clamp(28px, 3.5vh, 36px);
  object-fit: contain;
  filter: grayscale(100%) sepia(40%) brightness(0.88) contrast(1.05);
  opacity: 0.82;
  transition: filter 0.2s ease, opacity 0.2s ease;
}

.exp-square:hover .exp-logo,
.exp-square:focus-visible .exp-logo {
  filter: grayscale(20%) sepia(25%) brightness(1.05);
  opacity: 1;
}

.exp-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #0a0907;
  color: var(--ink);
  border: 1px solid var(--ink-dim);
  padding: 5px 10px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 30;
}

.exp-tooltip strong {
  color: var(--gold);
}

.exp-square:hover .exp-tooltip,
.exp-square:focus-visible .exp-tooltip {
  opacity: 1;
}

.discord-profile {
  width: min(310px, 100%);
  margin: 16px auto 0;
  background: #0a0907;
  border: 1px solid var(--ink-dim);
  text-align: left;
  overflow: hidden;
}

.discord-profile-banner {
  width: 100%;
  height: 76px;
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid var(--ink-dim);
}

.discord-profile-body {
  position: relative;
  padding: 0 14px 12px;
}

.discord-avatar-wrap {
  position: relative;
  width: 58px;
  height: 58px;
  margin-top: -29px;
  margin-bottom: 6px;
}

.discord-avatar {
  width: 58px;
  height: 58px;
  border-radius: 0;
  border: 3px solid #0a0907;
  outline: 1px solid var(--ink-dim);
  display: block;
  object-fit: cover;
  box-sizing: border-box;
}

.discord-status-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 13px;
  height: 13px;
  border-radius: 0;
  border: 2px solid #0a0907;
  box-sizing: border-box;
}

.discord-username {
  font-size: 15px;
  font-weight: bold;
  color: var(--ink);
}

.discord-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
}

.discord-handle {
  font-size: 12px;
  color: var(--ink-muted);
}

.discord-status-text {
  font-size: 11px;
  text-transform: lowercase;
}

.discord-activity-box {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--ink-dim);
}

.discord-activity-title {
  font-size: 12px;
  font-weight: bold;
  color: var(--ink);
  word-break: break-word;
}

.discord-activity-sub {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 2px;
  line-height: 1.4;
  word-break: break-word;
}

.projects-board {
  max-width: 1020px;
  margin: 0 auto;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.5vh, 16px);
  padding-bottom: 2px;
}

.projects-spread {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.22fr);
  gap: clamp(16px, 2.2vw, 28px);
}

.projects-col-left,
.projects-active-row {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.2vh, 14px);
}

.projects-col-right {
  border-left: 1px dashed var(--ink-dim);
  padding-left: clamp(14px, 1.8vw, 24px);
}

.project-group {
  margin: 0;
}

.group-title {
  margin: 0 0 clamp(3px, 0.6vh, 6px);
  padding-bottom: 3px;
  border-bottom: 1px solid var(--ink-dim);
  font-size: clamp(11px, 1.3vh, 13px);
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: lowercase;
  color: var(--gold);
}

.project-group.on-hold .group-title {
  color: #c89d66;
}

.project-group.skills .group-title {
  color: #cbb794;
}

.project-group.dropped .group-title {
  color: var(--ink-muted);
}

.project-list,
.skill-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.project-row,
.skill-row {
  padding: clamp(3px, 0.55vh, 5px) 0;
  border-bottom: 1px dashed rgba(156, 140, 112, 0.2);
  font-size: clamp(11.5px, 1.4vh, 13.5px);
  line-height: 1.38;
}

.skill-row {
  padding: clamp(2.5px, 0.45vh, 4.5px) 0;
  font-size: clamp(11px, 1.32vh, 13px);
  line-height: 1.36;
}

.project-row:last-child,
.skill-row:last-child {
  border-bottom: none;
}

.project-name,
.skill-category {
  font-weight: bold;
  color: var(--ink);
}

.skill-category {
  text-transform: lowercase;
}

.skill-items {
  color: #c8bda8;
}

.project-year {
  margin-left: 6px;
  font-size: 11.5px;
  color: var(--ink-dim);
  white-space: nowrap;
}

.project-group.dropped .project-name {
  color: var(--ink-muted);
}

.project-sep {
  color: var(--ink-dim);
  margin: 0 6px;
}

.project-desc {
  color: #c8bda8;
}

.project-group.dropped .project-desc {
  color: var(--ink-muted);
}

.project-ext {
  margin-left: 8px;
  font-size: 12px;
  white-space: nowrap;
}

.project-sublist {
  list-style: none;
  margin: 3px 0 1px 14px;
  padding: 0;
}

.project-subrow {
  padding: 2px 0;
  font-size: clamp(11px, 1.3vh, 12.5px);
  line-height: 1.35;
}

.sub-branch {
  color: var(--ink-dim);
  margin-right: 6px;
  user-select: none;
}

.message-form {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.message-form input,
.message-form textarea {
  width: min(440px, 90%);
  padding: 9px 11px;
  border-radius: 0;
  border: 1px solid var(--ink-dim);
  background: rgba(0, 0, 0, 0.55);
  color: var(--ink);
  font-family: "Courier New", Courier, monospace;
  font-size: 14px;
  box-sizing: border-box;
}
.message-form textarea {
  min-height: 76px;
  resize: vertical;
}
.message-form input:focus,
.message-form textarea:focus {
  outline: none;
  border-color: var(--gold);
}
.message-form input::placeholder,
.message-form textarea::placeholder {
  color: var(--ink-muted);
}
.message-form button {
  padding: 9px 22px;
  border-radius: 0;
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  font-family: "Courier New", Courier, monospace;
  font-size: 14px;
  letter-spacing: 1px;
  text-transform: lowercase;
}
.message-form button:hover:not(:disabled) {
  background: var(--gold);
  color: #000;
}
.message-form button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.form-status {
  margin-top: 12px;
  font-size: 14px;
}

@media (max-width: 720px) {
  .projects-spread {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .projects-col-right {
    border-left: none;
    padding-left: 0;
  }
}

@media (orientation: portrait) {
  #stage-container {
    width: 100vw;
    height: 100dvh;
  }

  .static-curtain {
    -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
    mask-image: linear-gradient(to bottom, #000 72%, transparent 100%);
  }

  .content-scene {
    width: 76%;
    top: calc(13vw + 4px);
    bottom: 108px;
    height: auto !important;
    max-height: none;
    transform: translateX(-50%);
    padding: 0 12px 10px;
    display: flex;
    flex-direction: column;
  }

  .content-scene > * {
    flex-shrink: 0;
  }

  .content-scene h2 {
    font-size: 18px;
    margin-bottom: 4px;
    padding: 6px 0 8px;
  }

  .content-scene iframe {
    width: 100%;
    height: auto !important;
    aspect-ratio: 16 / 9;
    padding-top: 0;
    margin: auto 0;
  }

  .about-template,
  .projects-board {
    width: 100%;
  }

  .links a { font-size: 24px; }
  .mal-icon { width: 24px; height: 24px; }

  .character-slot { bottom: 112px; }
  .character-slot.left { left: 4px; }
  .character-slot.right { right: 4px; }
  .character {
    max-width: 11.5vw;
    max-height: 13vh;
  }
  .speech-bubble {
    font-size: 12px;
    min-width: 130px;
    max-width: 190px;
    padding: 6px 8px;
  }

  .books {
    gap: 14px;
    bottom: 24px;
    padding-bottom: 0;
    z-index: 30;
    width: 100%;
    justify-content: center;
  }
  .clickable-book { width: 17vw; max-width: 78px; }
  .book-label { font-size: 12px; top: -18px; }

  .gear { width: 20vw; max-width: 96px; bottom: -10vw; }
  .gear.left { right: -10vw; }
  .gear.right { left: -10vw; }

  .projects-board {
    gap: 8px;
  }
  .projects-spread {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .projects-col-left {
    gap: 6px;
  }
  .projects-active-row {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 14px;
  }
  .projects-col-right {
    border-left: none;
    padding-left: 0;
  }
  .group-title {
    font-size: 11px;
    margin-bottom: 3px;
    padding-bottom: 2px;
  }
  .project-row,
  .skill-row {
    font-size: 11px;
    padding: 2.5px 0;
    line-height: 1.3;
  }
  .project-sublist {
    margin: 2px 0 1px 10px;
  }
  .project-subrow {
    font-size: 10.5px;
    padding: 1px 0;
    line-height: 1.28;
  }
  .exp-footer {
    flex-direction: row;
    padding-top: 6px;
    gap: 10px;
  }
  .exp-square { width: 28px; height: 28px; }
  .exp-logo { width: 26px; height: 26px; }
}

@media (orientation: portrait) and (max-width: 560px) {
  .content-scene {
    width: 82%;
    top: calc(22vw + 4px);
    bottom: 122px;
    padding: 0 12px 2px;
  }
  .character-slot.left { left: 6px; }
  .character-slot.right { right: 6px; }
  .character {
    max-width: 15vw;
    max-height: 11vh;
  }
  .projects-board {
    gap: 6px;
    padding-bottom: 0;
  }
  .projects-spread {
    gap: 6px;
  }
  .projects-active-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  .project-row,
  .skill-row {
    font-size: 11px;
    padding: 2px 0;
    line-height: 1.3;
  }
  .project-subrow {
    font-size: 10.5px;
  }
  .exp-footer {
    flex-direction: row;
    padding-top: 5px;
    gap: 10px;
  }
}
