﻿:root {
  --ui-gold: #b89d63;
  --ui-border: #3f3625;
  --bg-dark: #0f0d0a;
  --panel-bg: rgba(16, 12, 8, 0.88);
  --text-main: #e3dbc7;
  --danger: #bb2f2f;
  --mana: #2f4cae;
  --menu-bg-1: #120d08;
  --menu-bg-2: #2a1b11;
  --menu-bg-3: #080604;
}

* {
  box-sizing: border-box;
  user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Noto Serif TC", serif;
  color: var(--text-main);
  background: radial-gradient(circle at 30% 20%, #221b14 0%, #090705 65%);
}

#game-root {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#char-select-screen {
  position: absolute;
  inset: 0;
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.char-select-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 20%, rgba(167, 115, 52, 0.23), transparent 38%),
    radial-gradient(circle at 80% 82%, rgba(117, 61, 33, 0.25), transparent 35%),
    linear-gradient(130deg, var(--menu-bg-1) 0%, var(--menu-bg-2) 48%, var(--menu-bg-3) 100%);
}

.char-select-shell {
  position: relative;
  width: min(980px, 100%);
  border: 1px solid #5f4930;
  background: rgba(14, 10, 7, 0.92);
  box-shadow: 0 0 0 1px #000, 0 26px 50px rgba(0, 0, 0, 0.65);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.char-select-header h1 {
  margin: 0;
  font-family: "Cinzel", serif;
  color: #f0d9a8;
  letter-spacing: 0.08em;
}

.char-select-header p {
  margin: 8px 0 0;
  color: #ccb999;
  font-size: 14px;
}

.char-select-layout {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  gap: 14px;
}

.create-card,
.slot-card {
  border: 1px solid #4e3b28;
  background: linear-gradient(180deg, rgba(29, 21, 14, 0.95), rgba(17, 12, 8, 0.92));
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.create-card h2,
.slot-card h2 {
  margin: 0 0 4px;
  font-family: "Cinzel", serif;
  font-size: 16px;
  letter-spacing: 0.06em;
}

.field-label {
  font-size: 12px;
  color: #dcc7a0;
}

.field-input {
  width: 100%;
  border: 1px solid #685235;
  background: rgba(13, 10, 7, 0.95);
  color: #f4e3c0;
  height: 36px;
  padding: 6px 10px;
  font-family: "Noto Serif TC", serif;
}

.field-input:focus {
  outline: 1px solid #caa568;
}

.menu-btn {
  margin-top: 6px;
  border: 1px solid #8a6b42;
  background: linear-gradient(180deg, #3c2a1a 0%, #24180f 100%);
  color: #efdcb4;
  height: 36px;
  font-family: "Cinzel", serif;
  cursor: pointer;
}

.menu-btn:hover {
  border-color: #c79c5f;
  box-shadow: inset 0 0 10px rgba(233, 184, 108, 0.22);
}

.char-select-status {
  min-height: 20px;
  margin: 2px 0 0;
  color: #d8c093;
  font-size: 12px;
}

.slot-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slot-item {
  border: 1px solid #5b472f;
  background: rgba(20, 15, 10, 0.92);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slot-item.empty {
  border-style: dashed;
  color: #968261;
}

.slot-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.slot-name {
  font-weight: 600;
  color: #f0dcac;
}

.slot-meta {
  color: #bca885;
  font-size: 12px;
}

.slot-actions {
  display: flex;
  gap: 8px;
}

.slot-btn {
  flex: 1;
  border: 1px solid #695335;
  background: #1e1610;
  color: #e5d8b9;
  height: 30px;
  cursor: pointer;
  font-family: "Cinzel", serif;
  font-size: 12px;
}

.slot-btn:hover {
  border-color: #d3a864;
}

.slot-btn.delete {
  border-color: #6f2f2f;
  color: #efc1c1;
}

#in-game-toolbar {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 70;
  display: none;
  align-items: center;
  gap: 10px;
}

#active-character {
  border: 1px solid #5a482f;
  background: rgba(18, 13, 9, 0.9);
  color: #efd8ac;
  font-size: 12px;
  padding: 7px 10px;
  max-width: min(52vw, 300px);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.save-exit-btn {
  border: 1px solid #7a6040;
  background: #23180f;
  color: #f0e0bd;
  height: 34px;
  min-width: 112px;
  font-family: "Cinzel", serif;
  cursor: pointer;
}

.save-exit-btn:hover {
  border-color: #d2a560;
}

#game-root.menu-mode #char-select-screen {
  display: flex;
}

#game-root.menu-mode #gameCanvas,
#game-root.menu-mode #notification,
#game-root.menu-mode #char-panel,
#game-root.menu-mode #inv-panel,
#game-root.menu-mode #skill-panel,
#game-root.menu-mode #quest-panel,
#game-root.menu-mode #enemy-status-panel,
#game-root.menu-mode #item-tooltip,
#game-root.menu-mode #bottom-ui,
#game-root.menu-mode #in-game-toolbar {
  display: none !important;
}

