:root {
  --desktop: #31656a;
  --desktop-dark: #24484d;
  --chrome: #d0cbc0;
  --chrome-light: #eee8da;
  --chrome-mid: #aaa395;
  --chrome-dark: #5c5b58;
  --ink: #171717;
  --muted: #4f4f4f;
  --paper: #f7f1df;
  --red: #b6382f;
  --red-dark: #7e201c;
  --teal: #0d7779;
  --teal-light: #8cd7ce;
  --green: #4f8a3d;
  --amber: #c58923;
  --shadow: rgba(0, 0, 0, 0.34);
  --font-pixel: "Courier New", Courier, monospace;
  --font-ui: Arial, Helvetica, sans-serif;
  --radius: 3px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--desktop);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.35;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(0deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(135deg, var(--desktop), var(--desktop-dark));
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

:focus-visible {
  outline: 3px solid #f4cf58;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.desktop {
  position: relative;
  min-height: 100vh;
  padding: 18px;
}

.system-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  max-width: 1280px;
  margin: 0 auto 14px;
  padding: 6px 10px;
  color: #f7ffff;
  font-family: var(--font-pixel);
  font-size: 13px;
  background: #15373c;
  border: 2px solid #0b2023;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.18);
}

.system-strip__brand,
.system-strip__readouts {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.system-strip__readouts {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pixel-gem,
.window-icon,
.boot-logo {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
  background:
    linear-gradient(90deg, transparent 0 22%, #f6d257 22% 78%, transparent 78%),
    linear-gradient(0deg, transparent 0 22%, #f6d257 22% 78%, transparent 78%),
    #aa332d;
  border: 2px solid #141414;
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.18);
}

.window {
  width: min(1280px, 100%);
  margin: 0 auto;
  background: var(--chrome);
  border: 2px solid var(--ink);
  box-shadow:
    0 24px 60px var(--shadow),
    inset 2px 2px 0 var(--chrome-light),
    inset -2px -2px 0 var(--chrome-dark);
}

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  padding: 6px 9px;
  color: #f7ffff;
  font-family: var(--font-pixel);
  font-size: 14px;
  background: linear-gradient(90deg, #1b4f85, #0d7779);
  border-bottom: 2px solid var(--ink);
}

.titlebar__name {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.titlebar__name span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.window-actions {
  display: flex;
  gap: 5px;
}

.window-actions span {
  width: 20px;
  height: 18px;
  background: var(--chrome);
  border: 2px solid #121212;
  box-shadow: inset 2px 2px 0 var(--chrome-light), inset -2px -2px 0 var(--chrome-dark);
}

.menu-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 5px 8px;
  background: var(--chrome-light);
  border-bottom: 2px solid var(--chrome-dark);
}

.menu-bar button {
  min-height: 30px;
  border: 0;
  padding: 4px 11px;
  color: var(--ink);
  background: transparent;
  font-family: var(--font-pixel);
  font-size: 14px;
}

.menu-bar button:hover,
.menu-bar button:focus-visible {
  background: #c0e8e3;
}

.game-board {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 260px;
  gap: 10px;
  min-height: 660px;
  padding: 10px;
  background: #8c897d;
}

.panel,
.playfield {
  border: 2px solid var(--ink);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.46), inset -2px -2px 0 rgba(0, 0, 0, 0.28);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 12px;
  background: var(--paper);
}

h1,
h2,
p,
ol {
  margin: 0;
}

h1 {
  font-family: var(--font-pixel);
  font-size: 28px;
  line-height: 1.05;
}

h2 {
  font-family: var(--font-pixel);
  font-size: 16px;
  line-height: 1.15;
}

.lede {
  margin-top: 8px;
  color: var(--muted);
  font-family: var(--font-pixel);
  font-size: 13px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  min-width: 0;
  padding: 8px;
  background: #fff8e8;
  border: 2px solid var(--ink);
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.08);
}

.stat span,
.meter__label span,
.ad-box span,
.statusbar,
.drop-hint {
  font-family: var(--font-pixel);
  font-size: 12px;
}

.stat span {
  display: block;
  color: var(--muted);
}

.stat strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-family: var(--font-pixel);
  font-size: 21px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory {
  position: relative;
  min-height: 210px;
  padding: 8px;
  background:
    linear-gradient(45deg, rgba(0, 0, 0, 0.06) 25%, transparent 25% 75%, rgba(0, 0, 0, 0.06) 75%) 0 0 / 18px 18px,
    #d9d0bd;
  border: 2px solid var(--ink);
}

.inventory__media {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 156px;
}

.inventory__media img {
  width: min(230px, 92%);
  image-rendering: pixelated;
  filter: drop-shadow(7px 8px 0 rgba(0, 0, 0, 0.22));
}

.loose-egg,
.drag-egg,
.egg-pips span {
  border: 3px solid #141414;
  border-radius: 50% 50% 46% 46%;
  background:
    radial-gradient(circle at 34% 25%, #fff 0 11%, transparent 12%),
    radial-gradient(circle at 58% 68%, rgba(195, 155, 104, 0.32) 0 12%, transparent 13%),
    #fff2d5;
  image-rendering: pixelated;
}

.loose-egg {
  position: absolute;
  right: 12px;
  bottom: 14px;
  width: 48px;
  height: 58px;
  padding: 0;
  transform: rotate(8deg);
  box-shadow: 5px 6px 0 rgba(0, 0, 0, 0.2);
}

.loose-egg:active,
.loose-egg.is-pressed {
  transform: translate(1px, 2px) rotate(8deg);
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.2);
}

.egg-pips {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
  margin-top: 8px;
}

.egg-pips span {
  width: 14px;
  height: 18px;
  border-width: 2px;
  opacity: 0.2;
}

.egg-pips span.is-filled {
  opacity: 1;
}

.control-stack {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.button,
.ad-box button,
.popup__actions button {
  min-height: 42px;
  border: 2px solid var(--ink);
  border-radius: 0;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--chrome);
  font-family: var(--font-pixel);
  font-size: 13px;
  line-height: 1;
  box-shadow: inset 2px 2px 0 #fff, inset -3px -3px 0 var(--chrome-dark);
}

.button:hover,
.ad-box button:hover,
.popup__actions button:hover {
  background: #f8f0cf;
}

.button:active,
.ad-box button:active,
.popup__actions button:active {
  transform: translate(1px, 1px);
  box-shadow: inset -2px -2px 0 #fff, inset 3px 3px 0 var(--chrome-dark);
}

.button--primary,
.popup__actions button[data-action="primary"] {
  color: #fff;
  background: var(--teal);
  box-shadow: inset 2px 2px 0 var(--teal-light), inset -3px -3px 0 #064244;
}

.button--danger,
.popup__actions button[data-action="danger"] {
  color: #fff;
  background: var(--red);
  box-shadow: inset 2px 2px 0 #e16c62, inset -3px -3px 0 var(--red-dark);
}

.playfield {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.11) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(0deg, rgba(0, 0, 0, 0.08) 1px, transparent 1px) 0 0 / 24px 24px,
    radial-gradient(circle at 50% 52%, #f4ead0 0 0, #ddd0af 45%, #8b8f82 100%);
}

.scanlines {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 4;
  opacity: 0.18;
  background: repeating-linear-gradient(0deg, transparent 0 4px, rgba(0, 0, 0, 0.34) 5px 6px);
  mix-blend-mode: multiply;
}

.drop-hint {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  padding: 6px 10px;
  color: #fff;
  background: var(--red);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.24);
  opacity: 0;
  transition: opacity 160ms ease;
}

