:root {
  --ink: #1f2b28;
  --muted: #65736d;
  --paper: #fbfaf4;
  --mist: rgba(236, 242, 235, 0.86);
  --leaf: #426f5b;
  --leaf-dark: #294d3f;
  --rose: #c97978;
  --sun: #d8aa54;
  --sky: #86b6bd;
  --violet: #8e88b8;
  --line: rgba(31, 43, 40, 0.14);
  --shadow: 0 22px 70px rgba(21, 41, 34, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #dfe9e2;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

canvas {
  display: block;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #dfe9e2;
}

.start-screen {
  position: absolute;
  inset: 24px;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background: rgba(251, 250, 244, 0.9);
  box-shadow: var(--shadow);
  transition:
    opacity 500ms ease,
    transform 500ms ease,
    visibility 500ms ease;
}

.start-screen.is-hidden {
  visibility: hidden;
  opacity: 0;
  transform: scale(1.02);
  pointer-events: none;
}

.start-photo {
  min-height: 100%;
  background:
    linear-gradient(90deg, rgba(31, 43, 40, 0.08), rgba(31, 43, 40, 0)),
    url("https://images.unsplash.com/photo-1508214751196-bcfd4ca60f91?auto=format&fit=crop&w=1500&q=82")
      center/cover;
}

.start-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(32px, 6vw, 76px);
}

.kicker {
  margin: 0 0 10px;
  color: var(--leaf);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  font-size: clamp(5rem, 12vw, 9rem);
  line-height: 0.86;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: break-word;
}

p {
  color: var(--muted);
  line-height: 1.62;
  overflow-wrap: break-word;
}

.primary,
.secondary {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  border-radius: 8px;
  padding: 0 18px;
  text-decoration: none;
  font-weight: 900;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.primary {
  width: fit-content;
  background: var(--leaf);
  color: white;
  box-shadow: 0 14px 32px rgba(66, 111, 91, 0.26);
}

.secondary {
  background: rgba(255, 255, 255, 0.68);
  color: var(--leaf-dark);
  outline: 1px solid rgba(66, 111, 91, 0.2);
}

.secondary.is-on {
  background: rgba(66, 111, 91, 0.9);
  color: white;
}

button:hover {
  transform: translateY(-1px);
}

.start-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hud {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 4;
  display: grid;
  width: min(520px, calc(100vw - 36px));
  grid-template-columns: 174px 1fr;
  gap: 10px;
}

.guide-card,
.stats,
.quest-box,
.fragments,
.touch-pad,
.modal {
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background: rgba(251, 250, 244, 0.78);
  box-shadow: 0 16px 46px rgba(21, 41, 34, 0.14);
  backdrop-filter: blur(18px);
}

.guide-card {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.guide-card img {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  object-fit: cover;
}

.guide-card span,
.stats span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.guide-card strong {
  font-size: 1.3rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
}

.stats div {
  padding: 10px;
  background: rgba(255, 255, 255, 0.36);
}

.stats strong {
  display: block;
  margin-top: 4px;
  font-size: 1.4rem;
}

.quest-box {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 4;
  width: min(520px, calc(100vw - 36px));
  padding: 18px;
}

.quest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fragments {
  position: absolute;
  right: 18px;
  top: 18px;
  z-index: 4;
  display: flex;
  max-width: min(410px, calc(100vw - 36px));
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
}

.fragment {
  border-radius: 999px;
  padding: 8px 11px;
  background: rgba(236, 242, 235, 0.88);
  color: var(--leaf-dark);
  font-size: 0.82rem;
  font-weight: 900;
}

.touch-pad {
  position: absolute;
  bottom: 18px;
  left: 18px;
  z-index: 5;
  display: none;
  gap: 8px;
  padding: 10px;
}

.touch-pad button {
  width: 48px;
  height: 44px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--leaf-dark);
  font-size: 1.1rem;
  font-weight: 900;
}

.modal {
  width: min(960px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 20px;
  color: var(--ink);
}

.modal::backdrop {
  background: rgba(24, 35, 31, 0.42);
  backdrop-filter: blur(4px);
}

.modal.small {
  width: min(520px, calc(100vw - 32px));
}

.attachment-modal {
  width: min(760px, calc(100vw - 32px));
}

.story-modal {
  width: min(820px, calc(100vw - 32px));
}

.close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font-size: 1.5rem;
}

.modal-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

#art-canvas {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  touch-action: none;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
}

.swatch {
  width: 42px;
  height: 42px;
  border: 3px solid transparent;
  border-radius: 50%;
  background: var(--swatch);
}

.swatch.is-selected {
  border-color: var(--ink);
}

.attachment-head {
  max-width: 640px;
  padding-right: 40px;
}

.dialogue-stage {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.bubble-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.bubble-row.player {
  grid-template-columns: minmax(0, 1fr) 54px;
}

.bubble-row.player .speaker {
  order: 2;
}

.speaker {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 50%;
  background: var(--leaf);
  color: white;
  font-size: 1.4rem;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(21, 41, 34, 0.16);
}

.speaker.dream {
  background: #e88aa4;
}

.speaker.work {
  background: var(--sky);
}

.speaker.boss {
  background: var(--violet);
}

.speaker.client {
  background: var(--sun);
}

.speaker.money {
  background: #62a984;
}

.speaker.self {
  background: #b894d6;
}

.speaker.mountain {
  background: #726f64;
}

.bubble {
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  line-height: 1.48;
  outline: 1px solid rgba(66, 111, 91, 0.14);
}

.bubble-row.player .bubble {
  background: rgba(236, 242, 235, 0.9);
}

.bubble strong {
  display: block;
  margin-bottom: 4px;
  color: var(--leaf-dark);
}

.attachment-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.attachment-choice {
  min-height: 112px;
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  text-align: left;
  outline: 1px solid rgba(66, 111, 91, 0.16);
}

.attachment-choice strong {
  display: block;
  margin-bottom: 6px;
  color: var(--leaf-dark);
}

.attachment-choice span {
  color: var(--muted);
  line-height: 1.45;
}

.attachment-feedback {
  min-height: 58px;
  margin-top: 14px;
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(236, 242, 235, 0.82);
  color: var(--leaf-dark);
  font-weight: 800;
  line-height: 1.45;
}

.attachment-meter {
  display: grid;
  grid-template-columns: repeat(4, 1fr 44px);
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.attachment-meter strong {
  display: grid;
  min-height: 34px;
  place-items: center;
  border-radius: 8px;
  background: white;
  color: var(--ink);
}

@media (max-width: 880px) {
  .start-screen {
    inset: 10px;
    grid-template-columns: 1fr;
  }

  .start-photo {
    min-height: 42vh;
  }

  .start-copy {
    padding: 26px;
  }

  h1 {
    font-size: clamp(4rem, 18vw, 5rem);
  }

  .hud {
    grid-template-columns: 1fr;
  }

  .fragments {
    top: auto;
    right: 18px;
    bottom: 184px;
  }

  .quest-box {
    bottom: 18px;
  }

  .touch-pad {
    display: grid;
  }

  .modal-grid {
    grid-template-columns: 1fr;
  }

  .attachment-options {
    grid-template-columns: 1fr;
  }

  .attachment-meter {
    grid-template-columns: 1fr 36px;
  }

  #art-canvas {
    min-height: 330px;
  }
}

@media (max-width: 560px) {
  .modal,
  .attachment-modal,
  .story-modal {
    width: 72vw !important;
    max-width: 72vw !important;
    margin: auto;
    padding: 16px;
  }

  .attachment-head {
    padding-right: 28px;
  }

  .attachment-choice {
    min-height: 92px;
  }

  .bubble-row,
  .bubble-row.player {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .bubble-row.player .speaker {
    order: 0;
  }

  .speaker {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }

  .close {
    right: 28px;
  }

  .hud {
    top: 10px;
    left: 10px;
    width: calc(100vw - 20px);
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .quest-box {
    left: 16px;
    right: 16px;
    bottom: 10px;
    width: auto;
    max-width: none;
    padding: 14px 18px 14px 14px;
  }

  .quest-box h2 {
    font-size: 1.25rem;
    line-height: 1.12;
  }

  .quest-box p {
    font-size: 0.95rem;
  }

  .quest-box p {
    margin-bottom: 10px;
  }

  .fragments {
    display: none;
  }

  .touch-pad {
    display: none;
  }
}
