@import url("https://cdn.jsdelivr.net/npm/galmuri@latest/dist/galmuri.css");

:root {
  --desktop: #bfd4e6;
  --desktop-2: #96b8d6;
  --paper: #f5f2eb;
  --paper-deep: #dedbd3;
  --white: #fffefa;
  --ink: #171717;
  --muted: #69665f;
  --coral: #e76450;
  --mint: #48a77d;
  --line: 1px;
  --ui: 13px;
  --small: 11px;
  --display: 32px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--desktop);
  font-family: "Galmuri11", "Apple SD Gothic Neo", sans-serif;
  font-size: var(--ui);
  line-height: 1.55;
  word-break: keep-all;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: .055;
  background-image: radial-gradient(var(--ink) .45px, transparent .55px);
  background-size: 4px 4px;
  mix-blend-mode: multiply;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { color: inherit; }
a, button, [role="button"] { cursor: url("../assets/pixel-cursor.svg") 2 2, pointer; }

body.time-morning { --desktop: #cfe6ef; --desktop-2: #a9d4e0; }
body.time-day { --desktop: #bfd4e6; --desktop-2: #96b8d6; }
body.time-evening { --desktop: #f0c9b4; --desktop-2: #e6947a; }
body.time-night { --desktop: #37416b; --desktop-2: #1f2444; }

.menu-bar {
  height: 36px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 0 18px;
  border-bottom: var(--line) solid var(--ink);
  background: var(--paper);
  font-size: var(--small);
}
.brand, .menu-status, .menu-bar nav { display: flex; align-items: center; }
.brand { gap: 8px; width: fit-content; }
.brand > img { width: 15px; height: auto; image-rendering: pixelated; }
.menu-bar nav { height: 100%; gap: 4px; }
.menu-bar nav button {
  height: 100%;
  padding: 0 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.menu-bar nav button:hover, .menu-bar nav button.is-current { background: var(--ink); color: var(--paper); }
.menu-status { justify-self: end; gap: 8px; }
.menu-status time { margin-left: 6px; font-variant-numeric: tabular-nums; }
.status-dot { width: 7px; height: 7px; border: var(--line) solid var(--ink); background: var(--mint); }

.desktop {
  position: relative;
  min-height: calc(100dvh - 36px);
  display: grid;
  place-items: center;
  padding: 48px clamp(48px, 8vw, 128px) 56px;
  overflow: hidden;
  background-color: var(--desktop);
  background-image: linear-gradient(rgba(255,255,255,.16) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.16) 1px, transparent 1px), linear-gradient(135deg, var(--desktop) 0%, var(--desktop-2) 50%, var(--desktop) 100%);
  background-size: 8px 8px, 8px 8px, 300% 300%;
  transition: background-color .6s ease;
  animation: desktop-drift 18s ease-in-out infinite;
}
@keyframes desktop-drift {
  0%, 100% { background-position: 0 0, 0 0, 0% 0%; }
  50% { background-position: 0 0, 0 0, 100% 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .desktop { animation: none; }
}

.app-window {
  position: relative;
  z-index: 2;
  width: min(1160px, 100%);
  border: var(--line) solid var(--ink);
  background: var(--paper);
  box-shadow: 4px 4px 0 rgba(23,23,23,.28);
}
.title-bar {
  min-height: 28px;
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  padding: 0 7px;
  border-bottom: var(--line) solid var(--ink);
  background: repeating-linear-gradient(0deg, var(--ink) 0, var(--ink) 1px, var(--paper) 1px, var(--paper) 3px);
}
.title-bar h1 { justify-self: center; margin: 0; padding: 2px 10px; background: var(--paper); font-size: var(--small); line-height: 1.4; }
.window-controls { display: flex; gap: 5px; width: fit-content; padding-right: 7px; background: var(--paper); }
.window-controls span, .window-zoom { width: 14px; height: 14px; border: var(--line) solid var(--ink); background: var(--paper); }
.window-controls span:first-child { position: relative; background: var(--coral); }
.window-controls span:first-child::after { content: "×"; position: absolute; inset: -4px 0 0; text-align: center; font-family: monospace; font-size: 14px; }
.window-zoom { justify-self: end; box-shadow: inset -3px -3px 0 var(--paper-deep); }

.app-body { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(390px, .96fr); grid-template-rows: minmax(0, 1fr); height: 548px; }
.monkey-photo { position: relative; min-width: 0; margin: 0; overflow: hidden; border-right: var(--line) solid var(--ink); background: #6b6559; }
.monkey-photo img { display: block; width: 100%; height: 100%; min-height: 548px; object-fit: cover; object-position: center; }
.monkey-speech {
  position: absolute;
  z-index: 2;
  top: 8%;
  left: 5%;
  width: min(43%, 248px);
  padding: 16px 17px 18px;
  border: var(--line) solid var(--ink);
  border-radius: 2px;
  background: var(--white);
  box-shadow: 3px 3px 0 rgba(23,23,23,.25);
}
.monkey-speech::after {
  content: "";
  position: absolute;
  right: 25%;
  bottom: -8px;
  width: 14px;
  height: 14px;
  border-right: var(--line) solid var(--ink);
  border-bottom: var(--line) solid var(--ink);
  background: var(--white);
  transform: rotate(45deg);
}
.monkey-speech p { margin: 0; font-family: "Galmuri11-Bold", "Galmuri11", sans-serif; font-size: var(--ui); line-height: 1.65; text-wrap: balance; }
.monkey-photo figcaption {
  position: absolute;
  z-index: 3;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 9px;
  border: var(--line) solid var(--ink);
  background: rgba(245,242,235,.95);
  font-size: var(--small);
}

.action-panel { min-width: 0; min-height: 0; max-height: 100%; align-self: center; padding: 32px clamp(32px, 4vw, 52px); overflow-y: auto; }
.battle-view[hidden] { display: none; }
.eyebrow { margin: 0 0 16px; color: var(--muted); font-size: var(--small); }
.action-panel h2 {
  margin: 0;
  font-family: "Galmuri11-Bold", "Galmuri11", sans-serif;
  font-size: var(--display);
  line-height: 1.25;
  letter-spacing: -.04em;
}
.action-panel h2 em { color: var(--coral); font-style: normal; }
.intro { max-width: 46ch; margin: 20px 0 28px; font-size: var(--ui); line-height: 1.75; }

.stock-form { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 154px; gap: 8px; }
.stock-form label { grid-column: 1 / -1; font-family: "Galmuri11-Bold", "Galmuri11", sans-serif; font-size: var(--small); }
.stock-search { position: relative; min-width: 0; }
.stock-search input, .challenge-button { width: 100%; min-height: 42px; border: var(--line) solid var(--ink); }
.stock-search input { min-width: 0; padding: 0 12px; outline: 0; background: var(--white); box-shadow: inset 1px 1px 0 var(--paper-deep); font-size: var(--ui); }
.stock-search input::placeholder { color: #77736b; opacity: 1; }
.challenge-button { padding: 0 10px; background: var(--coral); box-shadow: 2px 2px 0 var(--ink); font-family: "Galmuri11-Bold", "Galmuri11", sans-serif; font-size: var(--small); cursor: pointer; }
.challenge-button:disabled { background: var(--paper-deep); color: #8a867e; box-shadow: 1px 1px 0 #8a867e; cursor: not-allowed; }
.challenge-button:not(:disabled):active { transform: translate(1px,1px); box-shadow: 1px 1px 0 var(--ink); }
.challenge-button span { margin-left: 3px; font-size: 8px; }
.suggestions { position: absolute; z-index: 6; top: calc(100% - 1px); left: 0; right: 0; max-height: 224px; margin: 0; padding: 0; overflow-y: auto; border: var(--line) solid var(--ink); background: var(--white); box-shadow: 2px 2px 0 rgba(23,23,23,.22); list-style: none; }
.suggestions li + li { border-top: var(--line) solid #aaa69d; }
.suggestions button { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 9px 10px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.suggestions button:hover, .suggestions button.is-focused { background: var(--ink); color: var(--paper); }
.suggestions strong { display: block; margin-bottom: 2px; font-size: var(--ui); }
.suggestions small, .suggestions em { font-size: var(--small); }
.suggestions em { align-self: center; font-style: normal; }

.record-panel { display: grid; grid-template-columns: repeat(3, 1fr); margin: 28px 0 0; border: var(--line) solid var(--ink); }
.record-panel div { min-width: 0; padding: 12px 8px; text-align: center; }
.record-panel div + div { border-left: var(--line) solid var(--ink); }
.record-panel dt { margin-bottom: 6px; color: var(--muted); font-size: var(--small); }
.record-panel dd { margin: 0; font-family: "Galmuri11-Bold", "Galmuri11", sans-serif; font-size: var(--ui); }
.record-panel div:nth-child(2) dd { color: var(--coral); }

.back-button { margin: 0 0 24px; padding: 0; border: 0; background: transparent; font-size: var(--small); cursor: pointer; }
.selected-stock { margin-bottom: 24px; padding-bottom: 20px; border-bottom: var(--line) solid var(--ink); }
.selected-market { display: inline-block; margin-bottom: 8px; padding: 3px 5px; border: var(--line) solid var(--ink); background: var(--paper-deep); font-size: var(--small); }
.selected-stock h2 { margin: 0 0 6px; font-size: 28px; line-height: 1.25; }
.selected-code { margin: 0; color: var(--muted); font-size: var(--ui); font-variant-numeric: tabular-nums; }
.prediction-question { margin: 0 0 20px; font-family: "Galmuri11-Bold", "Galmuri11", sans-serif; font-size: var(--ui); line-height: 1.65; }
.direction-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.direction-buttons button { min-height: 52px; border: var(--line) solid var(--ink); background: var(--white); box-shadow: 2px 2px 0 var(--ink); font-family: "Galmuri11-Bold", "Galmuri11", sans-serif; font-size: var(--ui); cursor: pointer; transition: transform .12s ease, background-color .12s ease; }
.direction-buttons button:first-child span { color: var(--coral); }
.direction-buttons button:last-child span { color: #36709e; }
.direction-buttons button:hover, .direction-buttons button.is-selected { transform: translate(-1px,-1px); background: var(--paper-deep); box-shadow: 3px 3px 0 var(--ink); }
.confirmation { margin-top: 24px; padding: 14px; border: var(--line) solid var(--ink); background: var(--paper-deep); }
.confirmation p { margin: 0 0 12px; font-size: var(--ui); line-height: 1.65; }
.confirmation > div { display: flex; gap: 8px; }
.confirmation button { min-height: 38px; padding: 0 11px; border: var(--line) solid var(--ink); background: var(--white); font-size: var(--small); cursor: pointer; }
.confirmation button:first-child { background: var(--coral); font-family: "Galmuri11-Bold", "Galmuri11", sans-serif; }
.result-title { margin-bottom: 28px !important; }
.versus-board { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 16px 8px; border-block: var(--line) solid var(--ink); text-align: center; }
.versus-board div { display: grid; gap: 8px; }
.versus-board span { font-size: var(--small); }
.versus-board strong { font-size: var(--ui); }
.versus-board b { color: var(--coral); font-size: var(--small); }
.return-message { margin: 24px 0; font-size: var(--ui); line-height: 1.75; }
.new-battle-button { min-height: 40px; padding: 0 12px; border: var(--line) solid var(--ink); background: var(--paper-deep); box-shadow: 2px 2px 0 var(--ink); font-size: var(--small); cursor: pointer; }

.window-footer { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 7px 12px; border-top: var(--line) solid var(--ink); font-size: var(--small); }
.window-footer p { margin: 0; }
.window-footer p span { display: inline-grid; place-items: center; width: 14px; height: 14px; margin-right: 6px; border: var(--line) solid var(--coral); color: var(--coral); }
.window-footer > span { white-space: nowrap; }
.window-footer > span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border: var(--line) solid var(--ink); background: var(--mint); }

.mobile-nav { display: none; }
.nav-notice { position: fixed; z-index: 15; left: 50%; bottom: 24px; margin: 0; padding: 9px 12px; transform: translateX(-50%); border: var(--line) solid var(--ink); background: var(--paper); box-shadow: 2px 2px 0 var(--ink); font-size: var(--small); }
:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }

@media (max-width: 1000px) {
  .desktop { padding-inline: 40px; }
  .app-body { grid-template-columns: minmax(0,.96fr) minmax(350px,1.04fr); height: 500px; }
  .monkey-photo img { min-height: 500px; }
  .action-panel { padding: 32px; }
  .stock-form { grid-template-columns: 1fr; }
  .stock-form label { grid-column: auto; }
}

@media (max-width: 760px) {
  :root { --ui: 13px; --small: 11px; --display: 27px; }
  body { padding-bottom: 58px; }
  body.is-battle-active { padding-bottom: 0; }
  .menu-bar { grid-template-columns: 1fr auto; height: 36px; padding: 0 12px; }
  .menu-bar nav, .menu-status > span:not(.status-dot) { display: none; }
  .menu-status time { display: none; }
  .desktop { display: block; min-height: calc(100dvh - 36px); padding: 20px 12px 36px; overflow: visible; }
  .app-window { box-shadow: 3px 3px 0 rgba(23,23,23,.28); }
  .title-bar { grid-template-columns: 48px 1fr 48px; min-height: 27px; }
  .title-bar h1 { font-size: 10px; }
  .app-body { display: block; height: auto; }
  .monkey-photo { border-right: 0; border-bottom: var(--line) solid var(--ink); }
  .monkey-photo img { min-height: 0; height: auto; aspect-ratio: 4 / 3; object-fit: cover; object-position: center; }
  .monkey-speech {
    top: auto;
    left: 4%;
    bottom: 52px;
    width: min(62%, 260px);
    padding: 12px 12px 14px;
  }
  .monkey-speech::after {
    top: -8px;
    right: 22%;
    bottom: auto;
    border: 0;
    border-top: var(--line) solid var(--ink);
    border-left: var(--line) solid var(--ink);
    transform: rotate(45deg);
  }
  .monkey-speech p { display: -webkit-box; overflow: hidden; font-size: 12px; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
  .monkey-photo figcaption { left: 8px; right: 8px; bottom: 8px; padding: 6px 8px; }
  .action-panel { max-height: none; padding: 28px 20px 32px; overflow: visible; }
  .intro { margin: 16px 0 24px; }
  .intro br { display: none; }
  .record-panel { margin-top: 24px; }
  .window-footer { align-items: flex-start; }
  .mobile-nav {
    position: fixed;
    z-index: 12;
    left: 0;
    right: 0;
    bottom: 0;
    height: 58px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: var(--line) solid var(--ink);
    background: var(--paper);
  }
  .mobile-nav button { display: grid; place-items: center; align-content: center; gap: 2px; min-width: 0; padding: 4px 2px; border: 0; border-right: var(--line) solid #aaa69d; background: transparent; font-size: 9px; cursor: pointer; }
  .mobile-nav button:last-child { border-right: 0; }
  .mobile-nav button span { font-size: 12px; line-height: 1; }
  .mobile-nav button.is-current { background: var(--ink); color: var(--paper); }
  body.is-battle-active .mobile-nav { display: none; }
  .nav-notice { bottom: 70px; max-width: calc(100% - 24px); white-space: nowrap; }
  body.is-battle-active .nav-notice { bottom: 16px; }
}

@media (max-width: 430px) {
  .window-controls span:nth-child(2), .window-zoom { display: none; }
  .action-panel { padding-inline: 16px; }
  .stock-search input, .challenge-button { min-height: 42px; }
  .record-panel dt { font-size: 10px; }
  .window-footer > span { display: none; }
}
