@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@700&display=swap');

html, body {
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  height: 100%;
}

.branding .logo {
  height: 40px;
  opacity: 75%;
}

html.loading #loader-overlay {
  visibility: visible !important;
  background-color: #223;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* Loader overlay styles */
#loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #223;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: background-color 0.8s ease, opacity 0.8s ease;
}

html:not(.loading) #loader-overlay {
  opacity: 0;
  background-color: transparent;
  pointer-events: none;
}
.hidden {
  visibility: hidden !important;
}


/* Sheep spinner */
.spinner {
  width: 200px;
  height: 200px;
  background-image: url('../images/sheepy.png');
  background-size: contain;
  background-repeat: no-repeat;
  animation: sheep-spin 2s linear infinite;
}

@keyframes sheep-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

:root {
  --compass-north-color: #e74c3c;   /* Red */
  --compass-south-color: #2ecc71;   /* Green */
  --compass-default-color: #fff;    /* White */
}

body {
  margin: 0;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #fff;
  padding-top: 0;
}

.header-brand {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 200;
  display: flex;
  flex-direction: row;
  gap: 14px;
  align-items: center;
  background: none;
  box-shadow: none;
  border: none;
}

.header-brand a {
  display: inline-flex;
  align-items: center;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 0.7em;
  color: #fff;
  height: 100%;
}

 .header-brand a:link, .header-brand a:visited {
      text-decoration: none;
}

#sidebar,#levelSelectorBox {
  z-index: 100;
}

.level-wheel-container {
  position: fixed;
  top: 10px;
  left: 285px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 190px;
  overflow: visible;
}

.level-wheel-container::before {
  content: "";
  pointer-events: none;
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 0;
  border-radius: 8px;
  z-index: 2;
  /* Fade to background at top/bottom, nothing at middle */
  background:
    linear-gradient(
      to bottom,
      #22243998 18%, /* match bg, more opaque at very top */
      #22243900 40%, /* transparent at 40% */
      #22243900 60%, /* transparent at 60% */
      #222439a9 82%  /* dark fade again at bottom */
    );
  mix-blend-mode: normal;
}

.wheel-arrow {
  font-size: 1em;
  background: none;
  color: #fff;
  border: none;
  margin: 4px 0;
  cursor: pointer;
}
.level-wheel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 35px;
  margin: 4px 0;
}
.level-item {
  width: 80%;
  padding: 1px 0;
  height: 20px;
  line-height: 18px;
  text-align: center;
  border-radius: 7px;
  margin: 1px 0;
  font-size: 0.8em;
  color: #ffffffa1;
  cursor: pointer;
  opacity: 0.65;
  transition: background 0.14s, color 0.18s, opacity 0.18s;
}
.level-item.center {
  background: #4d4d94;
  color: #e6ded3;
  font-size: 1em;
  font-weight: 500;
  cursor: default;
  opacity: 1.0;
}
.level-item.fade1 { opacity: 0.70; }
.level-item.fade2 { opacity: 0.55; }
.level-item.fade3 { opacity: 0.42; }
.level-item.fade4 { opacity: 0.30; }
.level-item.fade5, .level-item.fade6, .level-item.fade7 { opacity: 0.17; }
.level-item:not(.center):hover {
  background: #fff3;
  color: #fff;
  opacity: 0.99;
}

canvas {
  margin: 0;
  position: absolute;
  top: 0;
  left: 0;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 900px) {
  .level-wheel-container {
    left: 185px;
    min-width: 40px;
    padding: 12px 2px;
  }
  #floating-level-controls {
    left: 220px;
    min-width: 120px;
    padding: 18px 6px;
  }
  #sidebar {
    min-width: 160px;
    width: 170px;
    font-size: 14px;
  }
  .file-controls {
    right: 6px;
    gap: 6px;
  }
}

#gridToggleBtn {
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
  padding: 0;
  min-width: 30px;
}

.editor-wrapper  {
  display: flex;
  align-items: flex-start;
}

#sidebar {
  width: 290px;
  min-width: 220px;
  max-width: 350px;
  margin-left: 10px;
}

#controls {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  width: calc(100% - 20px);
  z-index: 10;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

canvas {
  display: block;
}

.ui-element {
  padding: 0 12px;
  font-size: 12px;
  background-color: #42425b;
  color: #e6ded3;
  border: 1px #1f1f2f;
  border-radius: 6px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.11);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  transition: background-color 0.2s ease, transform 0.1s ease;
  cursor: pointer;
  font-family: system-ui, sans-serif;
  height: 26px;
  min-width: 38px;
}

