/* ================= Ogacial Lite — Bedrock-inspired UI ================= */
:root {
  --ui-bg: #313233;
  --ui-panel: #48494a;
  --ui-panel-dark: #2b2b2c;
  --ui-border-light: #5a5b5c;
  --ui-border-dark: #1e1e1f;
  --btn-face: #d0d1d4;
  --btn-face-hover: #b1b2b5;
  --btn-shadow: #58585a;
  --accent: #3c8527;        /* Bedrock green */
  --accent-hover: #2a641c;
  --accent-shadow: #1d4d13;
  --text-dark: #1e1e1f;
  --text-light: #ffffff;
  --gold: #ffd83d;
  --font-pixel: 'Silkscreen', monospace;
  --font-body: 'IBM Plex Sans', sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #000; font-family: var(--font-body); }

.hidden { display: none !important; }
.hidden-input { display: none; }
.screen { position: absolute; inset: 0; }

/* ---------------- Buttons ---------------- */
.mc-btn {
  display: block; width: 100%; padding: 12px 24px;
  font-family: var(--font-pixel); font-size: 15px; letter-spacing: 1px;
  color: var(--text-dark); background: var(--btn-face);
  border: 2px solid var(--ui-border-dark);
  box-shadow: inset -2px -4px 0 var(--btn-shadow), inset 2px 2px 0 #ffffff66;
  cursor: pointer; transition: transform .05s;
  text-shadow: 0 1px 0 #ffffff55;
}
.mc-btn:hover:not(:disabled) { background: var(--btn-face-hover); }
.mc-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset -2px -2px 0 var(--btn-shadow); }
.mc-btn-primary {
  background: var(--accent); color: var(--text-light);
  box-shadow: inset -2px -4px 0 var(--accent-shadow), inset 2px 2px 0 #ffffff33;
  text-shadow: 0 2px 0 #00000055;
}
.mc-btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.mc-btn-disabled, .mc-btn:disabled { opacity: .45; cursor: not-allowed; }
.mc-btn.small { padding: 7px 12px; font-size: 11px; width: auto; display: inline-block; }
.toggle-group { display: flex; gap: 8px; }
.toggle-btn { width: auto; flex: 1; opacity: .55; }
.toggle-btn.active { opacity: 1; outline: 2px solid var(--gold); }

