@font-face {
  font-family: "FusionPixel";
  src: url("assets/fonts/fusion-pixel-12px-proportional-zh_hans.woff2") format("woff2");
  font-display: swap;
}

:root {
  --font-pixel: "FusionPixel", "Zpix", "Courier New", monospace;
  --ink: #241d15;
  --ink-soft: #5f5443;
  --paper: #e9dec2;
  --paper-2: #ddd0ae;
  --orange: #c8622b;
  --red: #a93a2e;
  --cream: #f1e6cb;
  --notes-w: 408px;
  --case-h: min(92dvh, 920px);
}

* { box-sizing: border-box; }

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

body {
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 38%, #183030 0%, #0e1d1e 55%, #070f10 100%);
  color: #cfdcd3;
  font-family: var(--font-pixel);
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(120, 170, 150, .05), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(190, 130, 70, .04), transparent 45%);
  pointer-events: none;
}

.page-grain {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: .5;
  background-image: radial-gradient(rgba(230, 240, 225, .09) .7px, transparent .8px);
  background-size: 3px 3px;
  mix-blend-mode: soft-light;
}

.env {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.env__trees {
  position: absolute;
  inset: -2px;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  display: block;
}
.env-desk {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 19dvh;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(214, 160, 102, .34) 0 1px, transparent 2px 7px, rgba(0, 0, 0, .34) 8px, transparent 15px),
    repeating-linear-gradient(90deg, transparent 0 118px, rgba(0, 0, 0, .22) 118px 119px, rgba(122, 82, 48, .16) 119px 121px, transparent 121px 240px),
    repeating-linear-gradient(180deg, #2c1d13 0 2px, #271910 2px 4px, #2f2015 4px 7px, #251810 7px 9px);
  box-shadow:
    inset 0 3px 0 rgba(166, 112, 66, .3),
    inset 0 16px 34px rgba(0, 0, 0, .5),
    inset 0 -40px 60px rgba(0, 0, 0, .35);
}
.env-desk::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 226, 180, .1) 1px, transparent 1.2px);
  background-size: 5px 4px;
  opacity: .35;
}
.env-vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(118% 94% at 50% 40%, transparent 44%, rgba(4, 10, 10, .26) 73%, rgba(2, 6, 7, .62) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, .2) 0, transparent 20%, transparent 76%, rgba(0, 0, 0, .34) 100%);
}

.brand {
  position: fixed;
  top: 26px;
  left: 28px;
  z-index: 20;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  pointer-events: none;
}
.brand__stripe {
  width: 7px;
  height: 62px;
  background: var(--orange);
  box-shadow: inset -2px 0 0 rgba(0, 0, 0, .25);
}
.brand__title {
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: 3px;
  color: #efe3c4;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .45);
}
.brand__sub {
  margin-top: 8px;
  font-size: 10px;
  line-height: 1.7;
  letter-spacing: 1.2px;
  color: #9fb1a6;
}

.now {
  position: fixed;
  top: 30px;
  right: 30px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 1.4px;
  color: #94a79b;
  pointer-events: none;
}
.now__led {
  width: 6px;
  height: 6px;
  background: #38423d;
  box-shadow: inset 0 0 0 1px #1a211e;
}
.now__led.is-on {
  background: #ff8a4c;
  box-shadow: 0 0 6px rgba(255, 138, 76, .7);
}
.now__label { color: #6d7f74; }
.now__title {
  color: #e7d9b8;
  max-width: 200px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.app {
  position: relative;
  z-index: 2;
  height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 20px 58px;
}

.rig {
  display: flex;
  align-items: center;
  gap: 18px;
  transform: translateX(calc(var(--notes-w) / 2 + 9px));
  transition: transform .62s cubic-bezier(.22, .8, .24, 1);
}
.app.is-open .rig {
  transform: translateX(0);
}

.console {
  flex: 0 0 auto;
}

.case-shell {
  height: var(--case-h);
  aspect-ratio: 260 / 420;
  transition: transform .55s cubic-bezier(.22, .8, .24, 1);
  touch-action: manipulation;
}

#machine {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  user-select: none;
}

#machine text {
  font-family: var(--font-pixel);
  paint-order: stroke fill;
}

/* ---------- 机器交互 ---------- */

