
/* ============================
   World Panel (root container)
   ============================ */
#world-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0; /* always behind UI panels */
}

#world-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url("assets/bg_main.png") no-repeat center center;
  background-size: cover;
  z-index: -1; /* background layer */
}

body {
  background: #0d1b2a;
  color: #fff;
  font-family: sans-serif;
  margin: 0;
  overflow: hidden;
  cursor: none; /* hide OS cursor */
}

/* Default for most panels */
.panel {
  position: absolute;
  background: rgba(114, 141, 235, 0.65);
  border: 2px solid #415a77;
  border-radius: 12px;
  padding: 10px;
  color: #fff;
  display: none;
  background-size: cover;
  background-position: top center;
  cursor: none;
}

/* Preserve opaque backgrounds for garden, focus, and minigame arenas */
#garden,
#focus-panel,
#race-arena-panel,
#karate-arena-panel,
#class-arena-panel,
#adventure-arena-panel {
  background: #1b263b;
}

/* Hide all tab contents by default */
#chaoregon-bg-panel .tab-content {
  display: none;
}

/* Only show the active one */
#chaoregon-bg-panel .tab-content.active {
  display: block;
}

/* Banner panels: true pixel sizes + above arenas */
#race-banner-panel {
  width: 498px;
  height: 147px;
  background: url("assets/banners/banner_chaorace.png") no-repeat center center;
  background-size: 100% 100%;
  z-index: 5;
}
#karate-banner-panel {
  width: 482px;
  height: 125px;
  background: url("assets/banners/banner_chaokarate.png") no-repeat center center;
  background-size: 100% 100%;
  z-index: 5;
}
#class-banner-panel {
  width: 497px;
  height: 108px;
  background: url("assets/banners/banner_kindergarten.png") no-repeat center center;
  background-size: 100% 100%;
  z-index: 5;
}
#adventure-banner-panel {
  width: 539px;
  height: 102px;
  background: url("assets/banners/banner_adventure.png") no-repeat center center;
  background-size: 100% 100%;
  z-index: 5;
}

/* Panel headers SA2B-style */
.panel h3 {
  font-size: 18px;
  font-weight: bold;
  color: #fffc00;
  text-shadow: 2px 2px 0px #000;
  margin: 0 0 8px 0;
  text-align: center;
  letter-spacing: 1px;
}

/* ============================
   Garden Panels
   ============================ */

#darkgarden {
  display: block !important;
  position: absolute;
  width: 1181px;
  height: 672px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: url("assets/bgs/bg_darkGarden.png") center center no-repeat;
  background-size: cover;
  border: 2px solid #415a77;
  border-radius: 12px;
  cursor: none;
}

#herogarden {
  display: block !important;
  position: absolute;
  width: 1181px;
  height: 672px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: url("assets/bgs/bg_heroGarden.png") center center no-repeat;
  background-size: cover;
  border: 2px solid #415a77;
  border-radius: 12px;
  cursor: none;
}

/* Neutral Garden */
#garden {
  display: block !important;
  position: absolute;
  width: 800px;
  height: 450px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: url("assets/bgs/bg_nGarden.png") center center no-repeat;
  background-size: cover;
  border: 2px solid #415a77;
  border-radius: 12px;
  cursor: none;
}


/* Canvases inside */
#garden-canvas,
#darkgarden-canvas,
#herogarden-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}


/* ============================
   Stats + Focus
   ============================ */
.stats-page { display: none; }
.stats-page.active { display: block; }

.stat-block { margin-bottom: 6px; }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2px 0;
  font-size: 14px;
}

.stat-name {
  color: #ffffff;
  font-weight: bold;
  text-shadow: 2px 2px 0px #000;
}

.stat-points {
  color: #ffffff;
  font-family: monospace;
  text-shadow: 2px 2px 0px #000;
  min-width: 45px;
  text-align: right;
}

