/* ---- Minecraft clone UI ---- */
@font-face { font-family: 'mc'; src: local('monospace'); }

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #000; }
body { font-family: 'Courier New', monospace; user-select: none; -webkit-user-select: none; }

#game { position: fixed; inset: 0; }
#glcanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#hud { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }
#hud.interactive { pointer-events: auto; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 10; }
.hidden { display: none !important; }
.dim { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.dim.red { background: rgba(120,0,0,0.5); }
.dirt-bg, .panorama { position: absolute; inset: 0; background: #3b2d1f; image-rendering: pixelated; }

.title-logo {
  position: relative; font-size: clamp(42px, 9vw, 96px); font-weight: bold; letter-spacing: 0.06em;
  color: #d8d8d8; -webkit-text-stroke: 3px #3f3f3f;
  text-shadow: 0 6px 0 #2a2a2a, 0 0 24px rgba(0,0,0,0.8);
  margin-bottom: 4px; font-family: 'Arial Black', 'Courier New', monospace;
}
.title-sub {
  position: relative; color: #ffff55; font-size: 18px; font-weight: bold;
  text-shadow: 2px 2px 0 #3f3f00; transform: rotate(-4deg); margin-bottom: 30px;
  animation: splashPulse 0.9s ease-in-out infinite alternate;
}
@keyframes splashPulse { from { transform: rotate(-4deg) scale(1); } to { transform: rotate(-4deg) scale(1.07); } }

.menu-col { position: relative; display: flex; flex-direction: column; gap: 10px; width: 340px; align-items: stretch; z-index: 2; }
.menu-col.wide { width: 460px; max-height: 86vh; overflow-y: auto; }
.menu-title { text-align: center; color: #fff; font-size: 22px; font-weight: bold; text-shadow: 2px 2px 0 #3f3f3f; margin-bottom: 8px; }
.menu-title.big { font-size: 42px; }
.menu-sub { text-align: center; color: #ddd; font-size: 15px; text-shadow: 1px 1px 0 #333; margin-bottom: 10px; }

.mc-btn {
  display: block; width: 100%; padding: 11px 8px; cursor: pointer;
  font-family: inherit; font-size: 16px; font-weight: bold; color: #e0e0e0;
  background: linear-gradient(#8b8b8b, #6f6f6f 45%, #5a5a5a);
  border: 2px solid #000; box-shadow: inset 2px 2px 0 rgba(255,255,255,0.35), inset -2px -2px 0 rgba(0,0,0,0.35);
  text-shadow: 2px 2px 0 #383838;
}
.mc-btn:hover { background: linear-gradient(#9aa4c0, #7f89a8 45%, #6a7490); color: #ffffa0; }
.mc-btn:active { box-shadow: inset -2px -2px 0 rgba(255,255,255,0.25), inset 2px 2px 0 rgba(0,0,0,0.4); }
.mc-btn.small { font-size: 13px; padding: 8px 4px; }

#seedInput {
  padding: 10px; font-family: inherit; font-size: 15px; background: #000; color: #e0e0e0;
  border: 2px solid #a0a0a0; outline: none;
}
#seedInput:focus { border-color: #fff; }

.title-footer {
  position: absolute; bottom: 8px; left: 10px; right: 10px; display: flex; justify-content: space-between;
  color: #ccc; font-size: 12px; text-shadow: 1px 1px 0 #222; z-index: 2;
}

.opt-row { display: flex; flex-direction: column; gap: 4px; color: #eee; font-size: 14px; font-weight: bold; text-shadow: 1px 1px 0 #333; }
.opt-row label { display: block; text-align: center; }
/* Minecraft-style slider: recessed dark bar, button-textured handle, label on the bar */
.mc-slider { position: relative; width: 100%; }
.mc-slider label {
  position: absolute; inset: 0; text-align: center; line-height: 42px;
  pointer-events: none; color: #e0e0e0; font-size: 16px; font-weight: bold; text-shadow: 2px 2px 0 #383838;
}
.mc-slider input[type=range] {
  -webkit-appearance: none; appearance: none; outline: none;
  display: block; width: 100%; height: 42px; margin: 0; cursor: pointer;
  background: linear-gradient(#4e4e4e, #5f5f5f 55%, #6d6d6d);
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,0.45), inset -2px -2px 0 rgba(255,255,255,0.15);
}
.mc-slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 34px; border-radius: 0;
  background: linear-gradient(#8b8b8b, #6f6f6f 45%, #5a5a5a);
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.35), inset -2px -2px 0 rgba(0,0,0,0.35);
}
.mc-slider input[type=range]::-moz-range-track { background: transparent; }
.mc-slider input[type=range]::-moz-range-thumb {
  width: 12px; height: 30px; border-radius: 0;
  background: linear-gradient(#8b8b8b, #6f6f6f 45%, #5a5a5a);
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.35), inset -2px -2px 0 rgba(0,0,0,0.35);
}
.mc-slider input[type=range]:hover::-webkit-slider-thumb { background: linear-gradient(#9aa4c0, #7f89a8 45%, #6a7490); }
.mc-slider input[type=range]:hover::-moz-range-thumb { background: linear-gradient(#9aa4c0, #7f89a8 45%, #6a7490); }
.mc-slider:hover label { color: #ffffa0; }
.opt-row .mc-btn { margin-top: 2px; }
.opt-row { flex-direction: column; }
.opt-row:has(button) { flex-direction: row; gap: 8px; }

.controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; color: #ddd; font-size: 14px; text-shadow: 1px 1px 0 #222; margin-bottom: 10px; }
.controls-grid .key { color: #ffff88; font-weight: bold; text-align: right; }

.loadbar { height: 12px; background: #222; border: 2px solid #888; }
#loadbarFill { height: 100%; width: 0%; background: #4c9e4c; transition: width 0.15s; }

.opt-note { color: #b8b8b8; font-size: 11px; text-align: center; text-shadow: 1px 1px 0 #222; line-height: 1.5; }

/* ---- field guide / wiki ---- */
.wiki-panel {
  position: relative; z-index: 2; display: flex; flex-direction: column; gap: 10px;
  width: min(900px, 94vw); max-height: 90vh;
}
.wiki-wrap {
  display: flex; gap: 10px; flex: 1; min-height: 0;
  height: 74vh;
  border: 2px solid #000; background: rgba(10,10,14,0.72);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.12), inset -2px -2px 0 rgba(0,0,0,0.5);
}
.wiki-nav { width: 218px; flex-shrink: 0; display: flex; flex-direction: column; border-right: 2px solid #000; }
.wiki-search {
  margin: 8px; padding: 7px 8px; font: 13px 'Courier New', monospace;
  background: #000; color: #e0e0e0; border: 2px solid #888; outline: none;
}
.wiki-search:focus { border-color: #fff; }
.wiki-list { overflow-y: auto; padding: 0 6px 8px; flex: 1; }
.wiki-cat {
  color: #ffd24a; font-size: 11px; font-weight: bold; letter-spacing: 1px;
  text-transform: uppercase; text-shadow: 1px 1px 0 #000; margin: 10px 6px 3px;
}
.wiki-link {
  display: block; width: 100%; text-align: left; cursor: pointer;
  padding: 5px 8px; margin: 1px 0; font: 13px 'Courier New', monospace; color: #cfcfcf;
  background: transparent; border: 1px solid transparent; text-shadow: 1px 1px 0 #000;
}
.wiki-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.wiki-link.active { background: rgba(120,140,200,0.35); border-color: #7f89a8; color: #fff; }
.wiki-link.hidden { display: none; }
.wiki-content { flex: 1; overflow-y: auto; padding: 14px 20px; color: #ddd; }
.wiki-content::-webkit-scrollbar, .wiki-list::-webkit-scrollbar { width: 10px; }
.wiki-content::-webkit-scrollbar-thumb, .wiki-list::-webkit-scrollbar-thumb { background: #555; border: 2px solid #222; }
.wiki-title { color: #fff; font-size: 22px; font-weight: bold; text-shadow: 2px 2px 0 #3f3f3f; margin-bottom: 4px; }
.wiki-h { color: #ffd24a; font-size: 15px; font-weight: bold; text-shadow: 1px 1px 0 #000; margin: 16px 0 6px; }
.wiki-p { font-size: 13.5px; line-height: 1.6; margin: 6px 0; text-shadow: 1px 1px 0 #111; }
.wiki-em { color: #ffe98a; font-weight: bold; }
.wiki-ul { margin: 6px 0 6px 4px; }
.wiki-li { font-size: 13.5px; line-height: 1.55; margin: 3px 0; padding-left: 16px; position: relative; text-shadow: 1px 1px 0 #111; }
.wiki-li::before { content: '\25AA'; color: #7f89a8; position: absolute; left: 2px; }
.wiki-note {
  font-size: 12.5px; line-height: 1.5; margin: 10px 0; padding: 8px 10px;
  background: rgba(120,100,40,0.18); border-left: 3px solid #ffd24a; color: #eadfc0; text-shadow: 1px 1px 0 #111;
}
.wiki-icon { image-rendering: pixelated; vertical-align: middle; }
.wiki-gallery { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.wiki-item { display: flex; flex-direction: column; align-items: center; width: 74px; text-align: center; cursor: help; padding: 3px 0; border: 1px solid transparent; }
.wiki-item:hover { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.14); }
.wiki-item .wiki-label { font-size: 10.5px; color: #bbb; margin-top: 3px; line-height: 1.2; text-shadow: 1px 1px 0 #000; }

/* hover-recipe tooltip */
.wiki-tip {
  display: none; position: fixed; z-index: 100; pointer-events: none;
  max-width: 340px; padding: 8px 10px; box-sizing: border-box;
  background: rgba(12,12,18,0.98); border: 2px solid #6a6a7a;
  box-shadow: 0 4px 16px rgba(0,0,0,0.7);
}
.wiki-tip-name { color: #ffe98a; font-weight: bold; font-size: 13px; margin-bottom: 5px; text-shadow: 1px 1px 0 #000; }
.wiki-tip-note { color: #a8a8a8; font-size: 11.5px; font-style: italic; text-shadow: 1px 1px 0 #000; }
.wiki-tip .wiki-craft { margin: 3px 0; gap: 8px; }
.wiki-craft { display: flex; align-items: center; gap: 12px; margin: 8px 0; flex-wrap: wrap; }
.wiki-grid { display: grid; grid-template-columns: repeat(3, 34px); grid-template-rows: repeat(3, 34px); gap: 2px; }
.wiki-slot {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  background: #1c1c22; border: 2px solid #000; box-shadow: inset 1px 1px 0 rgba(255,255,255,0.08);
}
.wiki-arrow { color: #ffd24a; font-size: 22px; }
.wiki-out { display: flex; flex-direction: column; align-items: center; }
.wiki-out .wiki-slot { background: #2a2a33; border-color: #555; }
.wiki-count { font-size: 11px; color: #fff; margin-top: 2px; text-shadow: 1px 1px 0 #000; }
.wiki-recipe-none { font-size: 12.5px; color: #999; font-style: italic; }
.wiki-empty { color: #999; font-style: italic; padding: 20px; text-align: center; }

/* ---- account / cloud sync ---- */
#accountBox { position: relative; margin-top: 14px; width: 300px; text-align: center; z-index: 2; }
#accountBox input {
  display: block; width: 100%; box-sizing: border-box; margin: 3px 0;
  background: rgba(0,0,0,0.6); border: 2px solid #888; color: #fff;
  font: 13px 'Courier New', monospace; padding: 6px 8px; outline: none;
}
#accountBox input:focus { border-color: #fff; }
#accountBox .mc-btn.small { width: 100%; margin-top: 4px; }
.acc-note { color: #ccc; font-size: 12px; margin: 4px 0; text-shadow: 1px 1px 0 #000; min-height: 14px; }
#accountInfo b { color: #ffff88; }

.menu-row { display: flex; gap: 10px; }
.menu-row .mc-btn { flex: 1; }

.opt-row.fx-sub { margin-left: 26px; }

/* ---- terrain flyover demo ---- */
#demoOverlay { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
#demoOverlay.hidden { display: none; }
.demo-top {
  position: absolute; top: 18px; left: 0; right: 0; text-align: center;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.7);
}
.demo-title { color: #fff; font-size: 24px; font-weight: bold; letter-spacing: 1px; }
.demo-mode { color: #ffd24a; font-size: 16px; font-weight: bold; margin-top: 4px; }
.demo-desc { color: #dfe6f0; font-size: 12.5px; margin-top: 3px; max-width: 460px; margin-left: auto; margin-right: auto; line-height: 1.5; }
.demo-bar {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; pointer-events: auto;
  background: rgba(0,0,0,0.4); padding: 8px; border: 2px solid rgba(0,0,0,0.55);
}
.demo-bar .mc-btn { width: auto; min-width: 130px; padding: 9px 14px; }

/* ---- mobile / touch ---- */
body.touch #game { touch-action: none; }
body.touch input, body.touch button { touch-action: auto; }
#rotateHint {
  display: none; position: absolute; inset: 0; z-index: 60;
  background: rgba(8, 8, 12, 0.92); color: #fff;
  flex-direction: column; align-items: center; justify-content: center;
  font: bold 18px monospace; gap: 10px; text-align: center;
}
#rotateHint .rot-icon { font-size: 44px; animation: rotHint 1.6s ease-in-out infinite; }
@keyframes rotHint { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-90deg); } }
@media (orientation: portrait) {
  body.touch #rotateHint { display: flex; }
}
