:root {
  color-scheme: dark;
  --night: #15191f;
  --night-2: #1a1f27;
  --stone: #8b8b8b;
  --stone-light: #b3b3b3;
  --stone-dark: #555;
  --panel: #c6c6c6;
  --panel-text: #3b3b3b;
  --panel-muted: #5f5f5f;
  --outline: #000;
  --grass: #5d9e2f;
  --grass-dark: #3f7a1c;
  --dirt: #7a5232;
  --dirt-dark: #5c3b22;
  --gold: #f6c548;
  --gold-dark: #c08a12;
  --green-ok: #2f6f17;
  --amber: #8a5500;
  --red: #a3241d;
  --pixel: "Pixelify Sans", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --mc-safe-width: calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  --mc-safe-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  font-family: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--night);
  color: #eee;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { width: 100%; min-height: 100%; }

body {
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  /* A faint 16px block grid on a night sky, drawn in CSS (no game textures). */
  background:
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(180deg, #10141a 0%, var(--night) 40%, var(--night-2) 100%);
}

body[data-game-active="true"] { background: #000; }

button, a { font: inherit; }

#minecraft-canvas {
  position: fixed;
  z-index: 1;
  top: env(safe-area-inset-top, 0px);
  left: env(safe-area-inset-left, 0px);
  width: var(--mc-safe-width);
  height: var(--mc-safe-height);
  image-rendering: pixelated;
  background: #000;
  touch-action: none;
}

/* ---- Layout ---- */

.site { display: flex; justify-content: center; padding: clamp(24px, 6vh, 64px) 16px 40px; }
.site-shell { display: grid; gap: 18px; width: min(720px, 100%); }

.hero { display: grid; justify-items: center; gap: 6px; text-align: center; }

.kicker {
  margin: 0;
  color: #7f8894;
  font: 500 12px/1.2 var(--pixel);
  letter-spacing: .2em;
}

.logo {
  margin: 4px 0 0;
  color: #f2f2f2;
  font: 700 clamp(64px, 14vw, 120px)/.9 var(--pixel);
  letter-spacing: .04em;
  /* Stacked hard shadows give the chunky extruded title look. */
  text-shadow:
    0 4px 0 #9a9a9a,
    0 8px 0 #5b5b5b,
    0 12px 0 #2c2c2c,
    0 18px 24px rgba(0, 0, 0, .55);
}

.tagline {
  margin: 14px 0 0;
  color: #b9c0c9;
  font-size: clamp(15px, 2vw, 18px);
}

/* ---- Fullscreen banner ---- */

.fullscreen-banner {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
  margin-top: 8px;
  padding: 22px 22px 20px;
  border: 4px solid var(--outline);
  background: var(--gold);
  color: #241a00;
  box-shadow: inset 4px 4px 0 #ffe08a, inset -4px -4px 0 var(--gold-dark), 0 6px 0 #000;
}

.fullscreen-banner::before {
  content: "";
  position: absolute;
  inset: -4px -4px auto;
  height: 10px;
  border: 4px solid var(--outline);
  border-bottom: 0;
  background: repeating-linear-gradient(135deg, #1d1d1d 0 12px, var(--gold) 12px 24px);
}

.fullscreen-banner h2 {
  margin: 0 0 6px;
  font: 700 clamp(26px, 4.6vw, 40px)/1 var(--pixel);
  text-transform: uppercase;
}

.fullscreen-banner p { margin: 0; font-size: 16px; line-height: 1.55; }

/* Four corner brackets: the usual "enter fullscreen" glyph, drawn with borders. */
.fullscreen-icon {
  position: relative;
  width: 56px;
  height: 56px;
}
.fullscreen-icon span {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 0 solid #241a00;
}
.fullscreen-icon span:nth-child(1) { top: 0; left: 0; border-top-width: 7px; border-left-width: 7px; }
.fullscreen-icon span:nth-child(2) { top: 0; right: 0; border-top-width: 7px; border-right-width: 7px; }
.fullscreen-icon span:nth-child(3) { bottom: 0; left: 0; border-bottom-width: 7px; border-left-width: 7px; }
.fullscreen-icon span:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 7px; border-right-width: 7px; }

kbd {
  display: inline-block;
  padding: 0 6px;
  border: 2px solid #241a00;
  border-bottom-width: 4px;
  background: #fff3cf;
  font: 700 13px/1.4 var(--pixel);
}

/* A grass-block strip between the hero and the steps. */
.grass-edge {
  height: 40px;
  margin: 8px 0 -4px;
  border: 4px solid var(--outline);
  background:
    linear-gradient(#7cc046 0 3px, var(--grass) 3px 10px, transparent 10px),
    repeating-linear-gradient(90deg, var(--grass-dark) 0 8px, transparent 8px 20px, var(--grass) 20px 24px, transparent 24px 32px) 0 10px / 100% 6px no-repeat,
    repeating-linear-gradient(90deg, transparent 0 12px, rgba(0, 0, 0, .22) 12px 16px, transparent 16px 28px) 0 22px / 100% 4px no-repeat,
    repeating-linear-gradient(90deg, transparent 0 20px, rgba(255, 255, 255, .12) 20px 24px, transparent 24px 36px) 0 28px / 100% 4px no-repeat,
    var(--dirt);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .6);
}

/* ---- Panels (inventory-style bevel) ---- */

.panel {
  padding: 20px 22px 22px;
  border: 4px solid var(--outline);
  background: var(--panel);
  color: var(--panel-text);
  box-shadow: inset 4px 4px 0 #fff, inset -4px -4px 0 var(--stone-dark), 0 6px 0 rgba(0, 0, 0, .6);
}

.panel h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  color: #262626;
  font: 700 24px/1.1 var(--pixel);
}