.stat-level {
  color: #fffc00;
  text-shadow: 2px 2px 0px #000;
  font-weight: bold;
  margin-right: 6px;
  min-width: 50px;
  text-align: left;
}

.stat-bars {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: 6px;
}

/* ============================
   Pixel-Perfect Stat Bars
   ============================ */
.upper-bar {
  width: 194px;
  height: 15px;
  background: #848a83;
  border: 4px solid #000;
  border-bottom: 2px solid #000;
  box-sizing: border-box;
  overflow: hidden;
}

.upper-bar .bar-fill {
  height: 100%;
  width: 0%;
  background: yellow;
  transition: width 0.3s, background-color 0.3s;
}

.lower-bar {
  width: 194px;
  height: 15px;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  background: #000;
  border: 4px solid #000;
  border-top: 2px solid #000;
  box-sizing: border-box;
}

.lower-bar .pip {
  background: #848a83;
  height: 100%;
}
.lower-bar .pip.filled { background: #5b63ff; }

/* Grades */
#stats-panel [id$="-grade"] {
  color: #ffd60a;
  font-weight: bold;
}

/* ============================
   Snap-On Debug Panel
   ============================ */
#stats-debug-panel {
  width: 200px;
  min-height: 120px;
  background: #1b263b;
  border: 2px solid #415a77;
  border-radius: 12px;
  padding: 10px;
  color: #fff;
  display: none;
  z-index: 1500;
}

#stats-debug-panel h3 {
  font-size: 16px;
  font-weight: bold;
  color: #ffd60a;
  text-shadow: 2px 2px 0px #000;
  margin: 0 0 6px 0;
  text-align: center;
}

#stats-debug-panel p {
  margin: 4px 0;
  font-size: 13px;
}

#debug-output {
  font-size: 12px;
  font-family: monospace;
  white-space: pre;
  background: #0d1b2a;
  border: 1px solid #415a77;
  border-radius: 6px;
  padding: 4px;
  margin-top: 6px;
  max-height: 120px;
  overflow-y: auto;
}

#focus-image { margin-bottom: 10px; }
#focus-details p { margin: 2px 0; }

/* ============================
   Journal
   ============================ */
.journal-page { display: none; }
.journal-page.active { display: block; }
#journal-panel .tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 10px;
}
#journal-panel #journal-adventures {
  color: #ffd60a;
  font-weight: bold;
}

/* ============================
   Trash + Inventory
   ============================ */
#trash-panel h3 img,
#inventory-panel h3 img {
  height: 24px;
  vertical-align: middle;
}
#inventory-panel .tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 10px;
}
#inventory-panel .tabs button {
  flex: 1;
  padding: 4px;
  background: #415a77;
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
}
#inventory-panel .tabs button.active {
  outline: 2px solid #ffd60a;
  background: #1b263b;
}
#inventory-panel .grid {
  display: grid;
  grid-template-columns: repeat(3, 60px);
  gap: 5px;
}
#inventory-panel .slot {
  width: 60px;
  height: 60px;
  background: #415a77;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#inventory-panel .slot.empty { background: #222; }

/* ============================
   Shop
   ============================ */
#shop-panel .tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 10px;
}
#shop-panel .shop-item {
  padding: 5px;
  background: #415a77;
  margin-bottom: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
#shop-panel .shop-item img { flex-shrink: 0; }

/* ============================
   Race + Karate Arenas
   ============================ */
#race-canvas,
#race-banner-canvas,
#karate-canvas {
  border: 2px solid #415a77;
  background: #1b263b;
  display: block;
  margin: 10px 0;
}

/* ============================
   Arena Panels (true sizes)
   ============================ */
#karate-arena-panel { width: 500px; height: 300px; }
#race-arena-panel { width: 442px; height: 133px; }
#class-arena-panel { width: 690px; height: 437px; position: relative; }
#adventure-arena-panel { width: 480px; height: 220px; }

