@font-face {
  font-family: "Reference Sans";
  src: url("../font/LiberationSans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Reference Sans";
  src: url("../font/LiberationSans-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: "Reference Sans", system-ui, sans-serif;
  color: #25221e;
  background: #edf5f8;
  font-synthesis: none;
  --ink: #25221e;
  --muted: #5d574f;
  --line: #cfc6b8;
  --orange: #a34427;
  --blue: #145f79;
  --paper: #fffdf8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #edf5f8;
  line-height: 1.5;
}

button, a { font: inherit; }
button { touch-action: manipulation; }

button:focus-visible,
a:focus-visible {
  outline: 3px solid #9a5700;
  outline-offset: 3px;
}

.wrap {
  width: min(1080px, calc(100% - 48px));
  margin: 0 auto;
}

header {
  padding: 46px 0 40px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(36px, 6vw, 64px);
  line-height: .98;
  letter-spacing: -.045em;
}

.back {
  flex: 0 0 auto;
  margin-top: 7px;
  color: var(--ink);
  font-weight: 700;
  text-underline-offset: 3px;
}

main { padding: clamp(34px, 6vw, 64px) 0 70px; }

.toolbar,
.demo-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.toolbar { margin-bottom: 14px; }

.mode-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, .72);
}

.mode-switch button,
.sound-toggle,
#reset {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.mode-switch button[aria-pressed="true"],
.sound-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}

.sound-toggle {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.game-frame {
  overflow: hidden;
  border: 1px solid #aaa092;
  background: #111;
  box-shadow: 0 18px 42px rgba(45, 53, 56, .13);
}

.game-stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #111;
  user-select: none;
}

.scene {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.inventory-back {
  position: absolute;
  z-index: 4;
  left: 12.8125%;
  top: 6.25%;
  min-height: 6.25%;
  border: 1px solid #d2e6f2;
  padding: 0 14px;
  background: rgba(35, 92, 135, .96);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.inventory-back[hidden] { display: none; }

.toolbox {
  position: absolute;
  z-index: 3;
  left: 12.8125%;
  top: 14.3229%;
  width: 74.375%;
  aspect-ratio: 1108 / 797;
  overflow: hidden;
  background: #fff;
  container-type: inline-size;
}

.toolbox[hidden] { display: none; }

.toolbox::after {
  content: "";
  position: absolute;
  z-index: 4;
  inset: 0;
  box-shadow: inset 0 0 0 max(2px, .4706cqw) #111;
  pointer-events: none;
}

.menu-background,
.inventory-background,
.menu-button,
.menu-button img,
.inventory-item {
  position: absolute;
}

.menu-background,
.inventory-background {
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.menu-button {
  z-index: 2;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.menu-button img {
  display: block;
  max-width: none;
  pointer-events: none;
}

.menu-button .hover { opacity: 0; }
.menu-button.is-active .normal { opacity: 0; }
.menu-button.is-active .hover { opacity: 1; }

.menu-button:focus-visible {
  outline: max(2px, .45cqw) dashed #145f79;
  outline-offset: 0;
  border-radius: 38%;
}

.inventory-item {
  z-index: 2;
  display: block;
  object-fit: fill;
  pointer-events: none;
}

.demo-footer {
  min-height: 58px;
  border-bottom: 1px solid var(--line);
}

.demo-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.item-section {
  padding: clamp(42px, 6vw, 72px) 0 0;
}

.item-section h2 {
  margin: 0 0 22px;
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1;
  letter-spacing: -.03em;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.item-grid img {
  display: block;
  width: 100%;
  height: 220px;
  border: 1px solid var(--line);
  padding: 20px;
  background: #fffdf8;
  object-fit: contain;
}

#reset {
  flex: 0 0 auto;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 680px) {
  .wrap { width: min(100% - 28px, 1080px); }
  header { padding: 34px 0 30px; }
  .header-row { display: block; }
  .back { display: inline-block; margin-top: 20px; }
  .toolbar { align-items: stretch; }
  .mode-switch { flex: 1 1 auto; }
  .mode-switch button { flex: 1 1 50%; padding: 0 9px; font-size: 13px; }
  .sound-toggle { flex: 0 0 auto; padding: 0 11px; font-size: 13px; }
  .demo-footer { align-items: flex-start; padding: 13px 0; }
  .demo-footer p { font-size: 13px; }
  .inventory-back { padding: 0 8px; font-size: 11px; }
  .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .item-grid img { height: 150px; padding: 12px; }
}
