:root {
  /* Dark Stone + Warm Wood theme */
  --bg: #071018;        /* page background deep navy-black */
  --fg: #efeae2;        /* warm off-white for text */
  --accent: #b86b2a;    /* warm wood accent */
  --danger: #f44336;    /* red for danger */
  --hp: #22c55e;
  --mp: #3b82f6;
  --xp: #f59e0b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 20% 20%, #1e293b 0, #0f172a 45%);
  color: var(--fg);
  font-family: "Segoe UI", sans-serif;
  overflow: hidden;
}
#game-wrapper {
  position: relative;
  text-align: center;
}
canvas {
  background: transparent;
  border: 3px solid #1f2a33; /* darker stone frame */
  border-radius: 8px;
  box-shadow: 0 26px 80px rgba(3,8,14,0.8), inset 0 6px 22px rgba(255,255,255,0.02);
}
canvas:focus { outline: none; }
  /* RPG HUD */
  #hud {
    position: absolute;
    top: 15px;
    left: 15px;
    padding: 15px;
    background: rgba(0,0,0,0.75);
    border-radius: 10px;
    border: 2px solid #2d3748;
    font-size: 14px;
    min-width: 250px;
    backdrop-filter: blur(5px);
  }
  
  .hud-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  
  .hud-text {
    font-weight: 700;
    color: #fbbf24;
    font-size: 16px;
    text-align: center;
  }
  
  .bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  .bar-label {
    font-weight: 700;
    font-size: 12px;
    width: 25px;
    color: #cbd5e1;
  }
  
  .bar {
    flex: 1;
    height: 20px;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #1e293b;
  }
  
  .bar-fill {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 10px;
  }
  
  .hp-fill { background: linear-gradient(90deg, #22c55e, #10b981); }
  .mp-fill { background: linear-gradient(90deg, #3b82f6, #2563eb); }
  .xp-fill { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
  
  /* Skill Bar */
  .skill-bar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    padding: 10px;
    background: rgba(0,0,0,0.75);
    border-radius: 10px;
    border: 2px solid #2d3748;
    backdrop-filter: blur(5px);
  }
  
  .skill-slot {
    width: 50px;
    height: 50px;
    background: rgba(30,41,59,0.8);
    border: 2px solid #475569;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
  }
  
  .skill-slot:hover {
    border-color: #38bdf8;
    background: rgba(56,189,248,0.2);
    transform: translateY(-2px);
  }
  
  .controls-hint {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 10px 15px;
    background: rgba(0,0,0,0.75);
    border-radius: 8px;
    border: 1px solid #2d3748;
    font-size: 11px;
    color: #94a3b8;
    max-width: 350px;
    backdrop-filter: blur(5px);
  }
#overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15,17,26,0.78);
  backdrop-filter: blur(4px);
  border-radius: 10px;
}
#overlay.active { display: flex; }
#panel {
  padding: 22px 26px;
  background: #0b1220;
  border: 1px solid #1f2a44;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  min-width: 280px;
}
#panel h1 { margin: 0 0 10px; font-size: 22px; color: var(--accent); }
#panel p { margin: 6px 0; }
#panel button {
  margin-top: 14px;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #0b1220;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
#panel button:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,0.35); }
#panel button:active { transform: translateY(0); }
#controls {
  margin-top: 8px;
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.4;
}

/* small responsive tweak */
@media (max-width: 480px) {
  canvas { width: 100%; height: auto; }
}

/* Dev-panel styles (visible only when enabled in config) */
#dev-panel {
  position: fixed;
  right: 18px;
  top: 18px;
  width: 320px;
  max-width: calc(100vw - 40px);
  background: rgba(12,12,12,0.9);
  color: #e6f9e6;
  border: 1px solid rgba(255,255,255,0.06);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 1200;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}
#dev-panel h3 { margin: 3px 0 8px; font-size: 15px; color: #bfffbf; }
#dev-panel label { display: block; margin: 6px 0 4px; font-weight: 600; color: #dfe; }
#dev-panel input[type="number"] { width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.06); background: rgba(255,255,255,0.02); color: inherit; }
#dev-panel .row { display: flex; gap: 8px; }
#dev-panel .row input[type="number"] { width: 50%; }
#dev-panel .hint { font-size: 11px; color: rgba(255,255,255,0.6); margin-top: 6px; }
#dev-panel .btn { margin-top: 8px; display:block; width:100%; padding:6px; border-radius: 6px; border: none; background: #2b7a2b; color: #0b1220; font-weight: 700; cursor: pointer; }

/* START overlay (enemies don't move until START pressed) */
.start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  background: rgba(8,12,20,0.85);
  backdrop-filter: blur(3px);
  border-radius: 10px;
  pointer-events: auto;
}
.start-overlay[aria-hidden="true"] { display: none; }
.start-panel {
  padding: 24px 32px;
  border-radius: 10px;
  background: rgba(11,18,32,0.95);
  border: 1px solid rgba(56,189,248,0.3);
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  text-align: center;
}
.start-panel .btn {
  display: inline-block;
  padding: 12px 28px;
  background: var(--accent);
  color: #0b1220;
  border-radius: 8px;
  font-weight: 700;
  font-size: 16px;
  border: none;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.start-panel .btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(56,189,248,0.4); }
.start-panel .btn:active { transform: translateY(0); }

/* Secondary button style */
.secondary-btn {
  margin-top: 10px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  transition: all 120ms ease;
}
.secondary-btn:hover { 
  background: rgba(56,189,248,0.1); 
  transform: translateY(-1px); 
}
.secondary-btn:active { transform: translateY(0); }