/* Progress bar for classes */
#class-progress {
  width: 100%;
  height: 20px;
  border: 2px solid #415a77;
  border-radius: 6px;
  background: #222;
  margin-bottom: 6px;
  overflow: hidden;
}
#class-progress-fill {
  height: 100%;
  width: 0%;
  background: #5b63ff;
  transition: width 1s linear;
}

/* Class status box */
#class-status-box {
  position: absolute;
  right: 10px;
  top: 40px;
  width: 200px;
  padding: 6px;
  background: rgba(0,0,0,0.65);
  border: 2px solid #415a77;
  border-radius: 8px;
  font-size: 14px;
  text-align: left;
}
#class-status-box p { margin: 2px 0; }

/* ============================
   Toolbars
   ============================ */
.toolbar {
  position: absolute;
  display: flex;
  gap: 5px;
}
#toolbar1 { bottom: 10px; left: 10px; }
#toolbar2 { position: relative; margin-top: 6px; display: flex; gap: 5px; }
.toolbar button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  background: #1b263b;
  cursor: pointer;
  padding: 0;
}
.toolbar button.off {
  opacity: 0.5;
  background: #555;
}
.toolbar button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.toolbar button.active {
  outline: 2px solid #ffd60a;
  background: #415a77;
}

/* ============================
   Cursor + Wheel
   ============================ */
#cursor {
  position: fixed;
  width: 32px;
  height: 32px;
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 2147483647;
  background-image: url("assets/ui/cursor-select.png");
  image-rendering: pixelated;
}
#cursor-wheel {
  display: none;
  position: fixed;
  width: 100px;
  height: 100px;
  background: url("assets/icons/wheel1.png") no-repeat center center;
  background-size: contain;
  pointer-events: none;
  z-index: 2147483646;
}
#cursor-wheel .quadrant { position: absolute; width: 50%; height: 50%; pointer-events: auto; }
#cursor-wheel .quadrant:nth-child(1) { left: 0; top: 0; }
#cursor-wheel .quadrant:nth-child(2) { left: 50%; top: 0; }
#cursor-wheel .quadrant:nth-child(3) { left: 0; top: 50%; }
#cursor-wheel .quadrant:nth-child(4) { left: 50%; top: 50%; }
#cursor-wheel .quadrant:hover { background: rgba(255, 214, 10, 0.2); }

/* ============================
   Debug Panel
   ============================ */
#debug-panel {
  display: block;
  position: absolute;
  top: 10px;
  left: 360px;
  width: 280px;
  background: #1b263b;
  border: 2px solid #415a77;
  border-radius: 12px;
  padding: 6px;
  color: #fff;
  z-index: 2000;
}
#debug-panel h3 {
  margin: 0 0 6px 0;
  font-size: 14px;
  color: #ff4444;
}
#debug-panel .content {
  font-size: 12px;
  white-space: pre-line;
}

/* ============================
   Chao + Items + Eggs
   ============================ */
#chao-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
}
.chao,
.egg,
.garden-item {
  position: absolute;
  width: 32px;
  height: 32px;
  pointer-events: auto;
  image-rendering: pixelated;
}
.chao-label {
  font-size: 10px;
  text-align: center;
  color: white;
  text-shadow: 1px 1px 2px black;
}
.dot {
 position: absolute;
  top: -6px;
  left: 35%;
  transform: translateX(-50%) scale(2.0);
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
}
.garden-item.picked { opacity: 0.7; }

/* ============================
   Focus Panel as Camera Viewport
   ============================ */
#focus-image {
  width: 160px;
  height: 160px;
  overflow: hidden;
  position: relative;
  border: 2px solid #415a77;
  border-radius: 8px;
  background: #000;
}
#focus-image .focus-viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 800px;
  height: 450px;
  transform-origin: top left;
}
#focus-details { text-align: center; margin-top: 4px; }

/* ============================
   Chaoregon Trail
   ============================ */