#game-root:not(.menu-mode) #in-game-toolbar {
  display: flex;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  cursor: crosshair;
}

.panel {
  position: absolute;
  z-index: 30;
  background: var(--panel-bg);
  border: 1px solid var(--ui-border);
  box-shadow: 0 0 0 1px #000, 0 8px 22px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(1px);
  display: none;
  flex-direction: column;
  padding: 10px;
  gap: 8px;
}

.panel-title {
  margin: 0;
  font-family: "Cinzel", serif;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #f0d9a8;
  font-size: 16px;
  text-shadow: 0 1px 0 #000;
}

.left-panel {
  top: 14px;
  left: 14px;
  width: 240px;
  max-height: calc(100vh - 190px);
}

.right-panel {
  top: 14px;
  right: 14px;
  width: 290px;
  max-height: calc(100vh - 190px);
}

.mid-panel {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  max-height: calc(100vh - 190px);
}

.quest-panel {
  display: flex;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  text-align: center;
  background: rgba(15, 11, 8, 0.75);
  pointer-events: none;
}

.enemy-status-panel {
  top: 14px;
  left: calc(50% + 176px);
  width: 260px;
  min-height: 108px;
  display: none;
  pointer-events: none;
  background: rgba(15, 11, 8, 0.8);
}

#enemy-name {
  color: #f0d9a8;
  font-family: "Cinzel", serif;
  font-size: 16px;
}

#enemy-hp {
  color: #ff9d9d;
  font-size: 14px;
}

#enemy-effects {
  color: #bcd8ff;
  font-size: 12px;
  line-height: 1.35;
}

#control-text {
  font-size: 11px;
  color: #cbb890;
}

.stat-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: auto;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.divider {
  border-top: 1px solid #3a3022;
  margin: 3px 0;
}

.equip-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.inventory-gold {
  font-family: "Cinzel", serif;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #f0d27f;
  text-shadow: 0 1px 0 #000;
}

.equip-slot {
  border: 1px dashed #5f543e;
  background: #14100c;
  color: #d7caab;
  height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
}

.equip-slot div {
  margin-top: 3px;
  font-size: 21px;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  overflow: auto;
  padding-right: 2px;
}

.inv-item {
  aspect-ratio: 1;
  border: 1px solid #4a3c28;
  background: #13100c;
  color: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 22px;
}

.inv-empty {
  background: rgba(16, 12, 8, 0.45);
  border-style: dashed;
  border-color: #3a2f21;
  cursor: default;
}

.inv-item:hover {
  border-color: var(--ui-gold);
  box-shadow: inset 0 0 8px rgba(250, 208, 120, 0.22);
}

.quality-magic {
  box-shadow: inset 0 0 0 1px #4e73ff;
}

.quality-rare {
  box-shadow: inset 0 0 0 1px #f0d561;
}

.skill-tree {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
}

.skill-node {
  border: 1px solid #4b3f2d;
  background: rgba(20, 16, 10, 0.95);
  padding: 7px;
  font-size: 12px;
  display: grid;
  gap: 5px;
}

.skill-node button {
  background: #2b2419;
  color: #ecd6a0;
  border: 1px solid #6e5b39;
  cursor: pointer;
  padding: 4px 6px;
}

#bottom-ui {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 156px;
  z-index: 25;
  display: grid;
  grid-template-columns: 180px 1fr 180px;
  align-items: center;
  background: linear-gradient(0deg, rgba(6, 4, 3, 0.98), rgba(19, 13, 9, 0.92));
  border-top: 2px solid #22180f;
  pointer-events: auto;
}

.exp-bar-wrap {
  position: absolute;
  left: 122px;
  right: 122px;
  bottom: 6px;
  height: 16px;
  border: 1px solid rgba(94, 75, 28, 0.95);
  background: linear-gradient(180deg, rgba(28, 22, 10, 0.95), rgba(16, 12, 6, 0.95));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.75);
  overflow: hidden;
  pointer-events: none;
}

.exp-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #b5881b 0%, #d8b642 52%, #f3de87 100%);
  box-shadow: inset 0 0 8px rgba(255, 232, 146, 0.34);
  transition: width 0.16s linear;
}

.exp-bar-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #f7e9b5;
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-shadow: 0 1px 2px #000;
}

.orb-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.gargoyle {
  font-size: 20px;
  color: #8a7a5a;
}

.orb {
  position: relative;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: 2px solid #2d2418;
  overflow: hidden;
  background: #070606;
}

.orb-fluid {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50%;
  transition: height 0.18s linear;
}

