:root {
  color-scheme: dark;
  font-family:
    ui-rounded,
    "SF Pro Rounded",
    "Avenir Next",
    system-ui,
    sans-serif;
  background: #1f2425;
  color: #eadbb4;
  touch-action: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

button {
  border: 0;
  font: inherit;
}

.game-shell {
  position: fixed;
  inset: 0;
  min-height: 100svh;
  background: #252827;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}

.start-menu {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(31, 36, 37, 0.72), rgba(31, 36, 37, 0.9)),
    radial-gradient(circle at 50% 24%, rgba(168, 63, 54, 0.25), transparent 42%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.start-menu.is-open {
  opacity: 1;
  pointer-events: auto;
}

.start-panel,
.how-to-panel {
  width: min(420px, calc(100vw - 28px));
  border: 2px solid #4d4339;
  border-radius: 8px;
  background: #2c302d;
  box-shadow: 0 6px 0 #171918;
}

.start-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.start-logo {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 14px 8px 10px;
  color: #eadbb4;
  text-align: center;
}

.start-star {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 3px solid #4d4339;
  border-radius: 50%;
  background: #a83f36;
  color: #d6a741;
  box-shadow: 0 4px 0 #171918;
  font-size: 28px;
  font-weight: 950;
}

.start-logo h1 {
  margin: 0;
  color: #eadbb4;
  font-size: 42px;
  font-weight: 950;
  line-height: 0.95;
  text-transform: uppercase;
}

.start-logo p {
  margin: 0;
  color: #c7b58f;
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.start-actions {
  display: grid;
  gap: 10px;
}

.start-button {
  min-height: 48px;
  border: 2px solid #4d4339;
  border-radius: 8px;
  background: #c7b58f;
  color: #2d2822;
  box-shadow: 0 4px 0 #171918;
  font-size: 13px;
  font-weight: 950;
}

.start-button.is-primary {
  background: #d6a741;
}

.start-button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #171918;
}

.start-button[hidden] {
  display: none;
}

.how-to-panel {
  position: absolute;
  left: 50%;
  top: max(52px, calc(env(safe-area-inset-top) + 52px));
  z-index: 32;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: min(72svh, 560px);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition:
    transform 150ms ease,
    opacity 150ms ease;
}

.how-to-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.how-to-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  padding: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.how-to-list article {
  padding: 9px;
  border: 2px solid #4d4339;
  border-radius: 8px;
  background: #c7b58f;
  color: #2d2822;
}

.how-to-list h3,
.how-to-list p {
  margin: 0;
}

.how-to-list h3 {
  font-size: 13px;
  font-weight: 950;
}

.how-to-list p {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.news-ticker {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: 34px;
  border: 2px solid #4d4339;
  border-radius: 8px;
  background: #263331;
  box-shadow: 0 4px 0 #171918;
  overflow: hidden;
}

.ticker-label {
  align-self: stretch;
  display: grid;
  place-items: center;
  padding: 0 9px;
  background: #a83f36;
  color: #eadbb4;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ticker-track {
  min-width: 0;
  overflow: hidden;
}

.ticker-track p {
  width: max-content;
  margin: 0;
  padding-left: 100%;
  color: #eadbb4;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
  animation: ticker-scroll 18s linear infinite;
}

@keyframes ticker-scroll {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-100%);
  }
}

.bottom-bar {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 8;
  display: grid;
  grid-template-columns: 72px 54px minmax(0, 1fr);
  gap: 8px;
}

.nav-button,
.resource-strip,
.icon-button,
.tier-tab,
.info-tab,
.room-card,
.resource-card,
.synergy-card {
  border: 2px solid #4d4339;
  border-radius: 8px;
  box-shadow: 0 4px 0 #171918;
}

.nav-button,
.tier-tab,
.info-tab {
  min-width: 0;
  min-height: 54px;
  background: #c7b58f;
  color: #2d2822;
  font-weight: 950;
}

.nav-button {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 6px 4px;
  font-size: 11px;
  line-height: 1;
}

.nav-button:active,
.nav-button.is-active,
.tier-tab.is-active,
.info-tab.is-active {
  transform: translateY(3px);
  background: #d6a741;
  box-shadow: 0 1px 0 #171918;
}

.nav-icon {
  width: 25px;
  height: 20px;
  border: 2px solid #26231f;
  image-rendering: pixelated;
}

.nav-icon.rooms {
  background:
    linear-gradient(90deg, #4f6f74 0 30%, transparent 30% 35%, #7f4d41 35% 65%, transparent 65% 70%, #667b52 70%),
    #bfb196;
}

.nav-icon.info {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #33413f;
  color: #eadbb4;
  font-size: 16px;
  font-weight: 950;
  line-height: 1;
}

.resource-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 54px;
  padding: 5px;
  background: #33413f;
  color: #eadbb4;
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
}

.resource-strip:focus-visible {
  outline: 3px solid #d6a741;
  outline-offset: 3px;
}

.resource-strip span {
  min-width: 0;
  padding: 5px 3px;
  border: 2px solid #4d4339;
  border-radius: 6px;
  background: #263331;
  color: #eadbb4;
  font-size: clamp(8px, 2.35vw, 10px);
  font-weight: 950;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.room-menu,
.info-menu {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(max(10px, env(safe-area-inset-bottom)) + 70px);
  z-index: 7;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  max-height: min(62svh, 520px);
  border: 2px solid #4d4339;
  border-radius: 8px;
  background: #2c302d;
  box-shadow: 0 5px 0 #171918;
  overflow: hidden;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 150ms ease,
    opacity 150ms ease;
}

.info-menu {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.room-menu.is-open,
.info-menu.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.room-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 8px;
  border-bottom: 2px solid #4d4339;
  background: #c7b58f;
  color: #2d2822;
}

.kicker,
.room-menu h2 {
  margin: 0;
  line-height: 1;
}

.kicker {
  margin-bottom: 5px;
  color: #6f4d3c;
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}

.room-menu h2 {
  font-size: 18px;
}

.icon-button {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  background: #a83f36;
  color: #eadbb4;
  font-size: 22px;
  font-weight: 950;
  line-height: 1;
}

.room-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  background: #242826;
}

.info-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  background: #242826;
}

.tier-tab,
.info-tab {
  min-height: 36px;
  padding: 5px 3px;
  font-size: 10px;
}

.tier-tab:disabled {
  filter: grayscale(0.65);
  opacity: 0.55;
}

.room-list {
  display: grid;
  gap: 8px;
  padding: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.info-list {
  display: grid;
  gap: 8px;
  padding: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.notification-stack {
  position: absolute;
  left: 10px;
  right: 10px;
  top: calc(max(8px, env(safe-area-inset-top)) + 42px);
  z-index: 9;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.notification {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 48px;
  padding: 8px;
  border: 2px solid #4d4339;
  border-radius: 8px;
  background: #c7b58f;
  color: #2d2822;
  box-shadow: 0 4px 0 #171918;
  animation: notification-in 160ms ease-out both;
}

.notification.is-warning {
  background: #d6a741;
}

.notification.is-danger {
  background: #a83f36;
  color: #eadbb4;
}

.notification.is-success {
  background: #9eaa83;
}

.notification-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid #4d4339;
  border-radius: 6px;
  background: #33413f;
  color: #eadbb4;
  font-size: 13px;
  font-weight: 950;
}

.notification-copy {
  min-width: 0;
  margin: 0;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.event-choice {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(max(10px, env(safe-area-inset-bottom)) + 78px);
  z-index: 10;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 2px solid #4d4339;
  border-radius: 8px;
  background: #c7b58f;
  color: #2d2822;
  box-shadow: 0 5px 0 #171918;
  transform: translateY(14px);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 150ms ease,
    opacity 150ms ease;
}

.event-choice.is-open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.event-kicker,
.event-choice h2,
.event-choice p {
  margin: 0;
}

.event-kicker {
  color: #74312d;
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}

.event-choice h2 {
  margin-top: 4px;
  font-size: 16px;
  line-height: 1.05;
}

#eventDescription {
  margin-top: 5px;
  color: #3a332b;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.2;
}

.event-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.event-action {
  min-height: 38px;
  padding: 7px 6px;
  border: 2px solid #4d4339;
  border-radius: 8px;
  background: #33413f;
  color: #eadbb4;
  box-shadow: 0 3px 0 #171918;
  font-size: 10px;
  font-weight: 950;
}

.event-action:disabled {
  opacity: 0.55;
  filter: grayscale(0.5);
}

@keyframes notification-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.room-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 58px;
  gap: 8px;
  align-items: start;
  min-height: 84px;
  padding: 8px;
  background: #c7b58f;
  color: #2d2822;
  text-align: left;
}

.synergy-card {
  display: grid;
  gap: 6px;
  min-width: 0;
  min-height: 72px;
  padding: 9px;
  background: #c7b58f;
  color: #2d2822;
}

.resource-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 72px;
  padding: 9px;
  background: #c7b58f;
  color: #2d2822;
}

.resource-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid #4d4339;
  border-radius: 6px;
  background: #33413f;
  color: #eadbb4;
  font-size: 14px;
  font-weight: 950;
}

