:root {
  --bg-top: #f0f7f2;
  --bg-bottom: #d9e7d8;
  --panel: #fff8ef;
  --panel-deep: #f4ead8;
  --ink: #2b2c33;
  --subtle: #6c6f79;
  --accent: #e26e52;
  --accent-strong: #cf5739;
  --mint: #4ca66a;
  --shadow: rgba(39, 38, 31, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(120% 130% at 20% 8%, #ffffff 0%, transparent 55%),
    radial-gradient(85% 95% at 90% 15%, #f9ffe3 0%, transparent 48%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--ink);
  font-family: "Trebuchet MS", "Gill Sans", Verdana, sans-serif;
}

#appShell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: 12px;
}

#topHud {
  display: grid;
  grid-template-columns: minmax(260px, 1.2fr) minmax(400px, 2fr);
  gap: 12px;
  align-items: stretch;
}

.brandWrap {
  background: linear-gradient(145deg, #fff4e4, #f7e7ca);
  border: 2px solid #f5e4c1;
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 10px 22px var(--shadow);
}

.brandWrap h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 1.9rem);
  letter-spacing: 0.02em;
}

.brandWrap p {
  margin: 8px 0 0;
  color: var(--subtle);
  font-size: 0.95rem;
}

.metricGrid {
  background: linear-gradient(145deg, #fff9f0, #f7eddc);
  border: 2px solid #f0ddbc;
  border-radius: 16px;
  box-shadow: 0 10px 22px var(--shadow);
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(5, minmax(90px, 1fr));
  gap: 8px;
}

.metricCard {
  background: linear-gradient(180deg, #fffaf4 0%, #f5e7ce 100%);
  border: 1px solid #e8d6b3;
  border-radius: 12px;
  padding: 8px;
  display: grid;
  gap: 6px;
  box-shadow: inset 0 1px 0 #fff;
}

.metricLabel {
  font-size: 0.75rem;
  color: #6b6d71;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metricCard strong {
  font-size: 1.08rem;
}

#mainLayout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(560px, 1fr) minmax(240px, 300px);
  gap: 12px;
}

#buildPanel,
#statusPanel {
  background: linear-gradient(170deg, var(--panel), var(--panel-deep));
  border: 2px solid #eedcbc;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 10px 22px var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#buildPanel h2,
#statusPanel h2 {
  margin: 2px 0 10px;
  font-size: 1.1rem;
}

#toolTabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.tabBtn {
  border: 1px solid #d9c8a9;
  background: #fff8eb;
  border-radius: 10px;
  color: #555651;
  padding: 7px 8px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

.tabBtn:hover {
  transform: translateY(-1px);
  background: #fff0d6;
}

.tabBtn.active {
  background: linear-gradient(180deg, #ffe39b, #f8c866);
  border-color: #d9a33a;
  color: #533617;
}

#toolList {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  overflow: auto;
  padding-right: 2px;
  max-height: 380px;
}

.toolBtn {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid #d8c7a8;
  border-radius: 12px;
  background: #fff9ee;
  color: #35363b;
  padding: 7px;
  cursor: pointer;
  text-align: left;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.toolBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 12px rgba(0, 0, 0, 0.08);
}

.toolBtn.active {
  border-color: #cb8f2f;
  background: linear-gradient(180deg, #ffe7b8, #ffd078);
}

.toolBtn img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.toolMeta {
  display: grid;
  gap: 2px;
}

.toolName {
  font-size: 0.88rem;
  font-weight: 700;
}

.toolType {
  font-size: 0.73rem;
  color: #6f6f70;
}

.toolCost {
  font-size: 0.83rem;
  font-weight: 700;
  color: #4b814e;
}

.toolBtn.locked {
  filter: grayscale(0.5);
  opacity: 0.72;
}

.panelNote {
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px dashed #d8c29a;
  background: #fff7e7;
}

.panelNote h3 {
  margin: 0 0 6px;
  font-size: 0.86rem;
}

.panelNote ul {
  margin: 0;
  padding-left: 16px;
  font-size: 0.8rem;
  color: #5f5f62;
  line-height: 1.35;
}

kbd {
  display: inline-block;
  border: 1px solid #c9c4ba;
  background: #f7f3ec;
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.72rem;
  padding: 1px 5px;
}

#playfieldWrap {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid #cfdecb;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 58%),
    linear-gradient(180deg, #b9d8bf, #86b084 62%, #79a177);
  box-shadow: 0 12px 24px var(--shadow);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#ticker {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(41, 64, 56, 0.62);
  color: #f4f6ed;
  font-size: 0.9rem;
  backdrop-filter: blur(2px);
}

#statusPanel {
  overflow: auto;
}

.statusBlock {
  border-radius: 12px;
  border: 1px solid #dcc9a8;
  background: #fff7ea;
  padding: 10px;
  margin-bottom: 10px;
}

.statusBlock h3 {
  margin: 0 0 7px;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #5b5f68;
}

.rideCard {
  border-radius: 9px;
  border: 1px solid #e1ceb1;
  background: #fffdf7;
  padding: 7px;
  margin-bottom: 6px;
  display: grid;
  gap: 5px;
}

.rideTop {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
}

.progressTrack {
  height: 8px;
  border-radius: 999px;
  background: #ebdfcb;
  overflow: hidden;
}

.progressFill {
  height: 100%;
  background: linear-gradient(90deg, #6bcf78, #42a963);
}

#guestStatus {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  color: #555a60;
}

#miniMap {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid #d1c2a7;
  background: #f2ead7;
}

@media (max-width: 1340px) {
  #mainLayout {
    grid-template-columns: minmax(220px, 250px) minmax(420px, 1fr);
    grid-template-areas:
      "build play"
      "status play";
  }

  #buildPanel {
    grid-area: build;
  }

  #statusPanel {
    grid-area: status;
  }

  #playfieldWrap {
    grid-area: play;
    min-height: 660px;
  }
}

@media (max-width: 980px) {
  #appShell {
    grid-template-rows: auto auto 1fr;
    padding: 8px;
  }

  #topHud {
    grid-template-columns: 1fr;
  }

  #mainLayout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "play"
      "build"
      "status";
  }

  #playfieldWrap {
    min-height: 58vh;
  }

  #buildPanel,
  #statusPanel {
    min-height: 0;
  }

  #toolList {
    max-height: 220px;
  }
}