.playfield.is-dragging .drop-hint,
.playfield.is-ready .drop-hint {
  opacity: 1;
}

.big-egg-wrap {
  position: relative;
  width: min(520px, 88%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.big-egg {
  width: 100%;
  image-rendering: pixelated;
  filter: drop-shadow(13px 16px 0 rgba(0, 0, 0, 0.26));
  transform-origin: 50% 76%;
}

.big-egg.is-chomping {
  animation: chomp 260ms steps(3) 1;
}

.big-egg.is-full {
  animation: full-wobble 900ms steps(4) infinite;
}

.mouth-target {
  position: absolute;
  left: 50%;
  top: 61%;
  width: 32%;
  height: 24%;
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(255, 255, 255, 0);
  border-radius: 50%;
}

.playfield.is-dragging .mouth-target {
  border-color: rgba(255, 255, 255, 0.92);
  background: rgba(13, 119, 121, 0.16);
}

.speech-bubble {
  position: absolute;
  right: 0;
  bottom: 10%;
  max-width: 230px;
  padding: 9px 10px;
  font-family: var(--font-pixel);
  font-size: 13px;
  background: #fff8e8;
  border: 2px solid var(--ink);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.2);
}

.speech-bubble::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 22px;
  width: 14px;
  height: 14px;
  background: #fff8e8;
  border-left: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(45deg);
}

