/* ========================================================
   ISLEFORGE: Realm of the Ancients - Pixel Art Stylesheet
   ======================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

:root {
  --font-pixel: 'Press Start 2P', monospace, sans-serif;
  --font-retro: 'Silkscreen', monospace, sans-serif;
  --c-dark-bg: #0d0f17;
  --c-border-outer: #1e2337;
  --c-border-mid: #3b4261;
  --c-border-light: #7aa2f7;
  --c-wood: #8b5a2b;
  --c-stone: #555b6e;
  --c-gold: #ffbe0b;
  --c-health: #e63946;
  --c-hunger: #fb8500;
  --c-stamina: #06d6a0;
  --c-xp: #4cc9f0;
  --c-mythic: #f72585;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #05070c;
  font-family: var(--font-pixel);
  color: #f1f5f9;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #0d1b2a;
}

/* Canvas Styling */
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
}

/* CRT Scanline Overlay */
#scanline-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.25) 50%
  );
  background-size: 100% 4px;
  z-index: 50;
  opacity: 0.4;
}

/* Reusable Pixel Box Container */
.pixel-box, .pixel-window, .pixel-card {
  background: #131722;
  border: 4px solid #3d4760;
  box-shadow: 
    inset -4px -4px 0px #0b0d14,
    inset 4px 4px 0px #5e6d93,
    0 8px 0px rgba(0,0,0,0.5);
  position: relative;
}

/* HUD System */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 60;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Top Left Status Panel */
#status-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
  background: rgba(13, 17, 28, 0.85);
  padding: 8px 10px;
  border: 3px solid #364156;
  border-radius: 2px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.6);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
}

.bar-container {
  width: 140px;
  height: 14px;
  background: #1b1e2e;
  border: 2px solid #07090e;
  position: relative;
  overflow: hidden;
}

.bar {
  height: 100%;
  width: 100%;
  transition: width 0.15s ease-out;
}

.health-fill { background: linear-gradient(180deg, #ff6b6b 0%, #c92a2a 100%); }
.hunger-fill { background: linear-gradient(180deg, #ffa94d 0%, #d9480f 100%); }
.stamina-fill { background: linear-gradient(180deg, #63e6be 0%, #0ca678 100%); }
.xp-fill { background: linear-gradient(180deg, #74c0fc 0%, #1c7ed6 100%); }

.bar-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 8px;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
}

/* Top Center Panel: Day/Night + Boss */
#top-center-panel {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

#clock-display {
  padding: 6px 14px;
  font-size: 10px;
  color: #ffde59;
  letter-spacing: 1px;
  text-shadow: 1px 1px 0 #000;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(19, 23, 34, 0.9);
}

#boss-bar-container {
  width: 280px;
  text-align: center;
}

#boss-title {
  font-size: 9px;
  color: #ff4757;
  letter-spacing: 2px;
  margin-bottom: 4px;
  text-shadow: 2px 2px 0 #000;
}

.boss-bar-frame {
  width: 100%;
  height: 16px;
  background: #111;
  border: 3px solid #ff4757;
  position: relative;
  box-shadow: 0 0 10px rgba(255, 71, 87, 0.5);
}

#boss-hp-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff0055, #ff4757, #ffa502);
  transition: width 0.2s;
}

#boss-hp-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 8px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
}

/* Top Right: Minimap */
#top-right-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
}

#minimap-wrapper {
  padding: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(19, 23, 34, 0.9);
}

#minimapCanvas {
  display: block;
  border: 2px solid #2f3542;
  image-rendering: pixelated;
}

#coords-text {
  font-size: 7px;
  color: #a4b0be;
  margin-top: 4px;
}

.top-buttons {
  display: flex;
  gap: 6px;
}

.btn-pixel-sm {
  background: #2f3542;
  border: 2px solid #57606f;
  color: #fff;
  font-size: 14px;
  padding: 6px 8px;
  cursor: pointer;
  box-shadow: 0 3px 0 #1e272e;
}

.btn-pixel-sm:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #1e272e;
}

/* Interactive Notifications */
#interact-prompt {
  position: absolute;
  bottom: 95px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid #ffbe0b;
  color: #ffbe0b;
  font-size: 9px;
  padding: 6px 14px;
  letter-spacing: 1px;
  animation: pulse-glow 1.5s infinite alternate;
}

#notification-toast {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e272e;
  border: 3px solid #00d2d3;
  color: #00d2d3;
  font-size: 10px;
  padding: 10px 20px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.6);
  z-index: 100;
  pointer-events: none;
  transition: opacity 0.3s;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 5px rgba(255, 190, 11, 0.4); }
  100% { box-shadow: 0 0 15px rgba(255, 190, 11, 0.9); }
}

/* Bottom Hotbar */
#hotbar-container {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
}