.step-number {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 3px solid var(--outline);
  background: var(--stone);
  color: #fff;
  font: 700 18px/1 var(--pixel);
  text-shadow: 2px 2px 0 #3a3a3a;
  box-shadow: inset 2px 2px 0 var(--stone-light), inset -2px -2px 0 var(--stone-dark);
}

.panel p { margin: 0 0 12px; font-size: 15px; line-height: 1.5; }
.panel p:last-child { margin-bottom: 0; }
.panel code { padding: 1px 5px; background: #a9a9a9; color: #1e1e1e; font: 600 13px/1.4 ui-monospace, Consolas, monospace; }
.panel strong { color: #1e1e1e; }

.panel label {
  display: block;
  margin-bottom: 6px;
  color: #3b3b3b;
  font: 700 14px/1.2 var(--pixel);
}

.mc-input {
  width: min(360px, 100%);
  padding: 10px 12px;
  border: 3px solid #a0a0a0;
  outline: 3px solid var(--outline);
  background: #000;
  color: #fff;
  font: 500 18px/1.2 var(--pixel);
}
.mc-input:focus { border-color: #fff; }
.mc-input:disabled { color: #8f8f8f; }

.fine-print { margin-top: 10px; color: var(--panel-muted); font-size: 13px; line-height: 1.45; }
.panel .fine-print { font-size: 13px; color: var(--panel-muted); }

.dev-status { margin: 12px 0 0; color: #4a4a4a; font: 500 14px/1.45 var(--pixel); }
.dev-status[data-state="reading"] { color: var(--amber); }
.dev-status[data-state="accepted"] { color: var(--green-ok); }
.dev-status[data-state="locked"] { color: var(--red); }

/* ---- Buttons (stone button with a bevel and a hard outline) ---- */

.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 4px; }

.mc-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 18px;
  border: 3px solid var(--outline);
  background: var(--stone);
  color: #fff;
  font: 700 16px/1.1 var(--pixel);
  letter-spacing: .03em;
  text-decoration: none;
  text-shadow: 2px 2px 0 #3a3a3a;
  box-shadow: inset 3px 3px 0 var(--stone-light), inset -3px -4px 0 var(--stone-dark);
  cursor: pointer;
}
.mc-button:hover:not(:disabled) {
  background: #7c86c4;
  box-shadow: inset 3px 3px 0 #aab3ee, inset -3px -4px 0 #4a5290;
}
.mc-button:active:not(:disabled) {
  box-shadow: inset -3px -3px 0 var(--stone-light), inset 3px 4px 0 var(--stone-dark);
  transform: translateY(2px);
}
.mc-button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.mc-button:disabled {
  background: #6a6a6a;
  color: #a5a5a5;
  text-shadow: none;
  box-shadow: inset 3px 3px 0 #7a7a7a, inset -3px -4px 0 #4f4f4f;
  cursor: default;
}

.mc-button-green {
  background: #4f9b2c;
  box-shadow: inset 3px 3px 0 #86cf5c, inset -3px -4px 0 #2e6614;
}
.mc-button-green:hover:not(:disabled) {
  background: #5cb233;
  box-shadow: inset 3px 3px 0 #9ae06f, inset -3px -4px 0 #357519;
}

.mc-button-big { width: 100%; min-height: 64px; font-size: 26px; }
.mc-button-small { min-height: 36px; padding: 6px 12px; font-size: 13px; }

.text-button {
  border: 0;
  background: none;
  color: #4a4a4a;
  font: 500 14px/1.4 var(--pixel);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.dev-progress {
  width: 100%;
  height: 16px;
  margin-top: 10px;
  padding: 2px;
  border: 3px solid var(--outline);
  background: #3a3a3a;
}
.dev-progress span { display: block; width: 0; height: 100%; background: var(--grass); box-shadow: inset 0 3px 0 #86cf5c; }

/* ---- Folds ---- */

.fold { margin-top: 16px; }
.fold summary {
  cursor: pointer;
  color: #3b3b3b;
  font: 700 14px/1.4 var(--pixel);
  letter-spacing: .05em;
}
.fold > p { margin-top: 10px; }
.fold-panel { margin-top: 0; padding-top: 14px; padding-bottom: 14px; }
.fold-panel[open] summary { margin-bottom: 6px; }

.dev-command-group { display: grid; gap: 6px; margin-top: 12px; }
.dev-command-label { margin: 6px 0 0 !important; color: #4a4a4a; font: 700 12px/1.2 var(--pixel); }
.dev-command { display: flex; min-width: 0; border: 3px solid var(--outline); background: #1e1e1e; }
.dev-command code { flex: 1 1 auto; min-width: 0; overflow-x: auto; padding: 10px; background: none; color: #e6e6e6; white-space: nowrap; }
.dev-copy {
  flex: 0 0 auto;
  min-width: 64px;
  border: 0;
  border-left: 3px solid var(--outline);
  background: var(--stone);
  color: #fff;
  font: 700 12px/1 var(--pixel);
  cursor: pointer;
}
.dev-copy:hover { background: #7c86c4; }

.runtime-diagnostics ol {
  max-height: 180px;
  overflow: auto;
  margin: 10px 0;
  padding: 8px 8px 8px 28px;
  border: 3px solid var(--outline);
  background: #1e1e1e;
  color: #d8d8d8;
  font: 12px/1.45 ui-monospace, Consolas, monospace;
}
.runtime-diagnostics ol:empty { display: none; }
.runtime-diagnostics li { margin: 2px 0; overflow-wrap: anywhere; }

/* ---- Resource packs ---- */

.pack-manager { margin-top: 16px; }
.pack-toggle {
  border: 0;
  background: none;
  color: #3b3b3b;
  font: 700 14px/1.4 var(--pixel);
  letter-spacing: .05em;
  cursor: pointer;
}
.pack-toggle::after { content: " ▾"; }
.pack-toggle[aria-expanded="true"]::after { content: " ▴"; }
.pack-body { display: grid; gap: 8px; margin-top: 10px; }
.pack-drop {
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 18px;
  border: 3px dashed #6b6b6b;
  background: #b5b5b5;
  text-align: center;
}
.pack-drop-active { border-color: var(--grass-dark); background: #c5dbb6; }
.pack-hint { margin: 0 !important; }
.pack-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.pack-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.pack-list li {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border: 3px solid var(--outline);
  background: #8b8b8b;
  color: #fff;
  font: 500 14px/1.2 var(--pixel);
}
.pack-list span { color: #e3e3e3; }
.pack-remove {
  padding: 4px 10px;
  border: 2px solid var(--outline);
  background: var(--red);
  color: #fff;
  font: 700 12px/1 var(--pixel);
  cursor: pointer;
}

/* ---- Footer ---- */

.site-footer { display: grid; gap: 8px; justify-items: center; margin-top: 10px; text-align: center; }
.disclaimer { max-width: 560px; margin: 0; color: #7f8894; font: 500 11px/1.5 var(--pixel); letter-spacing: .05em; }
.credit { margin: 0; color: #7f8894; font-size: 13px; }
.credit a { color: #b9c0c9; text-underline-offset: 3px; }

/* ---- In-game "left fullscreen" overlay ---- */

.fullscreen-return {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .72);
}
.fullscreen-return-panel { display: grid; gap: 12px; width: min(460px, 100%); text-align: center; }
.fullscreen-return-panel h2 { justify-content: center; margin-bottom: 0; }

#failure {
  position: fixed;
  z-index: 90;
  inset: auto 16px 16px;
  max-height: 30vh;
  overflow: auto;
  padding: 14px;
  border: 3px solid var(--outline);
  background: #2f0908;
  color: #ffd8d6;
  font: 11px/1.45 ui-monospace, Consolas, monospace;
  white-space: pre-wrap;
}

@media (max-width: 560px) {
  .fullscreen-banner { grid-template-columns: 1fr; justify-items: start; }
  .fullscreen-icon { width: 40px; height: 40px; }
  .fullscreen-icon span { width: 14px; height: 14px; }
  .panel { padding: 16px 16px 18px; }
  .button-row .mc-button { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
