/* -------------------------------------- */
/* GLOBAL RESETS + INPUT BEHAVIOR         */
/* -------------------------------------- */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: black;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
  overscroll-behavior: none;
  font-family: "MedievalSharp", serif;
  position: fixed;
  -webkit-user-select: none;
}

html, body {
  touch-action: none !important;         /* Absolutely block all gestures */
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  overscroll-behavior: none !important;
  -webkit-text-size-adjust: 100%;        /* Prevent font scaling on zoom */
}
button, input, textarea {
  touch-action: manipulation !important; /* Allow tapping, but block gestures */
}


*, *::before, *::after {
  box-sizing: border-box;
  -webkit-user-drag: none;
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  padding: 0;
  font-family: inherit;
}
@font-face {
  font-family: "MedievalSharp";
  src: url("/fonts/skranji-regular.ttf") format("truetype");
}
input, textarea, select, button {
  background: none;
  border: none;
  outline: none;
  font-family: inherit;
  pointer-events: auto;
  touch-action: manipulation;
}

.base-hud-button{
  width: 100%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position-x: left;
  background-position-y: bottom;
  text-align:center;
}

.menu-button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  text-align: center;
  pointer-events: auto;
  box-sizing: border-box;
  overflow: hidden;
  cursor: pointer;
  padding: 0.5rem;
  background: rgba(0,0,0,0.5);
  border:1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  font-size: 0.85rem;
  max-width:100px;
  margin-bottom:0.5rem;
   box-shadow: 0 4px 6px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}


.use-button{
  aspect-ratio:1/1;
}

/* -------------------------------------- */
/* CANVAS BEHAVIOR                        */
/* -------------------------------------- */
canvas {
  display: block;
  image-rendering: pixelated !important;
  -moz-image-rendering: pixelated !important;
  image-rendering: crisp-edges;
  transform: translateZ(0);
  touch-action: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}
#overlayCanvas {
  pointer-events: auto;
  touch-action: none;
}

/* -------------------------------------- */
/* HUD                                    */
/* -------------------------------------- */
.hud-root {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}
.hud-element {
  pointer-events: auto;
  cursor: pointer;
}

/* -------------------------------------- */
/* UI Theme Variables                     */
/* -------------------------------------- */
:root {
  --safe-top:    calc(env(safe-area-inset-top, 1vh) + 1rem);
  --safe-right:  calc(env(safe-area-inset-right, 1vw) + 1rem);
  --safe-bottom: calc(env(safe-area-inset-bottom, 1vh) + 1rem);
  --safe-left:   calc(env(safe-area-inset-left, 1vw) + 1rem);
  --pane-padding: 0.5rem;
}

/* -------------------------------------- */
/* UI Panes                               */
/* -------------------------------------- */
.hud-pane-base {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  background: none !important;
  z-index: 1;
  transform: none;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}
