:root {
  --panel: #c6c6c6;
  --panel-light: #ffffff;
  --panel-dark: #555555;
  --slot: #8b8b8b;
  --slot-dark: #373737;
  --slot-light: #ffffff;
  --px: 4px; /* GUI pixel unit */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Outfit', system-ui, sans-serif;
  background: #000;
  image-rendering: pixelated;
  overflow: hidden;
  letter-spacing: 0;
  word-spacing: 0;
}
body.plain-mode { overflow: auto; }

/* ---------- background: Minecraft loading-screen world, slowly drifting (generated in app.js) ---------- */
.world-bg {
  position: fixed;
  inset: 0;
  background-color: #2a1d12;
  /* backgroundImage set from JS: procedurally generated world scene */
  image-rendering: pixelated;
  /* Blurred + scaled up like the Minecraft title/loading screen, and slowly panned. */
  filter: blur(3px);
  transform: scale(1.14);
  animation: worldDrift 64s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes worldDrift {
  from { transform: scale(1.14) translate(-2.6%, 0.7%); }
  to   { transform: scale(1.14) translate(2.6%, -0.7%); }
}
@media (prefers-reduced-motion: reduce) {
  .world-bg { animation: none; transform: scale(1.14); }
}

/* ---------- layout ---------- */
.gui-root {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ---------- view toggle ---------- */
.view-toggle {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 60;
  font-family: inherit;
  font-size: 15px;
  padding: 7px 16px 6px;
  color: #fff;
  text-shadow: 1px 1px 0 #383838;
  background: #6f6f6f;
  border: 2px solid;
  border-color: #a8a8a8 #2f2f2f #2f2f2f #a8a8a8;
  box-shadow: 0 0 0 2px #000;
  cursor: pointer;
}
.view-toggle:hover {
  background: #7f8cff;
  border-color: #b8c2ff #35357f #35357f #b8c2ff;
}

/* ---------- inventory panel ---------- */
.inventory {
  background: var(--panel);
  padding: 10px 16px 12px;
  border: var(--px) solid;
  border-color: var(--panel-light) var(--panel-dark) var(--panel-dark) var(--panel-light);
  box-shadow: 0 0 0 var(--px) #000, 0 14px 40px rgba(0,0,0,.6);
}

.inv-title {
  color: #404040;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.section-label {
  color: #404040;
  font-size: 13px;
  margin: 4px 0 2px;
}

.inv-top {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 6px;
}

.armor-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.player-box {
  width: 148px;
  background: #000;
  border: 2px solid;
  border-color: var(--slot-dark) var(--slot-light) var(--slot-light) var(--slot-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#playerCanvas { image-rendering: pixelated; }

.player-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.offhand-row { display: flex; justify-content: center; }

.craft-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 0 4px;
}
.craft-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 10px;
}
.craft-grid {
  display: grid;
  grid-template-columns: repeat(2, 52px);
  gap: 2px;
}
.craft-arrow {
  color: #8b8b8b;
  text-shadow: 1px 1px 0 #fff;
  font-size: 30px;
  line-height: 1;
}
.player-sub  { font-size: 13px; color: #4a4a4a; line-height: 1.8; }
.player-sub.dim { color: #6a6a6a; }

/* XP bar (above hotbar, like the HUD) */
.xp-wrap { margin: 18px 0 6px; position: relative; cursor: help; }
.xp-level {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  color: #7fff1f;
  text-shadow: 2px 2px 0 #203000;
  font-size: 18px;
  font-weight: 700;
  z-index: 1;
}
.xp-bar {
  height: 10px;
  background: #2b2b2b;
  border: 2px solid #000;
}
.xp-fill {
  height: 100%;
  width: 35%;
  background: linear-gradient(#a2ff43, #6fce1a);
}

/* ---------- slot grids ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(9, 52px);
  gap: 2px;
}
.hotbar { margin-top: 2px; }

.slot {
  width: 52px;
  height: 52px;
  background: var(--slot);
  border: 2px solid;
  border-color: var(--slot-dark) var(--slot-light) var(--slot-light) var(--slot-dark);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slot.filled { cursor: pointer; }
.slot.filled:hover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.45);
  pointer-events: none;
}
.slot canvas {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
  pointer-events: none;
}

/* enchant glint */
.slot.enchanted::before {
  content: "";
  position: absolute;
  inset: 2px;
  pointer-events: none;
  background: linear-gradient(115deg,
    transparent 20%, rgba(190,120,255,.0) 35%,
    rgba(200,130,255,.45) 50%,
    rgba(190,120,255,.0) 65%, transparent 80%);
  background-size: 250% 250%;
  animation: glint 2.6s linear infinite;
  mix-blend-mode: screen;
  z-index: 1;
}
@keyframes glint {
  0%   { background-position: 120% 120%; }
  100% { background-position: -40% -40%; }
}

/* stack count badge */
.slot .count {
  position: absolute;
  right: 3px;
  bottom: 1px;
  color: #fff;
  text-shadow: 2px 2px 0 #3f3f3f;
  font-size: 15px;
  font-weight: 700;
  z-index: 2;
  pointer-events: none;
}

.hint {
  color: #ddd;
  text-shadow: 2px 2px 0 #000;
  font-size: 15px;
  opacity: .9;
}

/* ---------- tooltip ---------- */
.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  max-width: 340px;
  background: rgba(16, 0, 16, .94);
  border: 2px solid #2d0a63;
  box-shadow: inset 0 0 0 2px rgba(80, 40, 140, .9);
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.7;
}
.tooltip .t-name { margin-bottom: 5px; font-weight: 700; color: #fff; font-size: 14px; }
.tooltip .t-line { color: #a8a8a8; }
.tooltip .t-ench { color: #a8a8ff; }
.tooltip .t-click { color: #55ff55; margin-top: 5px; }

/* ---------- modal ---------- */
.modal-overlay[hidden], .tooltip[hidden] { display: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  position: relative;
  width: min(600px, 92vw);
  max-height: 84vh;
  overflow-y: auto;
  background: var(--panel);
  border: var(--px) solid;
  border-color: var(--panel-light) var(--panel-dark) var(--panel-dark) var(--panel-light);
  box-shadow: 0 0 0 var(--px) #000, 0 18px 50px rgba(0,0,0,.7);
  padding: 18px 20px;
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 24px;
  color: #5a5a5a;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: #000; }

.modal-head {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 10px;
}
.modal-icon {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  background: var(--slot);
  border: 2px solid;
  border-color: var(--slot-dark) var(--slot-light) var(--slot-light) var(--slot-dark);
  padding: 6px;
  flex: none;
}
.modal-title { font-size: 18px; font-weight: 700; line-height: 1.3; }
.modal-sub { font-size: 12px; color: #4f4f4f; margin-top: 2px; }

.modal-body { font-size: 13px; color: #2e2e2e; line-height: 1.9; }
.modal-body ul { list-style: none; margin: 8px 0; }
.modal-body li { padding-left: 20px; position: relative; margin: 8px 0; }
.modal-body li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 9px;
  width: 7px;
  height: 7px;
  background: #5a5a5a;
}
.modal-body .ench-line { color: #7a3fb8; margin: 2px 0; }
.modal-body .modal-story {
  margin: 10px 0 6px;
  color: #3a3a3a;
  font-style: italic;
  line-height: 1.7;
  border-left: 3px solid #b0b0b0;
  padding-left: 10px;
}
.modal-body .m-section {
  margin-top: 14px;
  margin-bottom: 6px;
  color: #404040;
  font-weight: 700;
  font-size: 12px;
  border-bottom: 2px solid #a0a0a0;
  padding-bottom: 3px;
}
.modal-head { margin-bottom: 14px; }
.modal-body a.mc-btn {
  display: inline-block;
  margin: 10px 8px 0 0;
  padding: 6px 14px 5px;
  font-family: inherit;
  font-size: 14px;
  text-decoration: none;
  color: #fff;
  text-shadow: 1px 1px 0 #383838;
  background: #6f6f6f;
  border: 2px solid;
  border-color: #a8a8a8 #2f2f2f #2f2f2f #a8a8a8;
  box-shadow: 0 0 0 2px #000;
  cursor: pointer;
}
.modal-body a.mc-btn:hover {
  background: #7f8cff;
  border-color: #b8c2ff #35357f #35357f #b8c2ff;
}

/* project pictures */
.pic-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.pic-gallery img {
  max-width: calc(50% - 4px);
  border: 2px solid;
  border-color: var(--slot-dark) var(--slot-light) var(--slot-light) var(--slot-dark);
  background: var(--slot);
}

/* ---------- plain (non-Minecraft) view ---------- */
body.plain-mode .gui-root,
body.plain-mode .world-bg { display: none; }
body.plain-mode { background: #f6f7f9; }
body.plain-mode .view-toggle {
  background: #1d3b8f;
  border-color: #4a6ad4 #101f4d #101f4d #4a6ad4;
}

.plain-view {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  max-width: 800px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  color: #1f2430;
}
.plain-view h1 { font-size: 34px; margin-bottom: 2px; }
.plain-view .p-title { font-size: 17px; color: #444; }
.plain-view .p-seek { font-size: 15px; color: #1d4ed8; margin: 6px 0 2px; font-weight: 500; }
.plain-view .p-contact { margin: 4px 0 6px; font-size: 15px; color: #555; }
.plain-view .p-contact a { color: #1d4ed8; text-decoration: none; }
.plain-view .p-contact a:hover { text-decoration: underline; }
.plain-view h2 {
  font-size: 21px;
  margin: 34px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid #d7dbe3;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.plain-view .p-section-date {
  font-size: 13px;
  font-weight: 400;
  color: #6a7080;
}
.plain-view .p-card {
  background: #fff;
  border: 1px solid #e2e5ec;
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(20,24,40,.05);
}
.plain-view .p-card h3 { font-size: 17px; margin-bottom: 1px; }
.plain-view .p-sub { font-size: 13.5px; color: #6a7080; margin-bottom: 8px; }
.plain-view .p-story {
  font-size: 14px;
  color: #444;
  line-height: 1.65;
  margin: 6px 0 10px;
  font-style: italic;
}
.plain-view .p-card ul { margin: 0 0 4px 18px; font-size: 14.5px; line-height: 1.5; }
.plain-view .p-card li { margin: 3px 0; }
.plain-view .p-tech { font-size: 13px; color: #556; margin-top: 8px; }
.plain-view .p-tech b { color: #333; }
.plain-view .p-skills { columns: 2; font-size: 14.5px; line-height: 1.7; }
.plain-view .p-skills div { break-inside: avoid; }
.plain-view .pic-gallery img { border: 1px solid #d7dbe3; border-radius: 4px; }

@media (max-width: 720px) {
  :root { --px: 3px; }
  .grid { grid-template-columns: repeat(9, 34px); }
  .slot { width: 34px; height: 34px; }
  .slot canvas { width: 26px; height: 26px; }
  .player-box { width: 92px; }
  #playerCanvas { width: 72px; height: 144px; }
  .craft-grid { grid-template-columns: repeat(2, 34px); }
  .player-sub { font-size: 12px; }
  .inv-title { font-size: 16px; }
  .section-label { font-size: 12px; }
  .slot .count { font-size: 12px; }
  .plain-view .p-skills { columns: 1; }
}