#chaoregon-banner-panel {
  width: 539px;
  height: 102px;
  background: url("assets/banners/banner_chaoregontrail.png") no-repeat center center;
  background-size: 100% 100%;
  z-index: 5;
}
#chaoregon-bg-panel {
  width: 640px;
  height: 360px;
  background-size: cover;
  position: relative;
  display: flex;
  flex-direction: column;
  z-index: 6;
}
#chaoregon-bg-panel .split {
  width: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  float: left;
}
#chaoregon-bg-panel .split button {
  font-size: 20px;
  padding: 10px 20px;
}
#chaoregon-log-panel {
  width: 300px;
  height: 200px;
  overflow-y: auto;
}
#chaoregon-wagon {
  text-align: center;
  font-size: 24px;
  margin-bottom: 10px;
}

/* ============================
   Party Manager (classic panel)
   ============================ */
#party-panel {
  width: 600px;
  height: 350px;
  overflow: hidden;
}
.party-container {
  display: flex;
  height: calc(100% - 40px);
}
.chao-list {
  width: 300px;
  height: 100%;
  overflow-y: auto;
  border: 1px solid #415a77;
  padding: 5px;
  background: rgba(0,0,0,0.4);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
  align-content: flex-start;
}
.chao-entry {
  width: 72px;
  text-align: center;
  cursor: pointer;
  position: relative;
}
.chao-entry .sprite-wrap {
  position: relative;
  width: 48px;
  height: 48px;
  margin: 0 auto;
}
.chao-entry img { image-rendering: pixelated; }
.chao-entry .sprite-wrap img.idle {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  background: rgba(0,0,0,0.3);
  border: 2px solid transparent;
}
.chao-entry .sprite-wrap img.dot {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%) scale(1.5);
  width: 16px;
  height: 16px;
}
.chao-entry:hover .sprite-wrap img.idle { border-color: yellow; }
.chao-entry.selected .sprite-wrap img.idle { border-color: lime; }
.chao-entry div { font-size: 12px; margin-top: 2px; }
.party-slots {
  flex: 1;
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 8px;
  align-items: center;
  justify-items: center;
  padding: 5px;
}
.party-slots .slot {
  width: 72px;
  height: 72px;
  border: 2px dashed #415a77;
  border-radius: 8px;
  background: rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}
.party-slots .slot .sprite-wrap { position: relative; width: 48px; height: 48px; }
.party-slots .slot .sprite-wrap img.idle {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
}
.party-slots .slot .sprite-wrap img.dot {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%) scale(1.5);
  width: 16px;
  height: 16px;
}
.party-slots .slot span { font-size: 12px; margin-top: 2px; }

/* ============================
   Party Hub (main hub)
   ============================ */
#partyhub-panel {
  width: 512px;
  height: 512px;
  background: url("assets/ui/partyhub.png") no-repeat center center;
  background-size: cover;
  position: relative;
  overflow: hidden;
  border: 2px solid #415a77;
  border-radius: 12px;
}
.party-hub-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 40px;
  position: absolute;
  top: 15%;
  left: 15%;
  right: 15%;
  bottom: 15%;
}
.party-hub-buttons .hub-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(27, 38, 59, 0.7);
  border: 3px solid #ffd60a;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
}
.party-hub-buttons .hub-btn:hover {
  background: rgba(65, 90, 119, 0.9);
  transform: scale(1.08);
}
.party-hub-buttons .hub-btn img {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
}

/* ============================
   Party Hub Sub-Pages
   ============================ */
#partyhub-panel .party-page {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  padding: 20px;
  background: rgba(0,0,0,0.5);
  display: none;
  overflow-y: auto;
}
#partyhub-panel .party-page:not(.hidden) { display: block; }
#partyhub-panel .back-btn {
  margin-top: 10px;
  margin-bottom: 20px;
  padding: 6px 12px;
  background: #415a77;
  color: #fff;
  border: 2px solid #ffd60a;
  border-radius: 6px;
  cursor: pointer;
}
#partyhub-panel .back-btn:hover { background: #5b63ff; }

