@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Pixelify Sans";
  src: url("/fonts/pixelify-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  --cream: #FFF4E0;
  --ink: #1F1A2E;
  --periwinkle: #8EA2F7;
  --grid: rgb(255 255 255 / 0.2);
  --marigold: #FFC567;
  --violet: #552CB7;
  --pink: #FB7DA8;
  --tomato: #FD5A46;
  --blue: #058CD7;
  --line: 4px solid var(--ink);
  --ui: "Pixelify Sans", ui-monospace, monospace;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background-color: var(--periwinkle);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 72px 72px;
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 500;
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

/* Desktop layout */
.desktop {
  position: relative;
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 320px;
  grid-template-areas:
    "brand brand meter"
    "icons windows windows";
  gap: 28px 32px;
  width: min(100%, 1560px);
  margin-inline: auto;
  padding: 24px 40px 150px;
}

/* Decorations */
.decor { position: absolute; pointer-events: none; }
.decor--cloud { top: 205px; left: 62%; width: 110px; }
.decor--star { top: 225px; left: 71%; width: 40px; }

/* Brand */
.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 12px;
}

.wordmark {
  flex: none;
  width: clamp(420px, 44vw, 700px);
  margin: 0;
}
.wordmark img { display: block; width: 100%; height: auto; }

.mascot { position: relative; flex: none; }

.orange {
  display: block;
  width: clamp(130px, 13vw, 210px);
  padding: 0;
  border: 0;
  background: none;
  transform-origin: 50% 100%;
}
.orange img { display: block; width: 100%; height: auto; }
.orange.is-hopping { animation: hop 500ms cubic-bezier(.3, 1.6, .5, 1); }

.bubble[hidden] { display: none; }
.bubble {
  position: absolute;
  top: 8px;
  left: calc(100% + 6px);
  width: max-content;
  max-width: 180px;
  margin: 0;
  padding: 10px 14px;
  border: var(--line);
  border-radius: 16px 16px 16px 2px;
  background: var(--cream);
  font-size: 0.95rem;
  line-height: 1.25;
}

/* Icons */
.icons {
  grid-area: icons;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 4px 0;
  border: 0;
  background: none;
  font-family: var(--ui);
  font-weight: 600;
  font-size: 0.95rem;
}
.icon img { width: 72px; height: 72px; image-rendering: pixelated; }
.icon span { padding: 1px 5px; }
.icon:hover img { transform: translateY(-3px); }
.icon:hover span,
.icon:focus-visible span { background: var(--ink); color: var(--cream); }

/* Windows */
.windows {
  grid-area: windows;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 126px 40px;
}
.windows > .window:not([hidden]) { display: flex; flex-direction: column; }

.window {
  position: relative;
  background: var(--cream);
  border: var(--line);
  border-radius: 8px;
  box-shadow: 8px 8px 0 var(--ink);
}
.window[hidden] { display: none; }
.window.is-opening { animation: pop 260ms cubic-bezier(.3, 1.5, .5, 1); }

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
  padding: 6px 8px 6px 18px;
  border-bottom: var(--line);
  border-radius: 4px 4px 0 0;
  user-select: none;
  touch-action: none;
  cursor: grab;
}
.titlebar--static { cursor: default; touch-action: auto; }
.is-dragging .titlebar { cursor: grabbing; }
.titlebar h2 {
  margin: 0;
  font-family: var(--ui);
  font-size: 1.35rem;
  font-weight: 600;
}
.window--violet > .titlebar { background: var(--violet); color: var(--cream); }
.window--pink > .titlebar { background: var(--pink); }
.window--blue > .titlebar { background: var(--blue); }
.window--tomato > .titlebar { background: var(--tomato); }
.window--marigold > .titlebar { background: var(--marigold); }

.controls button {
  display: block;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 4px;
  background: var(--cream);
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  box-shadow: 2px 2px 0 var(--ink);
}
.controls button:active { transform: translate(2px, 2px); box-shadow: none; }

.window__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(22px, 2.4vw, 36px) 20px 72px;
  text-align: center;
}