/* Danger button style */
.danger-btn {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: transparent;
  color: var(--danger);
  font-weight: 600;
  cursor: pointer;
  transition: all 120ms ease;
  font-size: 13px;
}
.danger-btn:hover { 
  background: rgba(244,63,94,0.1); 
  transform: translateY(-1px); 
}
.danger-btn:active { transform: translateY(0); }

/* Name input overlay */
.overlay-hidden { display: none !important; }
#name-overlay, #scoreboard-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15,17,26,0.85);
  backdrop-filter: blur(4px);
  border-radius: 10px;
  z-index: 2000;
}
#name-panel, #scoreboard-panel {
  padding: 22px 26px;
  background: #0b1220;
  border: 1px solid #1f2a44;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  min-width: 320px;
  max-width: 90vw;
}
#name-panel h2, #scoreboard-panel h2 { 
  margin: 0 0 12px; 
  font-size: 22px; 
  color: var(--accent); 
  text-align: center;
}
#name-panel p { margin: 6px 0; }
#name-panel label { 
  display: block; 
  margin: 12px 0 6px; 
  font-weight: 600; 
  color: #cbd5e1; 
}
#name-panel input[type="text"] {
  width: 100%;
  padding: 10px;
  border: 1px solid #1f2a44;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  color: var(--fg);
  font-size: 16px;
  margin-bottom: 10px;
}
#name-panel input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255,255,255,0.08);
}

/* Scoreboard list */
#scoreboard-list {
  max-height: 400px;
  overflow-y: auto;
  margin: 12px 0;
}
.score-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  margin: 6px 0;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}
.score-entry.highlight {
  background: rgba(56,189,248,0.15);
  border-left-color: #ffd700;
}
.score-entry .rank {
  font-weight: 700;
  color: #ffd36b;
  margin-right: 12px;
  min-width: 30px;
}
.score-entry .name {
  flex: 1;
  color: var(--fg);
  font-weight: 600;
}
.score-entry .details {
  text-align: right;
  font-size: 13px;
  color: #94a3b8;
}
.score-entry .score {
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
}
.empty-scoreboard {
  text-align: center;
  padding: 40px 20px;
  color: #64748b;
  font-style: italic;
}

/* RPG UI Panels */
.ui-panel {
  position: absolute;
  top: 100px;
  right: 20px;
  width: 350px;
  max-height: calc(100vh - 140px);
  background: rgba(15,23,42,0.95);
  border: 2px solid #2d3748;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  z-index: 1000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ui-panel.hidden {
  display: none;
}

.panel-header {
  padding: 15px 20px;
  background: rgba(30,41,59,0.9);
  border-bottom: 1px solid #475569;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h3 {
  margin: 0;
  font-size: 18px;
  color: #38bdf8;
  font-weight: 700;
}

.close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.close-btn:hover {
  background: rgba(148,163,184,0.2);
  color: #fff;
}

/* Inventory Grid */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 15px;
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}

.inventory-slot {
  aspect-ratio: 1;
  background: rgba(30,41,59,0.6);
  border: 2px solid #475569;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.inventory-slot:hover {
  background: rgba(56,189,248,0.2);
  border-color: #38bdf8;
  transform: scale(1.05);
}

.inventory-slot:empty {
  background: rgba(30,41,59,0.3);
}

/* Inventory Info */
.inventory-info {
  padding: 12px 15px;
  border-top: 1px solid #334155;
  background: rgba(2,6,23,0.6);
  max-height: 350px;
  overflow-y: auto;
}

.info-card {
  border: 2px solid #475569;
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(15,23,42,0.85);
}
.info-card .title {
  font-weight: 700;
  font-size: 14px;
}
.info-card .sub {
  color: #94a3b8;
  font-size: 12px;
  margin-bottom: 6px;
}
.info-card .section {
  margin-top: 8px;
  font-size: 12px;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.item-line, .delta-line {
  display: flex;
  justify-content: space-between;
  padding: 6px 8px;
  margin-top: 6px;
  background: rgba(30,41,59,0.5);
  border-radius: 6px;
  font-size: 13px;
}
.item-line .k { color: #94a3b8; }
.item-line .v { color: #e2e8f0; }
.delta-header { margin-top: 8px; font-size: 12px; color: #a3a3a3; }
.delta-line.pos { border-left: 3px solid #22c55e; color: #c7f9cc; }
.delta-line.neg { border-left: 3px solid #f43f5e; color: #fecaca; }
.item-line.muted, .delta-header.muted { color: #6b7280; }
.empty-info { color: #64748b; font-style: italic; padding: 8px; }
.verdict { margin: 6px 0; font-weight: 700; font-size: 12px; }
.verdict.better { color: #22c55e; }
.verdict.worse { color: #f43f5e; }
.verdict.equal { color: #eab308; }

/* Upgrade highlight */
.inventory-slot.upgrade {
  border-color: #22c55e !important;
  box-shadow: 0 0 0 2px rgba(34,197,94,0.25) inset, 0 0 10px rgba(34,197,94,0.15);
}

/* Character Sheet */
.character-content {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}

.character-content h3 {
  margin: 0 0 15px 0;
  color: #fbbf24;
  font-size: 16px;
  text-align: center;
}

.stat-line {
  padding: 10px;
  margin: 5px 0;
  background: rgba(30,41,59,0.5);
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  border-left: 3px solid #38bdf8;
}

/* Skill Tree */
.skill-content {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}

.skill-content h3 {
  margin: 0 0 15px 0;
  color: #a855f7;
  font-size: 16px;
  text-align: center;
}

.skill-item {
  padding: 12px;
  margin: 8px 0;
  background: rgba(30,41,59,0.6);
  border: 2px solid #475569;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
}

.skill-item:hover {
  background: rgba(168,85,247,0.2);
  border-color: #a855f7;
  transform: translateX(5px);
}