.ui-element:hover {
  background-color: #50506a;
}

.ui-element:focus {
  outline: none;
  box-shadow: 0 0 0 2px #4d4d94;
}

#upButton,
#downButton {
  width: 36px;
  font-weight: bold;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vnum-pair {
  display: flex;
  flex-direction: row;
  gap: 12px;
  justify-content: space-between;
}

.vnum-pair label {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.vnum-pair {
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.vnum-pair label {
  flex: 1;
}

#tool-info input, #tool-info select {
  padding: 4px 6px;
  border: 1px solid #4d4d94;
  border-radius: 4px;
  background-color: #3a3a4d;
  color: #bfab90;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  margin-top: 5px;
}

.vnum-row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.vnum-row label {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#tool-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  position: fixed;
  top: 10px;
  width: 250px;
  background-color: #3a3a4dae;
  padding: 10px;
  transition: max-height 0.3s ease;
  overflow: auto;
  min-height: 160px;
  max-height: 98vh;
  height: auto;
  z-index: 200;
  pointer-events: auto;
}

#tool-info.expanded-area,
#tool-info.expanded-room {
  max-height: 98vh;
}

#tool-info.collapsed {
  max-height: 160px;
  overflow: hidden;
}

#tool-info label {
  font-weight: bold;
  margin-bottom: 2px;
}

#tool-info input {
  padding: 4px 6px;
  border: 1px solid #4d4d94;
  border-radius: 4px;
  background-color: #3a3a4d;
  color: #b9b1a5;
  margin-top: 5px;
  margin-bottom: 10px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}

#tool-info input:focus {
  outline: none;
  box-shadow: 0 0 0 2px #4d4d94;
}

#tool-info > div:not(.vnum-row) {
  display: flex;
  flex-direction: column;
  width: 100%;
}

#tool-info:hover {
  background-color: #3a3a4dae;
}

#tool-info:focus {
  outline: none;
  box-shadow: 0 0 0 2px #4d4d94;
}

.field-group label {
  font-weight: bold;
  display: block;
}

.field-group {
  width:100%;
}

.full-width {
  width: 100%;
  padding: 4px 6px;
  box-sizing: border-box;
}

.vnum-row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.vnum-field {
  flex: 1;
}

.compass-label {
  position: absolute;
  font-weight: bold;
  color: white;
  font-size: 16px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 10;
}

#tool-info textarea.full-width {
  resize: none;
  height: 100px;
  width: 100%;
  box-sizing: border-box;
  overflow: auto;
  padding: 4px 6px;
  border: 1px solid #4d4d94;
  border-radius: 4px;
  background-color: #3a3a4d;
  color: #b9b1a5;
  margin-top: 5px;
  font-size: 12px;
}

#tool-info textarea.full-width:focus {
  outline: none;
  box-shadow: 0 0 0 2px #4d4d94;
}

#helpPopup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(20, 20, 30, 0.85);
  backdrop-filter: blur(8px);
  color: #b59c7e;
  padding: 24px 32px;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: none;
  max-width: 660px;
  height: 450px;
  overflow-y: auto;
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

#helpPopup ul {
  list-style: none;
  padding-left: 0px;
}

/* Thin scroll bar for help popup */
#helpPopup::-webkit-scrollbar {
  width: 4px;
}
#helpPopup::-webkit-scrollbar-track {
  background: transparent;
}
#helpPopup::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

/* Style spans inside the help popup */
#helpPopup strong {
  display: block;
  margin-top: 8px;
  color: #c4bbb1;
  font-size: 0.95em;
  line-height: 1.4;
  font-weight: 900;
}

#helpPopup.show {
  display: block;
}

#helpPopup h2 {
  margin-top: 0;
}

#helpClose {
  margin-top: 10px;
  padding: 6px 12px;
  background-color: #444;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#helpClose:hover {
  background-color: #666;
}

.key {
  color: #8888ff;
}

input[type="number"] {
  appearance: auto;        /* Standard: show native spinner */
  /* -webkit-appearance: none;  Chrome, Safari - removed to keep spinner arrows */
  -moz-appearance: auto;   /* Firefox: show native spinner */
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  background-color: #3a3a4d;
  border-left: 1px solid #4d4d94;
  height: 100%;
  filter: invert(1);
}

input[type="number"]::-webkit-inner-spin-button {
  background-color: #3a3a4d;
  border-left: 1px solid #4d4d94;
  filter: invert(1);
}

