:root {
  color: #f9f1cf;
  background: #10231f;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  overflow: hidden;
  background: linear-gradient(145deg, #10231f 0%, #243d36 52%, #4b3430 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

.game-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100vw;
  height: 100vh;
}

.top-bar,
.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(16, 35, 31, 0.92);
  border-color: rgba(232, 202, 118, 0.28);
  border-style: solid;
  border-width: 0 0 1px;
  padding: 0.85rem clamp(1rem, 2.6vw, 2rem);
}

.bottom-bar {
  border-width: 1px 0 0;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.55rem;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  color: #f9f1cf;
  font-size: clamp(1.2rem, 2.4vw, 1.95rem);
  line-height: 1.05;
}

#room-objective {
  color: #efe0a8;
  font-size: clamp(0.9rem, 1.6vw, 1.05rem);
  margin-top: 0.3rem;
}

.icon-button,
.primary-action,
.puzzle-option,
.leaderboard-form button {
  display: grid;
  place-items: center;
  border: 1px solid rgba(232, 202, 118, 0.55);
  border-radius: 8px;
  color: #f9f1cf;
  background: #284942;
  cursor: pointer;
}

.icon-button {
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
}

.icon-button:hover,
.icon-button:focus-visible,
.primary-action:hover,
.primary-action:focus-visible,
.puzzle-option:hover,
.puzzle-option:focus-visible,
.leaderboard-form button:hover,
.leaderboard-form button:focus-visible {
  outline: none;
  background: #365c52;
}

.icon-button[aria-pressed="true"] {
  color: #243d36;
  background: #e8ca76;
}

.icon-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.stage {
  position: relative;
  overflow: hidden;
  width: min(100vw, calc((100vh - 10.5rem) * 3 / 4));
  aspect-ratio: var(--room-aspect, 16 / 9);
  align-self: center;
  justify-self: center;
  background-image: var(--room-image);
  background-position: var(--room-position, center);
  background-repeat: no-repeat;
  background-size: var(--room-size, cover);
  box-shadow: 0 1.2rem 4rem rgba(0, 0, 0, 0.34);
}

.hotspot {
  position: absolute;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.hotspot::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.9rem;
  height: 0.9rem;
  content: "";
  border: 2px solid #f9f1cf;
  border-radius: 50%;
  background: #b84f48;
  box-shadow: 0 0.2rem 0.75rem rgba(16, 35, 31, 0.45);
  transform: translate(-50%, -50%);
}

.hotspot::before {
  position: absolute;
  left: 50%;
  bottom: calc(50% + 0.9rem);
  max-width: 9rem;
  content: attr(data-label);
  border: 1px solid rgba(232, 202, 118, 0.45);
  border-radius: 8px;
  color: #f9f1cf;
  background: rgba(16, 35, 31, 0.92);
  box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.28);
  font-size: 0.72rem;
  line-height: 1.15;
  opacity: 0;
  padding: 0.32rem 0.45rem;
  pointer-events: none;
  text-align: center;
  transform: translateX(-50%);
  transition: opacity 0.14s ease;
  white-space: normal;
  z-index: 2;
}

.hotspot:hover,
.hotspot:focus-visible {
  outline: none;
}

.hotspot:hover::before,
.hotspot:focus-visible::before,
.stage.show-targets .hotspot::before {
  opacity: 1;
}

.stage.show-targets .hotspot {
  outline: 1px dashed rgba(232, 202, 118, 0.55);
  outline-offset: -1px;
  background: rgba(232, 202, 118, 0.06);
}

.stage.show-targets .hotspot::after,
.hotspot:hover::after,
.hotspot:focus-visible::after {
  width: 1.1rem;
  height: 1.1rem;
  background: #e8ca76;
}

.hotspot.is-solved {
  opacity: 0.55;
}

.hotspot.is-solved::after {
  background: #4f8f7f;
}

.message {
  min-height: 4rem;
  max-width: 52rem;
  color: #f9f1cf;
  font-size: clamp(1rem, 1.9vw, 1.35rem);
  line-height: 1.35;
}

.inventory-panel {
  flex: 0 0 auto;
}