.hud-pane-base > .hud-pane-base-grid {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-areas:
    "topLeft topCenter topRight"
    "middleLeft center middleRight"
    "bottomLeft bottomCenter bottomRight";
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}
.hud-area {
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.hud-area.topLeft      { grid-area: topLeft;      justify-content: flex-start;  align-items: flex-start; flex-direction: column; }
.hud-area.topCenter    { grid-area: topCenter;    justify-content: center;      align-items: flex-start; }
.hud-area.topRight     { grid-area: topRight;     justify-content: flex-end;    align-items: flex-start; }
.hud-area.middleLeft   { grid-area: middleLeft;   justify-content: flex-start;  align-items: center; }
.hud-area.center       { grid-area: center;       justify-content: center;      align-items: center; }
.hud-area.middleRight  { grid-area: middleRight;  justify-content: flex-end;    align-items: center; }
.hud-area.bottomLeft   { grid-area: bottomLeft;   justify-content: flex-start;  align-items: flex-end; }
.hud-area.bottomCenter { grid-area: bottomCenter; justify-content: center;      align-items: flex-end; }
.hud-area.bottomRight  { grid-area: bottomRight;  justify-content: flex-end;    align-items: flex-end; }

/* -------------------------------------- */
/* Fixed-size pane for menu (tabbed pane) */
/* -------------------------------------- */
.hud-pane {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  background: #1a1a1a;
  z-index: 9999;
  pointer-events: auto;
  box-sizing: border-box;
  min-width: 25vw;
  max-height: 80vh;
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

/* Specific styles for HUD menu with tabs */
.hud-pane.hud-menu {
  width: 100%;
  max-width:55%;
  max-height: 55%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media only screen and (max-width: 768px) {
  .hud-pane.hud-menu{
    max-width:75%;
  }
}

/* -------------------------------------- */
/* Menu Tabs                              */
/* -------------------------------------- */
.menu-tab-bar {
  flex-shrink: 0;
  padding: 0.5rem;
  border-bottom: 1px solid #444;
  background-color: #1e1e1e;
  z-index: 1;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
}
.menu-tab {
  pointer-events: auto;
  color: white;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.5rem 1rem;
  background: #2a2a2a;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease, border-bottom 0.2s ease;
  border-bottom: 2px solid transparent;
}
.menu-tab:hover {
  background-color: #333;
}
.menu-tab.active {
  border-bottom: 2px solid white;
}

/* -------------------------------------- */
/* Scrollable section inside menu pane    */
/* -------------------------------------- */
.menu-section-display {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  scroll-behavior: smooth;
}
.menu-section-display::-webkit-scrollbar {
  width: 8px;
}
.menu-section-display::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 4px;
}
.menu-section-display::-webkit-scrollbar-track {
  background: #1a1a1a;
}

/* -------------------------------------- */
/* Health & XP UI                         */
/* -------------------------------------- */
.health-bar {
  background: linear-gradient(to right, #1a1a1a, #222);
  border: 2px solid #333;
  border-radius: 10px;
  box-shadow: 0 0 8px rgba(255, 0, 0, 0.3);
  width: 100%;
  height: 6vh;
  display: none;
  overflow: hidden;
  position: relative;
}
.health-fill {
  background: linear-gradient(to right, #8b0000, #e60000);
  box-shadow: inset 0 0 10px #ff0000;
  height: 100%;
  width: 100%;
}
.health-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-weight: bold;
  font-size: 90%;
  text-shadow: 1px 1px 2px #000;
  width: 100%;
  text-align: center;
}
.xp-bar {
  background: #222;
  border: 1px solid #555;
  height: 2.75vh;
  width: 100%;
  position: relative;
  margin-top: 4px;
  border-radius: 4px;
  overflow: hidden;
  align-items: center;
}
.xp-fill {
  background: linear-gradient(to right, #4fc3f7, #1976d2);
  height: 100%;
  width: 0%;
  transition: width 0.2s;
}
.xp-text {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  font-size: 10px;
  color: #ccc;
  text-align: center;

  display: flex;
  align-items: center;        /* vertical centering */
  justify-content: center;   /* horizontal centering */
  pointer-events: none;
  z-index: 1;
}


/* -------------------------------------- */
/* HUD Slots                              */
/* -------------------------------------- */
.hud-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  text-align: center;
  pointer-events: auto;
  box-sizing: border-box;
  overflow: hidden;
  cursor: pointer;
  padding: 0.5rem;
  background: linear-gradient(145deg, #1f1f1f, #292929);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
  aspect-ratio: 1 / 1;
  transition: background 0.2s ease;
}
.hud-slot:hover {
  background: #333;
}
.hud-slot .slot-label {
  margin-top: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  font-size: 0.75rem;
}

/* -------------------------------------- */
/* Chat Section                           */
/* -------------------------------------- */
.chat-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chat-log {
  flex: 1;
  width: 100%;
  min-height: 150px;
  background: #2b2b2b;
  color: white;
  border: 1px solid darkslategrey;
  padding: 0.5rem;
  overflow-y: auto;
  border-radius: 4px;
}
.chat-controls {
  display: flex;
  width: 100%;
  gap: 0.5rem;
}
.chat-input {
  flex: 1;
  padding: 0.5rem;
  background: #222;
  color: white;
  border: 1px solid darkslategrey;
  border-radius: 4px;
  font-size: 0.9rem;
}
.chat-send {
  padding: 0.5rem 1rem;
  background: #3a3a3a;
  color: white;
  border: 1px solid darkslategrey;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease;
  white-space: nowrap;
}
.chat-send:hover {
  background: #555;
}

/* -------------------------------------- */
/* Inventory Grid                         */
/* -------------------------------------- */
.menu-section-inventory {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 0.75rem;
  padding: 0.5rem;
}

/* -------------------------------------- */
/* Settings Section                       */
/* -------------------------------------- */
.menu-section-settings {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.setting-control {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.menu-section-settings label {
  min-width: 140px;
  color: #ccc;
  font-size: 0.95rem;
  font-weight: 500;
}
.menu-section-settings input[type="range"] {
  flex: 1;
  accent-color: #4fc3f7;
  height: 4px;
  background: #444;
  border-radius: 2px;
}
.menu-section-settings button {
  padding: 0.5rem 1rem;
  background: #2f2f2f;
  color: white;
  border: 1px solid #555;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: 0.95rem;
}
.menu-section-settings button:hover {
  background: #444;
}

.pressed {
  transform: scale(90%);
}

/* -------------------------------------- */
/* Keybindings Section                    */
/* -------------------------------------- */
.menu-section-keybindings {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.keybinding-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.keybinding-row .label {
  flex: 1;
  color: white;
  font-size: 0.95rem;
}
.keybinding-row .key-button {
  padding: 0.4rem 0.8rem;
  background: #2c2c2c;
  color: white;
  border: 1px solid #555;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s ease;
  min-width: 64px;
  text-align: center;
}
.keybinding-row .key-button:hover {
  background: #444;
}

/* -------------------------------------- */
/* Update Log Section                     */
/* -------------------------------------- */
.update-log-entry {
  background-color: #1e1e1e;
  border: 1px solid #333;
  border-radius: 8px;
  margin-bottom: 2rem;
  padding: 1.5rem;
  color: #ddd;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  font-family: 'Segoe UI', sans-serif;
}

.update-log-entry,
.update-log-entry * {
  white-space: normal !important;
  overflow-wrap: break-word !important;
  word-break: break-word;
  max-width: 100%;
}

.update-log-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}
.update-log-title {
  font-size: 1.5rem;
  margin: 0;
  color: #fff;
}
.update-log-date {
  font-size: 0.9rem;
  color: #aaa;
}
.update-log-summary {
  font-size: 1rem;
  margin: 0.5rem 0 1rem;
  color: #bbb;
}
.update-log-details {
  margin-top: 1rem;
}
.update-log-section {
  margin-bottom: 1.5rem;
}
.update-log-section-title {
  font-size: 1.2rem;
  color: #ffd580;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #444;
  padding-bottom: 0.25rem;
}
.update-log-section ul {
  list-style-type: disc;
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}
.update-log-section li {
  margin-bottom: 0.4rem;
  line-height: 1.4;
  color: #ccc;
}

/* -------------------------------------- */
/* Responsive                             */
/* -------------------------------------- */

.hud-pane:not(.hud-pane-base) * {
  pointer-events: auto;
}
.hud-pane-base {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width:100%;
  height: 100%;
  max-height:100%;
  pointer-events: none;
  background: none !important;
  z-index: 1;
  transform: none;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}