.number {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
}
.number img {
  display: block;
  width: auto;
  max-width: 92%;
  height: clamp(120px, 14vw, 210px);
  object-fit: contain;
  margin-inline: auto;
}
.number:hover img { transform: scale(1.03) rotate(-1deg); }
.number.is-squeezed img { animation: squeeze 340ms cubic-bezier(.3, 1.5, .5, 1); }

.caption {
  margin: 14px 0 0;
  font-size: clamp(1.1rem, 1.6vw, 1.55rem);
  line-height: 1.3;
}

/* Characters hang off each window's outer corner */
.person {
  position: absolute;
  bottom: -104px;
  left: -40px;
  z-index: 5;
  width: clamp(170px, 15.5vw, 270px);
  height: auto;
  pointer-events: none;
}
.windows > :nth-child(even) .person { right: -30px; left: auto; }
.person--tall { bottom: -146px; left: -34px; width: clamp(120px, 10.5vw, 175px); }

.ok, .start {
  border: var(--line);
  border-radius: 5px;
  background: var(--cream);
  font-family: var(--ui);
  font-weight: 600;
  box-shadow: 4px 4px 0 var(--ink);
}
.ok:hover, .start:hover { background: var(--marigold); }
.ok:active, .start:active { transform: translate(4px, 4px); box-shadow: none; }

/* Juice meter */
.meter { grid-area: meter; align-self: center; }
.meter__body { padding: 16px; }
.meter__bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  height: 32px;
  padding: 4px;
  border: var(--line);
  border-radius: 4px;
  background: #fff;
}
.meter__bar i { background: transparent; transition: background-color 160ms; }
.meter__bar i.is-full { background: var(--tomato); }
.meter__body p { margin: 10px 0 0; text-align: center; }

/* Alerts */
.alert { text-align: center; }
.alert--floating {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 60;
  width: min(400px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
}
.alert__body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 22px 16px 16px;
  font-size: 1.2rem;
}
.alert__body p { margin: 0; }
.alert__sign { flex: none; width: 54px; height: 50px; }
.ok { min-width: 124px; min-height: 46px; margin-bottom: 20px; font-size: 1.15rem; }

/* Taskbar */
.taskbar {
  position: sticky;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 14px;
  border-top: var(--line);
  background: var(--cream);
  font-family: var(--ui);
  font-weight: 600;
}
.start {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 12px 0 7px;
}
.clock { margin-left: auto; font-variant-numeric: tabular-nums; }

@keyframes pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes squeeze {
  35% { transform: scale(1.14, 0.84); }
  70% { transform: scale(0.95, 1.08); }
}
@keyframes hop {
  0%, 100% { transform: translateY(0) rotate(0); }
  40% { transform: translateY(-22px) rotate(-8deg); }
  70% { transform: translateY(0) rotate(5deg); }
}

/* Single column for tablets and phones */
@media (max-width: 1040px) {
  body { background-size: 44px 44px; }

  .desktop {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "brand" "meter" "windows" "icons";
    padding: 18px 16px 28px;
  }

  .decor, .bubble { display: none; }
  .brand { justify-content: space-between; }
  .wordmark { flex: 1; width: auto; max-width: 620px; }
  .orange { width: clamp(84px, 24vw, 180px); }

  .windows { grid-template-columns: minmax(0, 1fr); row-gap: 92px; }
  .titlebar { cursor: default; touch-action: auto; }
    .caption { font-size: 1.1rem; }

  .person { bottom: -66px; left: -6px; width: clamp(150px, 42vw, 240px); }
  .windows > :nth-child(even) .person { right: -6px; }
  .person--tall { bottom: -66px; left: -6px; width: clamp(96px, 25vw, 150px); }

  .number img { height: clamp(96px, 28vw, 180px); }
  .window__body { padding-bottom: 58px; }
  .icons { margin-top: 70px; }

  .icons {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }
  .icon { width: 84px; font-size: 0.85rem; }
  .icon img { width: 56px; height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .window.is-opening, .number.is-squeezed img, .orange.is-hopping { animation: none; }
}