.crumb-layer {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 3;
}

.crumb {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff2d5;
  border: 2px solid #141414;
  animation: crumb 720ms steps(7) forwards;
}

.printer {
  min-height: 260px;
  padding: 10px;
  background: #fff8e8;
  border: 2px solid var(--ink);
  overflow: hidden;
}

.printer ol {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 214px;
  margin-top: 10px;
  padding-left: 22px;
  overflow: auto;
  font-family: var(--font-pixel);
  font-size: 13px;
}

.printer li::marker {
  color: var(--red);
}

.meter {
  display: grid;
  gap: 8px;
}

.meter__label {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

.meter__label strong {
  font-family: var(--font-pixel);
  font-size: 13px;
  text-align: right;
}

.meter__track {
  height: 30px;
  padding: 4px;
  background: #fff8e8;
  border: 2px solid var(--ink);
}

.meter__track span {
  display: block;
  width: 0%;
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--green) 0 12px, #6faa50 12px 18px);
  transition: width 180ms steps(5);
}

.ad-box {
  margin-top: auto;
  padding: 11px;
  background: #c9e8e2;
  border: 2px solid var(--ink);
  box-shadow: inset -4px -4px 0 rgba(0, 0, 0, 0.1);
}

.ad-box span {
  display: block;
  color: var(--red-dark);
}

.ad-box strong {
  display: block;
  margin-top: 4px;
  font-family: var(--font-pixel);
  font-size: 18px;
}

.ad-box p {
  margin: 8px 0 10px;
  color: var(--muted);
  font-family: var(--font-pixel);
  font-size: 13px;
}

.ad-box button {
  width: 100%;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  padding: 8px 10px;
  background: var(--chrome-light);
  border-top: 2px solid var(--chrome-dark);
}

.statusbar span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boot-screen,
.modal-layer,
.ending {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 18, 18, 0.46);
}

.boot-box,
.popup,
.ending__window {
  width: min(460px, 100%);
  background: var(--chrome);
  border: 2px solid var(--ink);
  box-shadow:
    12px 14px 0 rgba(0, 0, 0, 0.3),
    inset 2px 2px 0 var(--chrome-light),
    inset -2px -2px 0 var(--chrome-dark);
}

.boot-box {
  display: grid;
  gap: 13px;
  justify-items: start;
  padding: 22px;
  font-family: var(--font-pixel);
}

.boot-logo {
  width: 38px;
  height: 38px;
}

.boot-box h2 {
  font-size: 22px;
}

.boot-track {
  width: 100%;
  height: 24px;
  padding: 3px;
  border: 2px solid var(--ink);
  background: #fff8e8;
}

.boot-track span {
  display: block;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--teal) 0 14px, #79c8bd 14px 20px);
  transform-origin: left;
  animation: boot 1150ms steps(18) both;
}

.popup {
  width: min(420px, 100%);
}

.popup__titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 6px 8px;
  color: #fff;
  background: var(--red);
  border-bottom: 2px solid var(--ink);
  font-family: var(--font-pixel);
}

.popup__titlebar button {
  width: 26px;
  height: 24px;
  border: 2px solid var(--ink);
  padding: 0;
  background: var(--chrome);
  font-family: var(--font-pixel);
}

.popup__body {
  display: grid;
  gap: 12px;
  padding: 16px;
  font-family: var(--font-pixel);
}

.popup__receipt {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  background: #fff8e8;
  border: 2px dotted var(--ink);
}

.popup__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 16px 16px;
}