/* ---------------- Main menu ---------------- */
#menu-screen { overflow: hidden; }
#panorama-canvas { position: absolute; inset: 0; width: 100%; height: 100%; filter: blur(1.5px) brightness(.9); }
.menu-overlay {
  position: relative; z-index: 2; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 36px;
  animation: menuFade .6s ease both;
}
@keyframes menuFade { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.logo-wrap { text-align: center; position: relative; }
.game-logo {
  font-family: var(--font-pixel); font-weight: 700; font-size: clamp(42px, 8vw, 86px);
  color: #fff; letter-spacing: 4px;
  text-shadow: 4px 4px 0 #3a3a3a, 8px 8px 0 #00000088;
  -webkit-text-stroke: 2px #222;
}
.logo-sub {
  font-family: var(--font-pixel); font-size: clamp(16px, 2.4vw, 26px); color: var(--gold);
  letter-spacing: 12px; text-shadow: 2px 2px 0 #000;
}
.splash-text {
  position: absolute; right: -60px; bottom: 4px;
  font-family: var(--font-pixel); font-size: 14px; color: #ffff55;
  text-shadow: 2px 2px 0 #3f3f00; transform: rotate(-12deg);
  animation: splashPulse 1.4s ease-in-out infinite;
}
@keyframes splashPulse { 0%,100% { transform: rotate(-12deg) scale(1);} 50% { transform: rotate(-12deg) scale(1.12);} }
.menu-buttons { width: min(380px, 80vw); display: flex; flex-direction: column; gap: 10px; }
.menu-buttons .mc-btn { animation: menuFade .5s ease both; }
.menu-buttons .mc-btn:nth-child(1) { animation-delay: .08s; }
.menu-buttons .mc-btn:nth-child(2) { animation-delay: .16s; }
.menu-buttons .mc-btn:nth-child(3) { animation-delay: .24s; }
.menu-buttons .mc-btn:nth-child(4) { animation-delay: .32s; }
.menu-footer {
  position: absolute; bottom: 10px; left: 0; right: 0;
  display: flex; justify-content: space-between; padding: 0 16px;
  font-family: var(--font-pixel); font-size: 10px; color: #ffffffaa; text-shadow: 1px 1px 0 #000;
}
.player-preview-panel {
  position: absolute; right: 4vw; top: 50%; transform: translateY(-50%); z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  animation: menuFade .7s .3s ease both;
}
#preview-canvas { width: 240px; height: 315px; image-rendering: auto; }
.preview-caption {
  display: flex; flex-direction: column; align-items: center;
  font-family: var(--font-pixel); color: #fff; text-shadow: 2px 2px 0 #000; font-size: 14px;
}
.preview-cape { color: var(--gold); font-size: 10px; }

/* ---------------- Panels (settings / play / profile) ---------------- */
.panel-bg { position: absolute; inset: 0; background:
  linear-gradient(#0008, #0008),
  repeating-conic-gradient(#3a3a3c 0% 25%, #333335 0% 50%) 0 0 / 48px 48px; }
.mc-panel {
  position: relative; z-index: 2; width: min(520px, 92vw);
  margin: 7vh auto 0; padding: 26px 30px 30px;
  background: var(--ui-panel);
  border: 3px solid var(--ui-border-dark);
  box-shadow: inset 2px 2px 0 var(--ui-border-light), inset -3px -3px 0 var(--ui-panel-dark), 0 14px 40px #000a;
  display: flex; flex-direction: column; gap: 18px;
  animation: menuFade .35s ease both;
}
.panel-title { font-family: var(--font-pixel); color: #fff; text-shadow: 2px 2px 0 #000; font-size: 24px; text-align: center; }
.form-row label { display: block; font-family: var(--font-pixel); font-size: 11px; color: #e8e8e8; margin-bottom: 7px; text-shadow: 1px 1px 0 #000; }
.mc-input {
  width: 100%; padding: 10px 12px; font-family: var(--font-body); font-size: 15px;
  background: #1d1d1e; color: #fff; border: 2px solid #000;
  box-shadow: inset 2px 2px 0 #00000088, 0 0 0 2px var(--ui-border-light);
  outline: none;
}
.mc-input:focus { box-shadow: inset 2px 2px 0 #00000088, 0 0 0 2px var(--gold); }
.hint { font-size: 12px; color: #c9c9c9; margin-top: 6px; }
.panel-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 22px; cursor: pointer; }

/* Profile */
.profile-layout { position: relative; z-index: 2; display: flex; gap: 30px; justify-content: center; align-items: flex-start; padding-top: 5vh; }
.profile-panel { margin: 0; max-height: 86vh; overflow-y: auto; }
.profile-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 20px; }
#profile-preview-canvas { width: 280px; height: 373px; }
.cape-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.cape-option {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  background: var(--ui-panel-dark); border: 2px solid var(--ui-border-dark); cursor: pointer;
  font-family: var(--font-pixel); font-size: 11px; color: #fff;
}
.cape-option:hover { background: #222; }
.cape-option.active { outline: 2px solid var(--gold); }
.cape-option canvas { width: 40px; height: 64px; image-rendering: pixelated; background: #111; }

/* ---------------- HUD ---------------- */
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#crosshair {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-family: var(--font-pixel); font-size: 22px; color: #fff; mix-blend-mode: difference;
}
#hotbar {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 0; background: #00000088; padding: 3px; border: 2px solid #000;
}
.hotbar-slot {
  width: 52px; height: 52px; position: relative;
  background: #8b8b8b55; border: 2px solid #55555588; margin: 1px;
}
.hotbar-slot.selected { border: 3px solid #fff; margin: 0; box-shadow: 0 0 0 2px #000; }
.slot-canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.slot-count {
  position: absolute; right: 3px; bottom: 1px;
  font-family: var(--font-pixel); font-size: 13px; color: #fff; text-shadow: 2px 2px 0 #000;
}
#status-bars {
  position: absolute; bottom: 78px; left: 50%; transform: translateX(-50%);
  width: 460px; display: flex; justify-content: space-between;
}
.bar-row { display: flex; gap: 1px; }
.bar-icon { width: 18px; height: 18px; image-rendering: pixelated; }
#debug-info {
  position: absolute; top: 8px; left: 8px;
  font-family: var(--font-pixel); font-size: 11px; color: #fff;
  background: #00000077; padding: 8px 10px; line-height: 1.7; white-space: pre;
}
#action-toast {
  position: absolute; bottom: 130px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-pixel); font-size: 13px; color: var(--gold);
  text-shadow: 2px 2px 0 #000; opacity: 0; transition: opacity .4s;
}

/* Chat */
#chat-box { position: absolute; left: 8px; bottom: 60px; width: min(480px, 60vw); pointer-events: none; }
#chat-messages { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; max-height: 40vh; overflow: hidden; }
.chat-msg {
  font-family: var(--font-body); font-size: 14px; color: #fff;
  background: #00000066; padding: 3px 8px; text-shadow: 1px 1px 0 #000;
  animation: chatIn .15s ease both;
}
.chat-msg b { color: var(--gold); }
.chat-msg.system { color: #ffff88; font-style: italic; }
@keyframes chatIn { from { opacity: 0; transform: translateX(-8px);} to { opacity: 1; transform: none; } }
#chat-input { pointer-events: auto; }

#player-list {
  position: absolute; top: 50px; left: 50%; transform: translateX(-50%);
  background: #000000aa; border: 2px solid #000; padding: 12px 26px;
  font-family: var(--font-pixel); font-size: 13px; color: #fff; text-align: center; line-height: 2;
}
#player-list h4 { color: var(--gold); margin-bottom: 6px; }

/* ---------------- Inventory ---------------- */
#inventory-screen { position: absolute; inset: 0; z-index: 10; background: #00000099; display: flex; align-items: center; justify-content: center; }
.inv-panel {
  background: #c6c6c6; border: 3px solid #000;
  box-shadow: inset 3px 3px 0 #ffffffcc, inset -4px -4px 0 #555555, 0 16px 50px #000c;
  padding: 18px 20px; display: flex; flex-direction: column; gap: 12px;
}
.inv-panel h3 { font-family: var(--font-pixel); font-size: 14px; color: #3a3a3a; }
.inv-grid { display: grid; grid-template-columns: repeat(9, 46px); gap: 3px; }
.inv-slot {
  width: 46px; height: 46px; position: relative;
  background: #8b8b8b; border: 2px solid; border-color: #373737 #fff #fff #373737;
  cursor: pointer;
}
.inv-slot:hover { background: #a8a8a8; }
#creative-palette { padding-bottom: 10px; border-bottom: 2px solid #999; }
#drag-ghost { position: fixed; width: 44px; height: 44px; pointer-events: none; z-index: 20; }
#drag-ghost canvas { width: 100%; height: 100%; image-rendering: pixelated; }
#drag-ghost .slot-count { font-size: 12px; }
#item-tooltip {
  position: fixed; z-index: 21; pointer-events: none;
  background: #100010ee; border: 2px solid #25015a; outline: 2px solid #100010ee;
  color: #fff; font-family: var(--font-pixel); font-size: 12px; padding: 5px 9px;
}

/* ---------------- Pause / death ---------------- */
#pause-screen { position: absolute; inset: 0; z-index: 12; background: #00000088; }
.pause-panel { width: min(380px, 90vw); margin-top: 18vh; gap: 10px; }
#death-screen {
  position: absolute; inset: 0; z-index: 13; background: #6d0000bb;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
#death-screen h1 { font-family: var(--font-pixel); font-size: 52px; color: #fff; text-shadow: 4px 4px 0 #400; }
#death-screen p { font-family: var(--font-pixel); color: #ffdddd; font-size: 14px; }
#death-screen .mc-btn { width: 300px; }

/* ---------------- Loading ---------------- */
#loading-overlay { position: fixed; inset: 0; z-index: 30; background: #1c1c1e; display: flex; align-items: center; justify-content: center; }
.loading-inner { text-align: center; }
.loading-block {
  width: 48px; height: 48px; margin: 0 auto 18px;
  background: linear-gradient(135deg, #6aa84f 50%, #8b5a2b 50%);
  border: 3px solid #000; animation: spinBlock 1.1s linear infinite;
}
@keyframes spinBlock { to { transform: rotate(360deg); } }
#loading-text { font-family: var(--font-pixel); color: #fff; font-size: 14px; }

@media (max-width: 900px) {
  .player-preview-panel { display: none; }
  #status-bars { width: 90vw; }
  .profile-layout { flex-direction: column; align-items: center; }
}

/* ---------------- Late additions: chat states, toast, hurt flash, cape cells ---------------- */
#action-toast.show { opacity: 1; }

.chat-msg { opacity: 0; transition: opacity .6s; }
.chat-msg.fresh { opacity: 1; }
#chat-box.open .chat-msg { opacity: 1; }
#chat-box.open #chat-messages { overflow-y: auto; pointer-events: auto; }

#game-canvas.hurt-flash { filter: saturate(1.4) sepia(.4) hue-rotate(-40deg) brightness(.92); }

.cape-cell {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 6px;
}
.cape-cell canvas { width: 40px; height: 64px; image-rendering: pixelated; background: #00000033; }
.cape-cell span { font-size: 11px; }
.cape-cell.active { outline: 3px solid var(--gold); }