#hotbar {
  display: flex;
  gap: 6px;
  padding: 6px;
  background: rgba(19, 23, 34, 0.92);
}

.hotbar-slot {
  width: 50px;
  height: 50px;
  background: #232a3b;
  border: 3px solid #455273;
  box-shadow: inset -2px -2px 0 #151a24, inset 2px 2px 0 #687aa6;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
}

.hotbar-slot:hover {
  background: #2c354a;
}

.hotbar-slot.active {
  border-color: #ffd166;
  box-shadow: 
    inset -2px -2px 0 #a37200, 
    inset 2px 2px 0 #ffe08a,
    0 0 12px rgba(255, 209, 102, 0.7);
  transform: scale(1.08);
  z-index: 2;
}

.slot-key-hint {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 7px;
  color: #8395a7;
}

.slot-icon {
  font-size: 22px;
}

.slot-count {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 8px;
  color: #fff;
  font-weight: bold;
  text-shadow: 1px 1px 0 #000;
}

/* Mobile Controls */
#mobile-controls {
  display: none;
  pointer-events: auto;
  position: absolute;
  bottom: 12px;
  left: 0;
  width: 100%;
  padding: 0 16px;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 65;
}

@media (max-width: 900px), (pointer: coarse) {
  #mobile-controls {
    display: flex;
  }
  #hotbar-container {
    bottom: 90px;
  }
  .bar-container {
    width: 100px;
  }
}

#joystick-zone {
  width: 130px;
  height: 130px;
  position: relative;
  touch-action: none;
}

#joystick-base {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 3px solid rgba(255, 255, 255, 0.35);
  position: absolute;
  top: 5px;
  left: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#joystick-stick {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.65);
  border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(255,255,255,0.4);
  transform: translate(0px, 0px);
}

#touch-buttons {
  display: grid;
  grid-template-columns: repeat(2, 64px);
  grid-template-rows: repeat(2, 64px);
  gap: 12px;
}

.btn-touch {
  border-radius: 50%;
  font-family: var(--font-pixel);
  font-size: 9px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 3px solid #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,0.5);
  line-height: 1.2;
}

.btn-touch:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.5);
}

.btn-touch-attack { background: #e63946; }
.btn-touch-place { background: #457b9d; }
.btn-touch-dodge { background: #2a9d8f; }
.btn-touch-craft { background: #9b5de5; }

/* Modals & Screens */
.modal-backdrop, .screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 7, 12, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  backdrop-filter: blur(3px);
}

.hidden {
  display: none !important;
}

.modal-window {
  width: 90%;
  max-width: 780px;
  max-height: 90vh;
  padding: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #161b26;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid #364156;
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.pixel-title {
  font-size: 14px;
  color: #ffd166;
  letter-spacing: 1px;
}

.btn-close {
  background: #e63946;
  border: 2px solid #fff;
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
}

.btn-close:hover {
  background: #d62828;
}

.modal-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  overflow-y: auto;
  padding-right: 4px;
}

@media (max-width: 720px) {
  .modal-body {
    grid-template-columns: 1fr;
  }
}

.section-title {
  font-size: 10px;
  color: #4cc9f0;
  margin-bottom: 8px;
}

/* Item Grid & Cards */
.item-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  background: #0f121a;
  padding: 8px;
  border: 2px solid #2f3542;
  margin-bottom: 12px;
}

.inv-slot {
  aspect-ratio: 1;
  background: #202636;
  border: 2px solid #3d4760;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
}

.inv-slot:hover {
  border-color: #7aa2f7;
}

.inv-slot.selected {
  border-color: #ffd166;
  background: #2a334a;
}

.inv-slot .slot-icon {
  font-size: 18px;
}

.inv-slot .slot-count {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 7px;
  color: #fff;
}

/* Card details */
.pixel-card {
  padding: 10px;
  margin-top: 6px;
}

.info-title {
  font-size: 10px;
  color: #ffd166;
  margin-bottom: 6px;
}

.info-desc {
  font-size: 8px;
  color: #ced6e0;
  line-height: 1.5;
  margin-bottom: 10px;
}

#info-actions {
  display: flex;
  gap: 8px;
}

.btn-pixel-action {
  font-family: var(--font-pixel);
  font-size: 8px;
  background: #06d6a0;
  color: #000;
  border: 2px solid #fff;
  padding: 6px 12px;
  cursor: pointer;
}

.btn-danger {
  background: #e63946;
  color: #fff;
}

/* Crafting Area */
.craft-category-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.tab-btn {
  background: #232a3b;
  border: 2px solid #455273;
  color: #a4b0be;
  font-family: var(--font-pixel);
  font-size: 7px;
  padding: 6px 8px;
  cursor: pointer;
}

.tab-btn.active {
  background: #ffbe0b;
  color: #111;
  border-color: #fff;
}

.recipe-list {
  max-height: 170px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #0f121a;
  padding: 6px;
  border: 2px solid #2f3542;
  margin-bottom: 10px;
}

.recipe-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px;
  background: #1c2230;
  border: 2px solid #303b52;
  cursor: pointer;
}