.hot {
  cursor: pointer;
  outline: none;
}
.hot:hover .hover-ring,
.hot:focus-visible .hover-ring {
  opacity: .5;
}
.hot:focus-visible {
  filter: brightness(1.18);
}
.hot:hover .hover-ring {
  transition: opacity .15s;
}

.btn {
  transition: transform .07s ease-out, filter .12s;
}
.btn:hover { filter: brightness(1.12); }
.btn:hover .btn-face { fill: #495655; }
.btn.is-pressed {
  transform: translateY(1.2px);
  filter: brightness(.9);
}
.btn.is-pressed .btn-face {
  fill: #2c3535;
}

#volWheel { cursor: ns-resize; touch-action: none; }
#volWheelRidges { transform-origin: 96px 234px; transform-box: view-box; transition: transform .12s ease-out; }

#powerBtn:hover .hover-ring { opacity: .8; }

#browsePrev:hover path,
#browseNext:hover path { fill: #ffcf87; }
#browsePrev:active, #browseNext:active { transform: translateY(1px); }

#lidTape { cursor: grab; }
#lidTape:hover .hover-ring { opacity: .55; }
#lidTape:active { cursor: grabbing; }

#charm { cursor: pointer; }
#charm.is-wiggle {
  animation: charm-wiggle .55s ease-in-out;
  transform-box: fill-box;
  transform-origin: 80% 10%;
}
@keyframes charm-wiggle {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(7deg); }
  45% { transform: rotate(-5deg); }
  70% { transform: rotate(3deg); }
}

#powerLed.is-on {
  fill: #ff8b50;
  filter: drop-shadow(0 0 2px #ff8b50);
}
#powerLedGlow.is-on {
  opacity: 1;
  animation: led-breathe 3.4s ease-in-out infinite;
}
@keyframes led-breathe {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}

#lcd .px { fill: #ffb15c; }
#lcd .px.dim { opacity: .065; }
.lcd-scan {
  animation: lcd-flicker 4.6s steps(2, end) infinite;
}
@keyframes lcd-flicker {
  0%, 96%, 100% { opacity: .12; }
  97% { opacity: .04; }
  98% { opacity: .16; }
}

/* 卷盘 */
.reel-spin {
  transform-box: fill-box;
  transform-origin: center;
}
#machine.is-spinning .reel-spin {
  animation: reel-spin 2.1s linear infinite;
}
#machine.is-fast .reel-spin {
  animation-duration: .3s;
}
#machine.is-spinning .wound {
  transition: r .18s linear;
}
@keyframes reel-spin {
  to { transform: rotate(360deg); }
}

/* 磁带装卸 */
.tape-anim {
  transform-box: fill-box;
  transform-origin: center;
}
.tape-anim.is-ejecting {
  animation: tape-eject .34s cubic-bezier(.4, 0, .9, .6) forwards;
}
.tape-anim.is-inserting {
  animation: tape-insert .4s cubic-bezier(.2, .9, .3, 1) forwards;
}
@keyframes tape-eject {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-16px); }
}
@keyframes tape-insert {
  0% { opacity: 0; transform: translateY(-14px); }
  70% { opacity: 1; transform: translateY(1px); }
  100% { opacity: 1; transform: translateY(0); }
}
.tape-anim.is-hidden {
  opacity: 0;
}
.app.is-open .notes {
  opacity: 1;
  transform: translateX(0) rotate(-1.1deg);
  pointer-events: auto;
}

.shot {
  margin: 0 0 26px;
}
.shot figcaption {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 7px;
  font-size: 8px;
  letter-spacing: 1.2px;
  color: #7d6a4d;
}

.tracks { margin-bottom: 26px; }
.track-list .no {
  color: var(--orange);
  letter-spacing: 1px;
}

.credits { margin-bottom: 26px; }
.credits p {
  margin: 0;
  font-size: 10px;
  line-height: 1.95;
  letter-spacing: .4px;
  color: #4d3f2c;
}
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-bottom: 22px;
}
.links a {
  color: #3a2f20;
  font-size: 10px;
  letter-spacing: 1.4px;
  text-decoration: none;
  border-bottom: 1px solid rgba(58, 47, 32, .5);
  padding-bottom: 2px;
}
.links a:hover {
  color: var(--orange);
  border-color: var(--orange);
}
.serial {
  margin: 0;
  font-size: 8px;
  letter-spacing: 1.6px;
  color: #7d6a4d;
}