input[type="number"]::-webkit-outer-spin-button {
  background-color: #3a3a4d;
  border-left: 1px solid #4d4d94;
  filter: invert(1);
}

input[type="number"]::part(increment),
input[type="number"]::part(decrement) {
  background-color: #3a3a4d;
  color: white;
  border-radius: 4px;
  padding: 2px;
}

/*#tool-info::-webkit-scrollbar {
  width: 6px;
}

#tool-info::-webkit-scrollbar-thumb {
  background-color: #666;
  border-radius: 4px;
}

#tool-info::-webkit-scrollbar-track {
  background-color: transparent;
}

#tool-info {
  scrollbar-width: thin;
  scrollbar-color: #141424 transparent;
}*/

.room-color-option {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  outline: none;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
  flex: 0 0 auto;
  margin: 1px;
}

.room-color-option:hover:not(.selected) {
  transform: scale(1.1);
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}

.room-color-option.selected {
  outline: 2px solid #ffffff;
  box-shadow: 0 0 0 2px #4d4d94;
  transform: none;
}

#roomColorOptions {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: space-between;
}

#areaInfoContainer {
  position: relative;
  transition: height 0.35s cubic-bezier(0.42,0,0.58,1);
  overflow: hidden;
}

#areaInfoContainer.hidden {
  max-height: 0;
}

.tab-header {
  display: flex;
  gap: 5px;
  flex-grow: 1;
}

.tab-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  flex-direction: row !important;
}

.toggle-btn-on  { opacity: 1; }
.toggle-btn-off { opacity: 0.4; }

.tab-button {
  padding: 5px 12px;
  background-color: #3b3b4f;
  color: #ececec;
  border: 1px solid #272b29;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  font-size: 12px;
  min-width: 55px;
}

.tab-button.active {
  background-color: #5e5e82;
  font-weight: bold;
  font-weight: bold;
}

.tab-content {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 100%;
  left: 0;
  top: 0;
  transition: opacity 0.25s cubic-bezier(0.42,0,0.58,1);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.tab-content.active {
  opacity: 1;
  pointer-events: auto;
  position: static;
  transition: opacity 0.25s cubic-bezier(0.42,0,0.58,1);
}

#toggleAreaInfoBtn {
  height: 22px;
  min-width: 22px;
}

.toolbar {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.toolbar .ui-element {
  min-width: 30px;
  height: 30px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#fitViewBtn.locked {
  color: #e74c3c;
  border-radius: 4px;
}
#fitViewBtn.unlocked {
  border-radius: 4px;
  color: #2ecc71;
}

.toolbar .ui-element:focus {
  outline: none;
  box-shadow: none;
}

.ui-element.disabled {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(1);
}

.toolbar .fa-solid,
.toolbar .fa-regular,
.toolbar .fa-light,
.toolbar .fa-lock,
.toolbar .fa-duotone {
  width: 1em;
  height: 1em;
  line-height: 1;
  vertical-align: middle;
}

i.fa-solid.fa-lock {
  width: 1em;
  height: 1em;
  line-height: 1;
  vertical-align: middle;
}

#roomExitsList {
  margin: 6px 0 0 0;
  padding-left: 0 !important;
  list-style-type: none;
  font-size: 13px;
  color: #e6ded3;
  max-height: 160px;
  overflow-y: auto;
}

#roomExitsList li {
  margin-bottom: 4px;
  padding: 4px 0 4px 10px;
  border-left: 3px solid #4d4d94;
  transition: background 0.13s;
  cursor: pointer;
}

#roomExitsList li:hover {
  background: #223;
  border-radius: 4px;
  color: #fff;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  display: none;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

@keyframes puff-animation {
  0%   { background-image: url('../images/puff1.png'); transform: scale(2); opacity: 1; }
  20%  { background-image: url('../images/puff2.png'); transform: scale(2.2); opacity: 1; }
  50%  { background-image: url('../images/puff3.png'); transform: scale(2.4); opacity: 1; }
  60%  { background-image: url('../images/puff4.png'); transform: scale(2.6); opacity: 1; }
  90%  { background-image: url('../images/puff5.png'); transform: scale(2.8); opacity: 1; }
  100% { opacity: 0; transform: scale(3); }
}

.puff-effect {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 240px;
  height: 240px;
  margin-left: -120px;
  margin-top: -120px;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  pointer-events: none;
  z-index: 9999;
  animation: puff-animation 0.6s steps(1) forwards;
  background-color: transparent;
}