:root {
  color-scheme: light;
  --case: #8b92ad;
  --case-dark: #5d637a;
  --ink: #181818;
  --paper: #f8f8f8;
  --line: #202020;
  --lcd: #c9d79f;
  --lcd-2: #aab879;
  --desk: #7d5c3e;
  --desk-dark: #4a3323;
  --green: #9bddad;
  --yellow: #f6d66f;
  --red: #ef8178;
}

* {
  box-sizing: border-box;
}

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

body {
  align-items: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.08), transparent 34%),
    #252835;
  color: var(--ink);
  display: flex;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  justify-content: center;
  margin: 0;
  min-height: 100dvh;
  padding: 14px;
}

a {
  color: inherit;
  text-decoration: none;
}

.gb {
  background: var(--case);
  border: 4px solid #d8dbe8;
  border-bottom-color: var(--case-dark);
  border-radius: 14px 14px 34px 14px;
  box-shadow:
    inset -7px -9px 0 rgba(0, 0, 0, 0.14),
    inset 5px 5px 0 rgba(255, 255, 255, 0.2),
    0 18px 50px rgba(0, 0, 0, 0.42);
  display: grid;
  gap: 12px;
  max-width: 640px;
  padding: 14px;
  width: min(100%, 640px);
}

.gb-top {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto auto;
}

.gb-top strong,
.gb-top span,
.gb-top a {
  background: var(--paper);
  border: 3px solid var(--line);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.18);
  display: inline-flex;
  font-size: 13px;
  font-weight: 900;
  justify-content: center;
  line-height: 1;
  min-height: 36px;
  padding: 9px 10px;
}

.gb-top strong {
  justify-content: flex-start;
}

.gb-top span {
  background: var(--yellow);
}

.gb[data-state="working"] .gb-top span {
  background: var(--green);
}

.gb[data-state="blocked"] .gb-top span {
  background: var(--red);
}

.screen {
  background: #4b5263;
  border: 5px solid #252a36;
  border-radius: 9px 9px 24px 9px;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.08);
  padding: 12px;
}

.scene {
  background: var(--lcd);
  border: 4px solid #111;
  height: clamp(278px, 58vw, 360px);
  image-rendering: pixelated;
  overflow: hidden;
  position: relative;
}

.wall,
.floor {
  inset-inline: 0;
  position: absolute;
}

.wall {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.1) 1px, transparent 1px),
    linear-gradient(#b9c88f, #b9c88f);
  background-size: 34px 34px, auto;
  border-bottom: 4px solid #6c7650;
  height: 45%;
  top: 0;
}

.floor {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.14) 1px, transparent 1px),
    linear-gradient(0deg, rgba(0, 0, 0, 0.14) 1px, transparent 1px),
    repeating-linear-gradient(45deg, #cbd99f 0 9px, var(--lcd-2) 9px 13px);
  background-size: 24px 24px, 24px 24px, 24px 24px;
  bottom: 0;
  height: 55%;
}

.desk {
  bottom: 32%;
  height: 118px;
  left: 8%;
  position: absolute;
  width: 45%;
  z-index: 2;
}

.desk::before,
.desk::after {
  background: var(--desk-dark);
  bottom: 0;
  content: "";
  height: 38px;
  position: absolute;
  width: 12px;
}

.desk::before {
  left: 20px;
}

.desk::after {
  right: 28px;
}

.monitor {
  background: #ececec;
  border: 4px solid #111;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.22);
  height: 78px;
  left: 18px;
  position: absolute;
  top: 0;
  width: 112px;
}

.monitor::before {
  background: #111;
  bottom: -16px;
  content: "";
  height: 8px;
  left: 40px;
  position: absolute;
  width: 32px;
}

.monitor::after {
  background: var(--desk);
  border: 4px solid #111;
  bottom: -39px;
  content: "";
  height: 16px;
  left: -18px;
  position: absolute;
  width: 190px;
}

.monitor i {
  background: #1e2533;
  border: 4px solid #6f7890;
  display: block;
  height: 42px;
  left: 11px;
  position: absolute;
  top: 10px;
  width: 82px;
}

.monitor span {
  background: #a7ef9b;
  height: 5px;
  left: 23px;
  opacity: 0.9;
  position: absolute;
  width: 54px;
  z-index: 1;
}

.monitor span:nth-child(2) {
  top: 22px;
}

.monitor span:nth-child(3) {
  top: 34px;
  width: 42px;
}

.monitor span:nth-child(4) {
  top: 46px;
  width: 62px;
}

.keyboard {
  background: #dfdfdf;
  border: 4px solid #111;
  bottom: 20px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(6, 1fr);
  left: 28px;
  padding: 5px;
  position: absolute;
  width: 136px;
  z-index: 3;
}

.keyboard b {
  background: #2d3340;
  display: block;
  height: 8px;
}

.trainer {
  bottom: 21%;
  height: 150px;
  position: absolute;
  right: 19%;
  width: 132px;
  z-index: 4;
}

.trainer-sprite {
  background-image: url("/assets/pokemon-yellow/extracted/sacha-overworld-work.png?v=20260705-overworld-pc-v1");
  background-position: 0 0;
  background-repeat: no-repeat;
  background-size: 32px 16px;
  bottom: 42px;
  display: block;
  height: 16px;
  image-rendering: pixelated;
  position: absolute;
  right: 28px;
  transform: scale(6);
  transform-origin: right bottom;
  width: 16px;
  z-index: 2;
}