/* ---------- 状态栏 ---------- */

.statusbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: 46px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  font-size: 9px;
  letter-spacing: 1.2px;
  color: #9db0a4;
  background: linear-gradient(to top, rgba(5, 11, 11, .92), rgba(5, 11, 11, .55) 60%, transparent);
  pointer-events: none;
}
.statusbar__left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.statusbar__left #hint {
  color: #d8c9a8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.statusbar__dot {
  width: 5px;
  height: 5px;
  background: #4d5a52;
  flex: 0 0 auto;
}
.statusbar__dot.is-on {
  background: #d98a4e;
  box-shadow: 0 0 5px rgba(217, 138, 78, .75);
}
.statusbar__right {
  display: flex;
  gap: 8px;
  align-items: center;
  color: #7d8f84;
}
.statusbar__sep { opacity: .4; }

/* ---------- 响应式 ---------- */

@media (max-width: 1240px) {
  :root { --notes-w: 372px; }
  .brand__title { font-size: 19px; }
}

@media (max-width: 980px) {
  :root { --case-h: min(90dvh, 820px); }
}

@media (max-width: 900px) {
  .app {
    padding: 14px 12px 52px;
    align-items: center;
  }
  .rig,
  .app.is-open .rig {
    transform: none !important;
    flex-direction: column;
  }
  .case-shell {
    height: min(94dvh, 760px);
  }
  .app.is-open .case-shell {
    transform: translateY(-7dvh) scale(.86);
  }
  .notes {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    height: min(64dvh, 620px);
    opacity: 0;
    transform: translateY(calc(100% + 26px)) rotate(0deg);
    pointer-events: none;
    z-index: 40;
  }
  .app.is-open .notes {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
    pointer-events: auto;
  }
  .paper { transform: rotate(-.5deg); }
  .notes-scroll { padding: 36px 26px 38px 34px; }
  .sheet-title { font-size: 32px; }
  .sheet-row { padding-right: 66px; }
  .brand {
    top: 14px;
    left: 14px;
    transform: scale(.82);
    transform-origin: top left;
  }
  .now {
    top: 16px;
    right: 14px;
    font-size: 9px;
    max-width: 44vw;
  }
  .now__title { max-width: 110px; }
  .statusbar {
    height: 42px;
    padding: 0 14px;
    font-size: 8px;
  }
  .statusbar__right { display: none; }
  .page-grain { opacity: .35; }
}

@media (max-width: 560px) {
  .brand__title { font-size: 17px; }
  .brand__sub { font-size: 8px; margin-top: 6px; }
  .brand__stripe { height: 50px; width: 6px; }
  .case-shell { height: min(88dvh, 700px); }
  .app.is-open .case-shell { transform: translateY(-9dvh) scale(.8); }
  .notes { height: min(62dvh, 560px); left: 6px; right: 6px; bottom: 6px; }
  .notes-scroll { padding: 34px 20px 34px 28px; }
  .sheet-title { font-size: 29px; letter-spacing: 2px; }
  .sheet-meta { gap: 6px; }
  .sheet-meta strong { font-size: 10px; }
}

@media (max-width: 470px) {
  .case-shell {
    height: min(84dvh, calc((100vw - 24px) * 1.6154));
  }
}

@media (max-height: 620px) and (min-width: 901px) {
  :root { --notes-w: 360px; --case-h: min(96dvh, 620px); }
  .brand__sub { display: none; }
  .notes { height: 88dvh; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- 衬纸标签 / 闲置动效 ---------- */

.console { position: relative; }
.app.is-open .notes-tab {
  opacity: 0;
  pointer-events: none;
  transform: translateX(16px) rotate(2deg);
  animation: none;
}
@keyframes tabFloat {
  50% { transform: rotate(2.3deg) translateY(-3px); }
}

body.room-open #lidTape {
  animation: tapeBob 5.4s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
@keyframes tapeBob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-1.6px) rotate(-.8deg); }
}

@media (max-width: 900px) {
  .notes-tab {
    top: 50%;
    right: calc(13.1% - 22px);
    padding: 10px 6px 8px;
    transform: rotate(1deg) scale(.9);
  }
  .notes-tab__cn { font-size: 11px; }
}