.recipe-item:hover, .recipe-item.selected {
  border-color: #ffd166;
  background: #273045;
}

.recipe-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.recipe-title {
  font-size: 8px;
  color: #f1f2f6;
}

.recipe-tier {
  font-size: 7px;
  padding: 2px 4px;
  border-radius: 2px;
}

.tier-basic { background: #57606f; color: #fff; }
.tier-bench { background: #e67e22; color: #fff; }
.tier-furnace { background: #c0392b; color: #fff; }
.tier-mythic { background: #8e44ad; color: #ff9ff3; font-weight: bold; }

.req-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.req-item {
  font-size: 8px;
  display: flex;
  justify-content: space-between;
}

.req-met { color: #2ed573; }
.req-missing { color: #ff4757; }

.btn-pixel-craft {
  width: 100%;
  font-family: var(--font-pixel);
  font-size: 9px;
  padding: 10px;
  background: #ffbe0b;
  color: #111;
  border: 3px solid #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 #b38600;
}

.btn-pixel-craft:disabled {
  background: #57606f;
  color: #888;
  border-color: #666;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-pixel-craft:not(:disabled):active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #b38600;
}

/* Title Screen */
.title-card {
  max-width: 580px;
  width: 90%;
  padding: 30px 24px;
  text-align: center;
  background: #141a29;
}

.game-logo {
  margin-bottom: 20px;
}

.logo-sub {
  font-size: 9px;
  color: #4cc9f0;
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.logo-main {
  font-size: 32px;
  color: #ffbe0b;
  letter-spacing: 4px;
  text-shadow: 
    3px 3px 0 #c77700,
    6px 6px 0 #000;
  margin-bottom: 6px;
}

.logo-tag {
  font-size: 11px;
  color: #f72585;
  letter-spacing: 3px;
  text-shadow: 1px 1px 0 #000;
}

.story-desc {
  font-family: var(--font-retro);
  font-size: 12px;
  line-height: 1.8;
  color: #ced6e0;
  margin-bottom: 24px;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-menu-primary {
  font-family: var(--font-pixel);
  font-size: 11px;
  padding: 14px;
  background: #2ed573;
  color: #0b2212;
  border: 4px solid #fff;
  cursor: pointer;
  box-shadow: 0 6px 0 #1e824c;
  letter-spacing: 1px;
}

.btn-menu-primary:hover {
  background: #26af5f;
}

.btn-menu-primary:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #1e824c;
}

.btn-menu-secondary {
  font-family: var(--font-pixel);
  font-size: 9px;
  padding: 12px;
  background: #2f3542;
  color: #f1f2f6;
  border: 3px solid #57606f;
  cursor: pointer;
  box-shadow: 0 5px 0 #1e272e;
}

.btn-menu-secondary:hover {
  background: #3c4456;
}

.btn-menu-secondary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #1e272e;
}

.version-tag {
  margin-top: 20px;
  font-size: 7px;
  color: #747d8c;
}

/* Guide Modal */
.guide-window {
  max-width: 650px;
}

.guide-content {
  overflow-y: auto;
  max-height: 60vh;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.guide-block h4 {
  font-size: 10px;
  color: #ffd166;
  margin-bottom: 8px;
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  font-family: var(--font-retro);
  font-size: 11px;
  line-height: 1.5;
  color: #ced6e0;
}

.guide-block ul {
  padding-left: 20px;
  font-family: var(--font-retro);
  font-size: 11px;
  line-height: 1.6;
  color: #ced6e0;
}

.guide-block li {
  margin-bottom: 6px;
}

.modal-footer {
  margin-top: 14px;
}

/* Death Screen */
.death-card {
  max-width: 480px;
  width: 90%;
  padding: 30px;
  text-align: center;
  background: #1e1114;
  border-color: #ff4757;
}

.death-title {
  font-size: 24px;
  color: #ff4757;
  letter-spacing: 3px;
  text-shadow: 3px 3px 0 #000;
  margin-bottom: 12px;
}

.death-msg {
  font-family: var(--font-retro);
  font-size: 12px;
  color: #ced6e0;
  margin-bottom: 20px;
}

.death-stats {
  background: #11090b;
  border: 2px solid #571620;
  padding: 12px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 9px;
  color: #ffbe0b;
}

/* Item Rarity Text Color Classes */
.rarity-common { color: #ced6e0; }
.rarity-rare { color: #1e90ff; }
.rarity-epic { color: #a55eea; }
.rarity-legendary { color: #ffbe0b; }
.rarity-mythic { color: #f72585; text-shadow: 0 0 6px #f72585; }