.shadow {
  background: rgba(0, 0, 0, 0.26);
  bottom: 36px;
  height: 12px;
  left: 28px;
  position: absolute;
  width: 92px;
  z-index: 1;
}

.nameplate {
  background: #f8f8f8;
  border: 3px solid #111;
  bottom: 2px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.16);
  color: #111;
  font-size: 11px;
  left: 18px;
  line-height: 1;
  padding: 5px 7px;
  position: absolute;
  z-index: 6;
}

.work-pixel {
  background: #fff36f;
  box-shadow: 10px 8px 0 #ff4b33, 20px 0 0 #111;
  height: 7px;
  opacity: 0;
  position: absolute;
  width: 7px;
  z-index: 5;
}

.p1 {
  left: -10px;
  top: 46px;
}

.p2 {
  left: 6px;
  top: 72px;
}

.p3 {
  left: 14px;
  top: 34px;
}

.gb[data-state="working"] .trainer-sprite {
  animation:
    overworld-frame 640ms steps(1, end) infinite,
    trainer-work 820ms steps(2, end) infinite;
}

.gb[data-state="ready"] .trainer-sprite {
  animation: trainer-idle 1550ms steps(2, end) infinite;
}

.gb[data-state="working"] .monitor i {
  animation: screen-pulse 680ms steps(2, end) infinite;
}

.gb[data-state="working"] .monitor span {
  animation: code-line 900ms steps(2, end) infinite;
}

.gb[data-state="working"] .monitor span:nth-child(3) {
  animation-delay: 120ms;
}

.gb[data-state="working"] .monitor span:nth-child(4) {
  animation-delay: 240ms;
}

.gb[data-state="working"] .keyboard b {
  animation: key-press 520ms steps(2, end) infinite;
}

.gb[data-state="working"] .keyboard b:nth-child(2n) {
  animation-delay: 120ms;
}

.gb[data-state="working"] .keyboard b:nth-child(3n) {
  animation-delay: 240ms;
}

.gb[data-state="working"] .work-pixel {
  animation: work-pixel 980ms steps(3, end) infinite;
}

.gb[data-state="working"] .p2 {
  animation-delay: 180ms;
}

.gb[data-state="working"] .p3 {
  animation-delay: 360ms;
}

.gb[data-state="blocked"] .monitor i {
  background: #4f1717;
}

.gb[data-state="blocked"] .trainer-sprite {
  filter: sepia(0.4) saturate(0.9);
}

.text-box {
  background: var(--paper);
  border: 4px solid #111;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.22);
  margin-top: 10px;
  min-height: 70px;
  padding: 9px 10px;
}

.text-box p,
.text-box small {
  display: block;
  line-height: 1.25;
  margin: 0;
}

.text-box p {
  font-size: clamp(16px, 4.2vw, 22px);
  font-weight: 900;
  min-height: 1.25em;
}

.text-box small {
  color: #4b4b4b;
  font-size: 12px;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.hud {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
}

.hud div {
  background: #252a36;
  border: 3px solid #111;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.06);
  color: #fff;
  min-width: 0;
  padding: 8px;
}

.hud span {
  color: #b9c0d7;
  display: block;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud b {
  color: #fff;
  display: block;
  font-size: 15px;
  line-height: 1.1;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

@keyframes trainer-work {
  0%,
  100% {
    translate: 0 0;
    rotate: 0deg;
  }

  50% {
    translate: -4px -2px;
    rotate: -1deg;
  }
}

@keyframes overworld-frame {
  0%,
  49% {
    background-position: 0 0;
  }

  50%,
  100% {
    background-position: -16px 0;
  }
}

@keyframes trainer-idle {
  50% {
    translate: 0 -2px;
  }
}

@keyframes screen-pulse {
  50% {
    background: #344826;
    border-color: #dff6a3;
  }
}

@keyframes code-line {
  50% {
    transform: translateX(10px);
    width: 28px;
  }
}

@keyframes key-press {
  50% {
    background: #93e689;
    transform: translateY(2px);
  }
}

@keyframes work-pixel {
  0% {
    opacity: 0;
    transform: translate(0, 0);
  }

  35% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(-46px, -18px);
  }
}

@media (max-width: 520px) {
  body {
    padding: 8px;
  }

  .gb {
    border-width: 3px;
    border-radius: 12px 12px 28px 12px;
    gap: 9px;
    padding: 10px;
  }

  .gb-top {
    grid-template-columns: 1fr auto;
  }

  .gb-top a {
    display: none;
  }

  .screen {
    padding: 8px;
  }

  .scene {
    height: 300px;
  }

  .desk {
    left: 5%;
    width: 55%;
  }

  .monitor {
    height: 68px;
    width: 96px;
  }

  .monitor i {
    height: 34px;
    width: 68px;
  }

  .monitor::after {
    width: 158px;
  }

  .keyboard {
    width: 118px;
  }

  .trainer {
    bottom: 18%;
    right: 2%;
    width: 124px;
  }

  .trainer-sprite {
    right: 28px;
    transform: scale(5);
  }

  .hud {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