.inventory-panel h2 {
  margin-bottom: 0.35rem;
  color: #efe0a8;
  font-size: 0.85rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.inventory {
  display: grid;
  grid-template-columns: repeat(6, minmax(3.1rem, 4.1rem));
  gap: 0.45rem;
}

.inventory-slot {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(232, 202, 118, 0.42);
  border-radius: 8px;
  background: #173630;
}

.inventory-slot img {
  width: 3.15rem;
  max-height: 1.9rem;
}

.inventory-slot span {
  max-width: 3.4rem;
  color: #f9f1cf;
  font-size: 0.61rem;
  line-height: 1;
  text-align: center;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.start-panel,
.win-panel,
.interaction-card {
  border: 3px solid #e8ca76;
  border-radius: 8px;
  color: #243d36;
  background: rgba(246, 231, 180, 0.96);
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.34);
}

.start-panel,
.win-panel {
  position: absolute;
  left: 50%;
  width: min(29rem, calc(100% - 1.2rem));
  max-height: calc(100% - 1.2rem);
  overflow: auto;
  padding: 1.35rem;
  text-align: center;
  transform: translateX(-50%);
}

.start-panel {
  top: 50%;
  transform: translate(-50%, -50%);
}

.win-panel {
  top: 50%;
  transform: translate(-50%, -50%);
}

.start-panel h2,
.win-panel h2,
.interaction-card h2 {
  color: #243d36;
  font-size: 1.55rem;
}

.start-panel p,
.win-panel p,
.interaction-card p {
  margin-top: 0.6rem;
  color: #365c52;
  font-size: 1rem;
  line-height: 1.4;
}

.primary-action {
  width: min(100%, 14rem);
  min-height: 2.9rem;
  margin: 1rem auto 0;
  font-weight: 700;
}

.interaction-dock {
  position: fixed;
  right: clamp(0.75rem, 2vw, 1.5rem);
  bottom: clamp(6.25rem, 14vh, 8rem);
  width: min(28rem, calc(100vw - 1.5rem));
  pointer-events: auto;
}

.interaction-card {
  position: relative;
  padding: 1rem;
}

.interaction-close {
  display: grid;
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 1.9rem;
  height: 1.9rem;
  place-items: center;
  border: 1px solid rgba(36, 61, 54, 0.35);
  border-radius: 8px;
  color: #243d36;
  background: #efe0a8;
  cursor: pointer;
}

.interaction-close:hover,
.interaction-close:focus-visible {
  outline: none;
  background: #e8ca76;
}

.puzzle-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 1rem;
}

.puzzle-option,
.leaderboard-form button {
  min-height: 2.75rem;
  padding: 0.4rem 0.55rem;
}

.puzzle-feedback {
  min-height: 1.4rem;
  font-weight: 700;
}

.puzzle-feedback.is-correct,
.leaderboard-saved {
  color: #2f6d5f;
}

.win-stats {
  font-weight: 700;
}

.leaderboard-form {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  margin-top: 1rem;
}

.leaderboard-form label {
  color: #243d36;
  font-weight: 700;
}

.leaderboard-form input {
  min-width: 0;
  height: 2.75rem;
  border: 1px solid rgba(36, 61, 54, 0.35);
  border-radius: 8px;
  color: #243d36;
  background: #fff8db;
  padding: 0 0.75rem;
}

.leaderboard-form input:focus {
  outline: 2px solid #4f8f7f;
  outline-offset: 2px;
}

.start-panel h3,
.win-panel h3 {
  margin-top: 1rem;
  color: #243d36;
  font-size: 1.05rem;
}

.leaderboard-list {
  display: grid;
  gap: 0.35rem;
  margin: 0.5rem 0 0;
  padding-left: 1.4rem;
  color: #365c52;
  text-align: left;
}

.leaderboard-list li {
  padding-left: 0.15rem;
}

.leaderboard-list strong {
  color: #243d36;
}

.leaderboard-list span {
  display: block;
  font-size: 0.85rem;
}

.shake {
  animation: shake 0.18s linear;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-0.45rem);
  }
  70% {
    transform: translateX(0.45rem);
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .game-shell {
    min-height: 100vh;
    height: auto;
  }

  .top-bar,
  .bottom-bar {
    align-items: flex-start;
  }

  .bottom-bar {
    flex-direction: column;
  }

  .stage {
    width: 100vw;
  }

  .message {
    min-height: 3rem;
  }

  .inventory-panel {
    width: 100%;
  }

  .inventory {
    grid-template-columns: repeat(6, minmax(2.7rem, 1fr));
    width: min(100%, 23rem);
  }

  .interaction-dock {
    right: 0.75rem;
    bottom: 1rem;
    width: calc(100vw - 1.5rem);
  }

  .puzzle-options,
  .leaderboard-form {
    grid-template-columns: 1fr;
  }
}