.orb-red .orb-fluid {
  background: radial-gradient(circle at 50% 0%, #ff7d7d 0%, #bf1616 58%, #540303 100%);
}

.orb-blue .orb-fluid {
  background: radial-gradient(circle at 50% 0%, #83a6ff 0%, #2744aa 56%, #0b194f 100%);
}

.orb-glare {
  position: absolute;
  left: 13%;
  top: 10%;
  width: 54%;
  height: 28%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.65), transparent 80%);
}

.orb-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: "Cinzel", serif;
  text-shadow: 0 1px 2px #000;
}

.center-console {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.console-row {
  display: flex;
  gap: 8px;
}

.ui-btn,
.hotkey-slot {
  border: 1px solid #6d5c3c;
  background: #1e1811;
  color: #e5d8b9;
  min-width: 84px;
  height: 34px;
  font-family: "Cinzel", serif;
  cursor: pointer;
}

.hotkey-slot {
  min-width: 58px;
  height: 50px;
  font-size: 24px;
  position: relative;
}

.hotkey-slot span {
  position: absolute;
  right: 4px;
  bottom: 3px;
  font-size: 12px;
  color: #d3b778;
}

.hotkey-cd-overlay {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  pointer-events: none;
  display: none;
  --cd-progress: 0;
  background: conic-gradient(
    rgba(112, 166, 255, 0.58) calc(var(--cd-progress) * 1turn),
    rgba(112, 166, 255, 0.08) 0turn
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
}

.tooltip {
  position: fixed;
  z-index: 90;
  max-width: 260px;
  background: rgba(0, 0, 0, 0.95);
  border: 1px solid #826f42;
  padding: 8px;
  display: none;
  pointer-events: none;
}

.tt-name {
  font-weight: 600;
  color: #f5dfa9;
}

.tt-desc {
  margin-top: 4px;
  font-size: 12px;
}

.inventory-action-menu {
  position: fixed;
  z-index: 95;
  display: none;
  min-width: 118px;
  padding: 4px;
  border: 1px solid #6c5538;
  background: rgba(12, 9, 6, 0.96);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
  gap: 4px;
  flex-direction: column;
}

.inventory-action-menu.open {
  display: flex;
}

.inventory-action-btn {
  border: 1px solid #6c5538;
  background: #21180f;
  color: #e9dab8;
  height: 30px;
  font-family: "Noto Serif TC", serif;
  font-size: 13px;
  cursor: pointer;
}

.inventory-action-btn:hover {
  border-color: #d2a560;
}

.inventory-action-btn.cancel {
  border-style: dashed;
  color: #c7b58f;
}

.notification {
  position: absolute;
  z-index: 50;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  color: #ffb43b;
  font-family: "Cinzel", serif;
  letter-spacing: 0.08em;
  font-size: 28px;
  opacity: 0;
  transition: opacity 0.3s, top 0.3s;
  text-shadow: 0 2px 0 #000;
  pointer-events: none;
}

@media (max-width: 960px) {
  #char-select-screen {
    padding: 14px;
  }

  .char-select-shell {
    padding: 14px;
  }

  .char-select-layout {
    grid-template-columns: 1fr;
  }

  #in-game-toolbar {
    top: 8px;
    left: 8px;
    right: 8px;
    justify-content: space-between;
    gap: 8px;
  }

  #active-character {
    max-width: calc(100vw - 146px);
    padding: 6px 8px;
  }

  .save-exit-btn {
    min-width: 118px;
    height: 32px;
  }

  .left-panel,
  .right-panel,
  .mid-panel {
    width: 44vw;
  }

  .enemy-status-panel {
    left: 50%;
    transform: translateX(-50%);
    top: 104px;
    width: min(82vw, 320px);
  }

  #bottom-ui {
    grid-template-columns: 128px 1fr 128px;
    height: 145px;
  }

  .exp-bar-wrap {
    left: 90px;
    right: 90px;
    height: 14px;
  }

  .orb {
    width: 82px;
    height: 82px;
  }

  .hotkey-slot {
    min-width: 52px;
  }
}

@media (max-width: 640px) {
  .slot-actions {
    flex-direction: column;
  }

  .slot-btn {
    width: 100%;
  }

  .char-select-header p {
    font-size: 13px;
  }

  #bottom-ui {
    grid-template-columns: 100px 1fr 100px;
    height: 138px;
  }

  .exp-bar-wrap {
    left: 64px;
    right: 64px;
    height: 13px;
    bottom: 5px;
  }

  .exp-bar-text {
    font-size: 10px;
  }

  .orb {
    width: 72px;
    height: 72px;
  }

  .hotkey-slot {
    min-width: 48px;
    height: 46px;
    font-size: 20px;
  }

  .enemy-status-panel {
    top: 96px;
    width: min(88vw, 320px);
  }
}