/* Tabs */
#partyhub-panel .party-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
#partyhub-panel .party-tabs .tab {
  flex: 1;
  padding: 6px;
  background: #1b263b;
  border: 2px solid #415a77;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
}
#partyhub-panel .party-tabs .tab.active {
  background: #415a77;
  border-color: #ffd60a;
}

/* Scroll grids */
.party-scroll-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 64px);
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}
.party-scroll-grid.hidden { display: none; }
.party-scroll-grid .chao-slot {
  width: 64px;
  height: 64px;
  background: rgba(0,0,0,0.4);
  border: 2px solid #415a77;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
}
.party-scroll-grid .chao-slot:hover {
  border-color: #ffd60a;
  background: rgba(255,214,10,0.2);
}

/* Move Party Grid */
#move-party-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 10px;
  margin: 20px auto;
  width: 100%;
  max-width: 300px;
}
#move-party-grid .slot {
  width: 80px;
  height: 80px;
  background: rgba(0,0,0,0.4);
  border: 2px dashed #415a77;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
}
#move-hero-btn,
#move-dark-btn {
  margin: 5px;
  padding: 8px 14px;
  font-size: 14px;
  background: #1b263b;
  border: 2px solid #415a77;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
}
#move-hero-btn:hover,
#move-dark-btn:hover {
  background: #415a77;
  border-color: #ffd60a;
}

/* Status Page */
#party-status-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.status-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,0.4);
  border: 2px solid #415a77;
  border-radius: 8px;
  padding: 6px;
}
.status-entry .status-party {
  display: flex;
  gap: 5px;
}
.status-entry .status-info {
  display: flex;
  flex-direction: column;
  font-size: 13px;
}
.status-entry .cancel-btn {
  background: #a02020;
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  padding: 4px 8px;
}
.status-entry .cancel-btn:hover { background: #d03030; }

/* Minigame Banners */
#party-minigames .minigame-banner {
  margin: 10px auto;
  width: 400px;
  cursor: pointer;
  border: 2px solid #415a77;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0,0,0,0.4);
  transition: transform 0.1s;
}

#party-minigames .minigame-banner img {
  display: block;
  width: 100%;
  height: auto;
}

#party-minigames .minigame-banner:hover {
  transform: scale(1.05);
  border-color: #ffd60a;
}


/* ============================
   Janken
   ============================ */
#chaojanken-panel {
  width: 600px;
  height: 400px;
  position: relative;
  background: #ffd84a;
  image-rendering: pixelated;
  overflow: hidden;
}
#janken-field {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 400px;
  height: 250px;
  border: 2px solid #fff;
  overflow: hidden;
  z-index: 1;
}
#janken-hand {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: 400px;
  display: flex;
  justify-content: center;
  gap: 12px;
  z-index: 2;
}
#janken-ui {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 3;
}
.janken-box {
  position: relative;
  width: 120px;
  height: 50px;
}
.janken-box .box-bg { width: 100%; height: 100%; display: block; }
.janken-box .box-icon {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
}
.janken-box span {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: monospace;
  font-size: 18px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

/* Janken Cards */
.janken-card {
  width: 48px;
  height: 48px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  image-rendering: pixelated;
  cursor: pointer;
  z-index: 5;
  position: relative;
}
#janken-field .janken-card { position: absolute; }
#janken-hand .janken-card { position: static; }
.janken-card .selector {
  position: absolute;
  top: -4px;
  left: -4px;
  width: 56px;
  height: 56px;
  background: url("assets/ui/JankenEmpty.png") no-repeat center center;
  background-size: contain;
  display: none;
  pointer-events: none;
}

/* Journal highlights for Janken stats */
#journal-panel #journal-janken,
#journal-panel #journal-janken-rings {
  color: #ffd60a;
  font-weight: bold;
}

/* Force hide OS cursor globally */
html, body, .panel, canvas, button, input, select {
  cursor: none !important;
}