.popup__actions button:first-child:last-child {
  grid-column: 1 / -1;
}

.ending {
  z-index: 35;
  background:
    linear-gradient(45deg, rgba(0, 0, 0, 0.34) 25%, transparent 25% 75%, rgba(0, 0, 0, 0.34) 75%) 0 0 / 20px 20px,
    rgba(0, 0, 0, 0.72);
}

.ending__window {
  width: min(760px, 100%);
}

.ending__stage {
  position: relative;
  height: 330px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 54%, #ffe7b0 0, #bf8830 40%, #5b211d 100%);
  border-bottom: 2px solid var(--ink);
}

.ending__stage img {
  position: absolute;
  left: 50%;
  bottom: -52px;
  width: 290px;
  transform: translateX(-50%);
  image-rendering: pixelated;
  filter: drop-shadow(10px 12px 0 rgba(0, 0, 0, 0.25));
}

.curtain {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 38%;
  background: repeating-linear-gradient(90deg, #771d24 0 18px, #a82e37 18px 31px, #53141a 31px 42px);
  box-shadow: inset -10px 0 0 rgba(0, 0, 0, 0.2);
}

.curtain--left {
  left: 0;
}

.curtain--right {
  right: 0;
  transform: scaleX(-1);
}

.privacy-pixels {
  position: absolute;
  left: 50%;
  top: 58%;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(4, 26px);
  gap: 4px;
  transform: translate(-50%, -50%) rotate(-4deg);
}

.privacy-pixels span {
  width: 26px;
  height: 26px;
  background: #121212;
  border: 2px solid #f7f1df;
}

.ending__copy {
  display: grid;
  gap: 10px;
  padding: 18px;
  font-family: var(--font-pixel);
  background: var(--paper);
}

.ending__copy h2 {
  font-size: 24px;
}

.ending__copy .button {
  justify-self: start;
}

.drag-egg {
  pointer-events: none;
  position: fixed;
  z-index: 60;
  width: 48px;
  height: 58px;
  transform: translate(-50%, -50%);
  box-shadow: 6px 7px 0 rgba(0, 0, 0, 0.26);
}

.toast-layer {
  pointer-events: none;
  position: fixed;
  top: 74px;
  right: 22px;
  z-index: 25;
  display: grid;
  gap: 8px;
  width: min(330px, calc(100vw - 44px));
}

.toast {
  padding: 10px 12px;
  background: #fff8e8;
  border: 2px solid var(--ink);
  box-shadow: 7px 8px 0 rgba(0, 0, 0, 0.22);
  font-family: var(--font-pixel);
  font-size: 13px;
  animation: toast-in 220ms steps(4) both;
}

@keyframes boot {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@keyframes chomp {
  0% {
    transform: translateY(0) scaleY(1);
  }
  50% {
    transform: translateY(8px) scaleY(0.96);
  }
  100% {
    transform: translateY(0) scaleY(1);
  }
}

@keyframes full-wobble {
  0%,
  100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-2deg);
  }
  75% {
    transform: rotate(2deg);
  }
}

@keyframes crumb {
  to {
    transform: translate(var(--dx), var(--dy)) rotate(70deg);
    opacity: 0;
  }
}

@keyframes toast-in {
  from {
    transform: translateX(18px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@media (max-width: 1060px) {
  .game-board {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .panel--right {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px 240px;
    align-items: start;
  }

  .ad-box {
    margin-top: 0;
  }
}

@media (max-width: 780px) {
  .desktop {
    padding: 10px;
  }

  .system-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .game-board {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .panel--right {
    grid-template-columns: minmax(0, 1fr);
  }

  .playfield {
    min-height: 430px;
  }

  .big-egg-wrap {
    width: min(430px, 94%);
  }

  .speech-bubble {
    right: 8px;
    bottom: 4%;
    max-width: 210px;
  }

  .statusbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .statusbar span:first-child {
    white-space: normal;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 24px;
  }

  .stat-grid,
  .control-stack,
  .popup__actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .egg-pips {
    grid-template-columns: repeat(8, 1fr);
  }

  .ending__stage {
    height: 280px;
  }

  .ending__stage img {
    width: 240px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