.resource-copy {
  min-width: 0;
}

.resource-name,
.resource-use,
.resource-source,
.resource-generation,
.resource-amount {
  margin: 0;
}

.resource-name {
  font-size: 13px;
  font-weight: 950;
  line-height: 1.05;
}

.resource-use,
.resource-source,
.resource-generation {
  margin-top: 3px;
  color: #3a332b;
  font-size: 10px;
  font-weight: 850;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.resource-source {
  color: #5b4437;
}

.resource-generation {
  color: #33413f;
  line-height: 1.25;
}

.resource-generation strong {
  color: #171918;
  font-weight: 950;
}

.resource-amount {
  grid-column: 1 / -1;
  justify-self: end;
  max-width: 100%;
  padding: 4px 5px;
  border: 2px solid #4d4339;
  border-radius: 6px;
  background: #33413f;
  color: #eadbb4;
  font-size: 10px;
  font-weight: 950;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info-action {
  cursor: pointer;
}

.info-action:disabled {
  opacity: 0.62;
  filter: grayscale(0.45);
}

.synergy-title,
.synergy-components,
.synergy-benefit {
  margin: 0;
}

.synergy-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  font-size: 13px;
  font-weight: 950;
  line-height: 1.05;
}

.synergy-title span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.synergy-tier {
  flex: 0 0 auto;
  padding: 3px 5px;
  border: 2px solid #4d4339;
  border-radius: 6px;
  background: #33413f;
  color: #eadbb4;
  font-size: 9px;
}

.synergy-components {
  color: #5b4437;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.synergy-benefit {
  color: #3a332b;
  font-size: 10px;
  font-weight: 850;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.room-card.is-selected {
  background: #d6a741;
}

.room-card.is-unaffordable:not(.is-selected) {
  background: #b7a98a;
}

.room-card:disabled {
  opacity: 0.58;
  filter: grayscale(0.55);
}

.room-swatch {
  position: relative;
  width: 30px;
  height: 30px;
  border: 2px solid #26231f;
  background:
    linear-gradient(0deg, var(--room-floor) 0 28%, transparent 28%),
    linear-gradient(90deg, transparent 0 12%, var(--room-accent) 12% 30%, transparent 30% 42%, var(--room-trim) 42% 58%, transparent 58% 70%, var(--room-accent) 70% 88%, transparent 88%),
    var(--room-back, #bfb196);
  box-shadow:
    inset 0 4px 0 var(--room-roof, #875a4b),
    inset 0 6px 0 #26231f,
    inset -4px 0 0 rgba(38, 35, 31, 0.24),
    inset 0 -3px 0 rgba(38, 35, 31, 0.28);
  image-rendering: pixelated;
  overflow: hidden;
}

.room-swatch::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 11px;
  width: 7px;
  height: 7px;
  border: 1px solid #26231f;
  background: var(--room-accent, #4f6f74);
  box-shadow: 11px 0 0 var(--room-trim, #7f4d41);
}

.room-swatch::after {
  content: attr(data-sign);
  position: absolute;
  left: 3px;
  right: 3px;
  top: 4px;
  color: #eadbb4;
  font-size: 6px;
  font-weight: 950;
  line-height: 1;
  text-align: center;
  text-shadow: 1px 1px 0 #26231f;
}

.room-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.room-name,
.room-meta,
.room-function,
.room-cost {
  margin: 0;
}

.room-name {
  font-size: 13px;
  font-weight: 950;
  line-height: 1.12;
}

.room-meta,
.room-function,
.room-cost,
.room-lock {
  font-size: 10px;
  font-weight: 850;
  line-height: 1.2;
}

.room-meta {
  color: #5b4437;
}

.room-function {
  color: #3a332b;
  overflow-wrap: anywhere;
}

.room-cost {
  color: #74312d;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.room-lock {
  align-self: center;
  justify-self: end;
  max-width: 100%;
  padding: 4px 5px;
  border: 2px solid #4d4339;
  border-radius: 6px;
  background: #33413f;
  color: #eadbb4;
}

@media (min-width: 720px) {
  .news-ticker {
    left: 18px;
    right: 18px;
  }

  .bottom-bar,
  .room-menu,
  .info-menu,
  .notification-stack,
  .event-choice {
    left: 50%;
    right: auto;
    width: min(520px, calc(100vw - 24px));
    transform: translateX(-50%);
  }

  .event-choice {
    transform: translateX(-50%) translateY(14px);
  }

  .event-choice.is-open {
    transform: translateX(-50%) translateY(0);
  }

  .room-menu,
  .info-menu {
    transform: translate(-50%, 16px);
  }

  .room-menu.is-open,
  .info-menu.is-open {
    transform: translate(-50%, 0);
  }
}
