:root {
  --ink: #3a2a18;
  --cream: #fff6e4;
  --panel: #ffe9c2;
  --panel-edge: #8b5a2b;
  --muted: #7a5c3a;
  --coral: #e07848;
  --coral-dark: #c45a2c;
  --grass: #6bb83a;
  --sky: #6eb8e8;
  --wood: #c48a4a;
  --wood-dark: #8a5a32;
  --shadow: 0 10px 0 rgba(58, 42, 24, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: Nunito, "Segoe UI", sans-serif;
  background: #6bb83a;
}

body.merge {
  min-height: 100svh;
  overflow: hidden;
  image-rendering: pixelated;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    url("./assets/suika-farm-bg.png") center / cover no-repeat,
    linear-gradient(180deg, #6eb8e8 0%, #9fd4f0 38%, #6bb83a 38%, #4f9a2a 100%);
}

.kicker {
  margin: 0 0 8px;
  color: var(--coral-dark);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.btn {
  appearance: none;
  border: 3px solid var(--panel-edge);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 var(--panel-edge);
  background: var(--panel);
  color: var(--ink);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--panel-edge); }
.btn.coral {
  background: var(--coral);
  color: #fff8ee;
  border-color: #9a3f1e;
  box-shadow: 0 4px 0 #9a3f1e;
}
.btn.cream { background: var(--cream); }
.btn.ghost {
  background: rgba(255, 246, 228, 0.88);
  box-shadow: 0 3px 0 var(--panel-edge);
}
.btn.xl { width: 100%; padding: 14px 18px; font-size: 17px; }

.layout {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(360px, 1fr) minmax(200px, 260px);
  gap: 16px;
  align-items: stretch;
  justify-content: center;
  width: min(1280px, calc(100% - 20px));
  height: calc(100svh - 20px);
  margin: 10px auto;
  padding: 0;
}

.panel {
  background: linear-gradient(180deg, #fff1d2, #ffe0a8);
  border: 4px solid var(--panel-edge);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
  height: 100%;
  overflow: auto;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  text-decoration: none;
  color: inherit;
  font-weight: 900;
}
.brand-row img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 2px solid var(--panel-edge);
  object-fit: cover;
  background: #fff;
}

.side-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 900;
}

.evo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}
.evo-list img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  border: 2px solid rgba(139, 90, 43, 0.35);
}

.howto {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--muted);
}
.howto li {
  margin: 0 0 6px;
  padding-left: 12px;
  position: relative;
}
.howto li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--coral);
}

.stage-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  height: 100%;
}

.crate {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  height: auto;
  padding: 0;
  border-radius: 4px 4px 18px 18px;
  background:
    linear-gradient(180deg, rgba(110, 184, 232, 0.55) 0%, rgba(255, 246, 228, 0.2) 28%, transparent 28%);
  border: 6px solid var(--wood-dark);
  box-shadow:
    inset 0 0 0 5px var(--wood),
    0 16px 0 rgba(58, 42, 24, 0.2);
  overflow: hidden;
}

.crate canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
  touch-action: none;
  image-rendering: auto;
}

.danger-label {
  pointer-events: none;
  position: absolute;
  left: 28px;
  top: 18%;
  color: var(--coral-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
  text-shadow: 0 1px 0 #fff6e4;
}

.order-strip {
  text-align: center;
}
.order-strip[hidden] { display: none; }
.order-strip p { margin: 0; }
.order-need {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  margin: 6px 0;
}
.order-need img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}
.order-need b { font-size: 18px; }
.order-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.hud-panel .stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.45);
  border: 2px solid rgba(139, 90, 43, 0.28);
  border-radius: 10px;
}
.hud-panel .stat span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.hud-panel .stat strong {
  font-size: 28px;
  color: #2f9b3a;
}
.hud-panel .next {
  display: grid;
  justify-items: center;
  gap: 6px;
  margin: 10px 0 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.5);
  border: 3px solid var(--panel-edge);
  border-radius: 12px;
}
.hud-panel .next span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.hud-panel .next img {
  width: 96px;
  height: 96px;
  object-fit: contain;
}

.dock {
  display: grid;
  gap: 8px;
}
.dock .btn { width: 100%; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(58, 42, 24, 0.35);
}
.overlay.show { display: grid; }

.card {
  width: min(420px, 100%);
  padding: 24px 20px 18px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fff1d2, #ffe0a8);
  border: 4px solid var(--panel-edge);
  box-shadow: var(--shadow);
  text-align: center;
}
.card.slim { padding: 22px 18px; }
.card h1, .card h2 { margin: 0 0 8px; line-height: 0.95; }
.card h1 { font-size: 52px; letter-spacing: -0.04em; }
.card .lede, .card p { margin: 0 0 14px; font-weight: 700; color: #4a3420; }
.card ul {
  margin: 0 0 14px;
  padding: 0 0 0 18px;
  text-align: left;
  font-weight: 700;
  line-height: 1.45;
}
.modes { display: grid; gap: 10px; margin: 16px 0 12px; }
.face {
  width: 84px;
  height: 84px;
  margin: 0 auto 8px;
  object-fit: contain;
  image-rendering: pixelated;
}
.linkish {
  display: block;
  margin: 8px auto 0;
  background: none;
  border: 0;
  font: inherit;
  font-weight: 800;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}
.end-score { font-size: 18px; }
.end-score strong { font-size: 28px; color: #2f9b3a; }

.evo {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin: 0 0 16px;
}
.evo img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
}
.toast {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--cream);
  font-weight: 800;
  border: 2px solid #1a120c;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    width: min(560px, calc(100% - 12px));
    height: auto;
    min-height: calc(100svh - 12px);
  }
  .left-panel { order: 2; height: auto; }
  .stage-wrap { order: 1; height: auto; }
  .hud-panel { order: 3; height: auto; }
  .crate {
    flex: none;
    height: min(68svh, 720px);
  }
  .howto li:nth-child(n + 3) { display: none; }
}

@media (max-height: 740px) and (min-width: 981px) {
  .layout { height: calc(100svh - 12px); margin: 6px auto; }
  .card h1 { font-size: 40px; }
}
