/* ============================================================
   DARK DUNGEON - Fantasy Roguelike Incremental Game
   Style Sheet
   ============================================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0d1a;
  --bg2:       #131325;
  --bg3:       #1a1a30;
  --panel:     #16162a;
  --border:    #2e2e55;
  --border2:   #3d3d6e;
  --gold:      #c9a227;
  --gold2:     #f0c040;
  --red:       #e74c3c;
  --red2:      #ff6b6b;
  --blue:      #3498db;
  --blue2:     #74c0fc;
  --green:     #2ecc71;
  --purple:    #9b59b6;
  --purple2:   #c39bd3;
  --gray:      #888;
  --text:      #ddd;
  --text2:     #aaa;
  --text3:     #777;

  --common:    #aaa;
  --uncommon:  #4ade80;
  --rare:      #60a5fa;
  --epic:      #c084fc;
  --legendary: #facc15;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', 'Yu Gothic', 'Meiryo', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

#app { width: 100vw; height: 100vh; position: relative; overflow: hidden; }

/* ---- Screens ---- */
.screen { display: none; width: 100%; height: 100%; position: absolute; top: 0; left: 0; }
.screen.active { display: flex; flex-direction: column; }

/* ============================================================
   MENU SCREEN
   ============================================================ */
#menu-screen {
  background: radial-gradient(ellipse at center, #1a0a2e 0%, #0d0d1a 70%);
  justify-content: center; align-items: center;
}

.menu-bg {
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h60v60H0z' fill='none'/%3E%3Ccircle cx='30' cy='30' r='1' fill='%23ffffff08'/%3E%3C/svg%3E");
  opacity: 0.5;
}

.menu-content {
  position: relative; z-index: 1;
  text-align: center;
  max-width: 900px; width: 100%; padding: 20px;
}

.game-title {
  font-size: 3rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold2) 50%, var(--gold) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}

.game-subtitle {
  color: var(--text2); font-size: 1.1rem; margin-bottom: 20px;
  letter-spacing: 0.2em;
}

.section-title {
  color: var(--gold); font-size: 1.1rem; margin-bottom: 16px;
  letter-spacing: 0.1em;
}

#prestige-info {
  margin-bottom: 16px;
  display: flex; gap: 12px; justify-content: center; align-items: center;
}

.rune-badge {
  background: rgba(155,89,182,0.2);
  border: 1px solid var(--purple);
  border-radius: 20px; padding: 6px 16px;
  color: var(--purple2); font-size: 0.95rem;
}

.btn-prestige-shop {
  background: linear-gradient(135deg, #4a1b6e, #6b2fa0);
  border: 1px solid var(--purple);
  border-radius: 8px; padding: 6px 16px;
  color: #fff; cursor: pointer; font-size: 0.9rem;
  transition: all 0.2s;
}
.btn-prestige-shop:hover { background: linear-gradient(135deg, #5d2290, #8040c0); }

/* Class Cards */
.class-cards {
  display: flex; gap: 20px; justify-content: center; flex-wrap: wrap;
}

.class-card {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 12px; padding: 24px 20px;
  width: 240px; cursor: pointer;
  transition: all 0.25s; position: relative;
  overflow: hidden;
}

.class-card::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at top, rgba(255,255,255,0.03), transparent 70%);
}

.class-card:hover {
  border-color: var(--gold);
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(201,162,39,0.25);
}

.class-card[data-class="warrior"]:hover { border-color: var(--red2); box-shadow: 0 8px 30px rgba(231,76,60,0.3); }
.class-card[data-class="mage"]:hover    { border-color: var(--purple2); box-shadow: 0 8px 30px rgba(155,89,182,0.3); }
.class-card[data-class="rogue"]:hover  { border-color: var(--green); box-shadow: 0 8px 30px rgba(46,204,113,0.3); }

.class-icon { font-size: 2.5rem; margin-bottom: 10px; }

.class-card h3 {
  font-size: 1.2rem; color: var(--gold); margin-bottom: 8px;
}

.class-desc {
  color: var(--text2); font-size: 0.85rem; margin-bottom: 16px;
  line-height: 1.5;
}

.class-bars {
  display: grid; grid-template-columns: 35px 1fr;
  gap: 5px 8px; align-items: center;
}

.bar-label { color: var(--text3); font-size: 0.75rem; text-align: right; }
.bar-track {
  background: var(--bg); border-radius: 4px; height: 8px; overflow: hidden;
}
.bar-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--gold), var(--gold2));
}

/* ============================================================
   GAME SCREEN
   ============================================================ */
#game-screen {
  flex-direction: column;
  background: var(--bg);
}

/* ---- Header ---- */
#game-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex; gap: 20px; align-items: center;
  flex-shrink: 0; z-index: 10;
}

.header-hero {
  display: flex; gap: 8px; align-items: center; min-width: 200px;
}

.level-badge {
  background: var(--gold);
  color: #000; font-size: 0.75rem; font-weight: 700;
  padding: 2px 8px; border-radius: 12px;
}

.header-bars {
  display: flex; gap: 12px; flex: 1; align-items: center;
}

.hbar {
  display: flex; gap: 6px; align-items: center; flex: 1;
}

.hbar-label {
  color: var(--text3); font-size: 0.75rem; min-width: 28px;
}

.hbar-track {
  flex: 1; height: 10px; background: var(--bg3);
  border-radius: 5px; overflow: hidden;
  border: 1px solid var(--border);
}
.hbar-track.full-width { width: 100%; flex: unset; }

.hbar-fill {
  height: 100%; border-radius: 5px;
  transition: width 0.3s ease;
}

.hp-color  { background: linear-gradient(90deg, #c0392b, var(--red2)); }
.mp-color  { background: linear-gradient(90deg, #1a5276, var(--blue2)); }
.exp-color { background: linear-gradient(90deg, #1e8449, var(--green)); }
.enemy-color { background: linear-gradient(90deg, #922b21, var(--red)); }

.hbar-text { color: var(--text2); font-size: 0.75rem; min-width: 72px; }

.header-info {
  display: flex; gap: 16px; color: var(--text2);
  font-size: 0.85rem; min-width: 200px; justify-content: flex-end;
}

.header-info span { display: flex; gap: 4px; align-items: center; }

/* ---- Main Layout ---- */
#game-main {
  display: grid;
  grid-template-columns: 230px 1fr 230px;
  gap: 8px; padding: 8px;
  flex: 1; overflow: hidden;
}

/* ---- Panels ---- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 8px;
  overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
}

.panel-section { display: flex; flex-direction: column; gap: 6px; }

.panel-title {
  font-size: 0.8rem; font-weight: 700;
  color: var(--gold); letter-spacing: 0.05em;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* ---- Stats ---- */
#stats-grid { display: flex; flex-direction: column; gap: 3px; }

.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 2px 4px;
}

.stat-name { color: var(--text2); font-size: 0.8rem; }
.stat-val  { color: var(--text); font-weight: 600; font-size: 0.85rem; }

/* ---- Equipment ---- */
#equip-list { display: flex; flex-direction: column; gap: 4px; }

.equip-slot {
  display: flex; gap: 6px; align-items: center;
  padding: 4px 6px; border-radius: 4px;
  background: var(--bg3); border: 1px solid var(--border);
}

.slot-label {
  color: var(--text3); font-size: 0.75rem; min-width: 28px;
}

.slot-item { font-size: 0.8rem; color: var(--text); flex: 1; }

/* ---- Inventory ---- */
#inventory-list { display: flex; flex-direction: column; gap: 4px; }

.inv-item {
  display: flex; gap: 6px; align-items: center;
  padding: 4px 6px; border-radius: 4px;
  background: var(--bg3); border: 1px solid var(--border);
  cursor: pointer; transition: border-color 0.2s;
}

.inv-item:hover { border-color: var(--gold); }

.inv-item .item-name { flex: 1; font-size: 0.8rem; }
.inv-item .item-qty  { color: var(--text3); font-size: 0.75rem; }
.inv-item .use-btn {
  font-size: 0.7rem; padding: 2px 6px;
  background: var(--bg2); border: 1px solid var(--border2);
  color: var(--text); border-radius: 3px; cursor: pointer;
}
.inv-item .use-btn:hover { background: var(--border2); }

/* ---- Center Panel ---- */
#center-panel {
  display: flex; flex-direction: column; gap: 6px;
}

/* Dungeon Map */
#dungeon-map {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px;
  background: var(--bg3); border-radius: 6px;
  border: 1px solid var(--border);
}

#room-dots {
  display: flex; gap: 5px; align-items: center;
}

.room-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg2); border: 2px solid var(--border2);
  transition: all 0.3s;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem;
}

.room-dot.done   { background: var(--border2); border-color: var(--gray); }
.room-dot.current { background: var(--gold); border-color: var(--gold2); box-shadow: 0 0 8px var(--gold); }
.room-dot.boss   { background: var(--red); border-color: var(--red2); }
.room-dot.shop   { background: #16a085; border-color: #1abc9c; }

#floor-label { color: var(--gold); font-size: 0.85rem; font-weight: 700; }

/* Battle Arena */
#battle-arena {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg3); border-radius: 8px;
  border: 1px solid var(--border);
  position: relative; min-height: 200px;
  overflow: hidden;
}

#battle-arena::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.02), transparent 70%);
  pointer-events: none;
}

#enemy-area {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px; width: 100%;
}

#enemy-icon-display { font-size: 4rem; animation: float 3s ease-in-out infinite; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

#enemy-name-display {
  font-size: 1.1rem; font-weight: 700; color: var(--red2);
}

#enemy-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

.badge {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 10px;
  font-weight: 600;
}
.badge-boss   { background: rgba(231,76,60,0.3); color: var(--red2); border: 1px solid var(--red); }
.badge-poison { background: rgba(46,204,113,0.2); color: #6ef27a; border: 1px solid #2ecc71; }
.badge-slow   { background: rgba(52,152,219,0.2); color: var(--blue2); border: 1px solid var(--blue); }

.enemy-hp-wrap {
  width: 80%; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
#enemy-hp-text { font-size: 0.75rem; color: var(--text2); }

/* FX Layer */
#fx-layer {
  position: absolute; inset: 0; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}

#dmg-popup {
  font-size: 2rem; font-weight: 900; opacity: 0;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  transition: none;
  position: absolute;
}

#dmg-popup.show-dmg {
  animation: dmgFloat 0.8s ease-out forwards;
}

@keyframes dmgFloat {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  30%  { opacity: 1; transform: translateY(-20px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-50px) scale(0.8); }
}

#status-fx {
  position: absolute; bottom: 8px;
  display: flex; gap: 8px;
}

/* Event Panel */
#event-panel {
  width: 100%; padding: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}

.event-title { font-size: 1.3rem; font-weight: 700; color: var(--gold); }
.event-desc  { color: var(--text2); font-size: 0.9rem; text-align: center; }

.event-options {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
}

/* Battle Log */
#battle-log {
  height: 120px;
  background: var(--bg2); border-radius: 6px;
  border: 1px solid var(--border);
  overflow-y: auto; padding: 6px 8px;
}

#log-inner { display: flex; flex-direction: column; gap: 2px; }

.log-entry {
  font-size: 0.8rem; color: var(--text2); line-height: 1.4;
  padding: 1px 0; border-bottom: 1px solid rgba(255,255,255,0.03);
}
.log-entry.log-dmg    { color: #ff8a7a; }
.log-entry.log-crit   { color: var(--gold2); font-weight: 700; }
.log-entry.log-heal   { color: #6ef27a; }
.log-entry.log-skill  { color: var(--purple2); }
.log-entry.log-info   { color: var(--blue2); }
.log-entry.log-loot   { color: var(--gold); }
.log-entry.log-event  { color: var(--text); font-style: italic; }

/* Action Bar */
#action-bar {
  display: flex; gap: 8px; flex-wrap: wrap;
}

.btn-action {
  flex: 1; padding: 8px 6px;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); border-radius: 6px;
  cursor: pointer; font-size: 0.85rem; font-weight: 600;
  transition: all 0.2s; min-width: 70px;
}

.btn-action:hover:not(:disabled) {
  background: var(--border2); border-color: var(--gold);
  color: var(--gold);
}

.btn-action:disabled {
  opacity: 0.4; cursor: not-allowed;
}

#btn-attack:hover:not(:disabled) { border-color: var(--red2); color: var(--red2); }
#btn-flee:hover:not(:disabled)   { border-color: var(--blue2); color: var(--blue2); }

.btn-toggle.active {
  background: rgba(46,204,113,0.15);
  border-color: var(--green); color: var(--green);
}

/* ---- Skills ---- */
#skills-list { display: flex; flex-direction: column; gap: 6px; }

.skill-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px;
  transition: all 0.2s;
}

.skill-card.usable { cursor: pointer; }
.skill-card.usable:hover { border-color: var(--purple2); }

.skill-card.on-cd { opacity: 0.5; cursor: not-allowed; }
.skill-card.no-mp { opacity: 0.5; cursor: not-allowed; }

.skill-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 3px;
}

.skill-name { font-size: 0.85rem; font-weight: 700; color: var(--purple2); }
.skill-cost { font-size: 0.75rem; color: var(--blue2); }
.skill-desc { font-size: 0.75rem; color: var(--text2); }
.skill-cd   { font-size: 0.7rem; color: var(--red2); }

.cd-bar {
  height: 3px; background: var(--bg2); border-radius: 2px;
  margin-top: 4px; overflow: hidden;
}
.cd-fill { height: 100%; background: var(--purple); border-radius: 2px; transition: width 0.5s; }

/* ---- Shop ---- */
#shop-items-list { display: flex; flex-direction: column; gap: 6px; }

.shop-item {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px;
  display: flex; gap: 6px; align-items: center;
}

.shop-item .item-icon { font-size: 1.2rem; }
.shop-item .item-info { flex: 1; }
.shop-item .item-name-shop { font-size: 0.8rem; font-weight: 600; }
.shop-item .item-desc-shop { font-size: 0.72rem; color: var(--text2); }
.shop-item .item-price {
  font-size: 0.8rem; color: var(--gold); font-weight: 700;
  white-space: nowrap;
}

.btn-buy {
  padding: 3px 10px; font-size: 0.75rem;
  background: var(--bg2); border: 1px solid var(--border2);
  color: var(--text); border-radius: 4px; cursor: pointer;
  transition: all 0.2s;
}
.btn-buy:hover:not(:disabled) { background: var(--gold); color: #000; border-color: var(--gold); }
.btn-buy:disabled { opacity: 0.4; cursor: not-allowed; }

.hint-text { color: var(--text3); font-size: 0.8rem; font-style: italic; }

.btn-small {
  padding: 4px 12px; font-size: 0.8rem;
  background: var(--bg2); border: 1px solid var(--border2);
  color: var(--text); border-radius: 4px; cursor: pointer;
  transition: all 0.2s; width: 100%;
}
.btn-small:hover { background: var(--border2); }

/* ---- Rarity Colors ---- */
.rarity-common    { color: var(--common); }
.rarity-uncommon  { color: var(--uncommon); }
.rarity-rare      { color: var(--rare); }
.rarity-epic      { color: var(--epic); }
.rarity-legendary { color: var(--legendary); }

/* ============================================================
   DEATH SCREEN
   ============================================================ */
#death-screen {
  background: radial-gradient(ellipse at center, #1a0505 0%, #0d0d1a 70%);
  justify-content: center; align-items: center;
}

.death-content {
  text-align: center; max-width: 500px;
  background: var(--panel); border: 2px solid var(--border);
  border-radius: 16px; padding: 40px;
  display: flex; flex-direction: column; gap: 20px; align-items: center;
}

#death-title { font-size: 2rem; color: var(--red2); }

#death-summary {
  display: flex; flex-direction: column; gap: 8px;
  width: 100%; text-align: left;
}

.summary-row {
  display: flex; justify-content: space-between;
  padding: 4px 8px; border-radius: 4px;
  background: var(--bg3); font-size: 0.9rem;
}
.summary-label { color: var(--text2); }
.summary-val   { color: var(--text); font-weight: 600; }

.rune-reward {
  background: rgba(155,89,182,0.2);
  border: 1px solid var(--purple);
  border-radius: 8px; padding: 12px 24px;
  color: var(--purple2); font-size: 1.1rem; font-weight: 700;
}

.btn-big {
  padding: 12px 32px; font-size: 1rem; font-weight: 700;
  background: linear-gradient(135deg, #1a1a3a, #2a2a5a);
  border: 2px solid var(--gold);
  color: var(--gold); border-radius: 8px; cursor: pointer;
  transition: all 0.2s;
}
.btn-big:hover {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #000;
}

/* ============================================================
   PRESTIGE MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}

.modal-box {
  background: var(--panel); border: 2px solid var(--purple);
  border-radius: 16px; padding: 30px;
  max-width: 600px; width: 90%; max-height: 80vh;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
}

.modal-box h2 { color: var(--purple2); font-size: 1.5rem; text-align: center; }

.modal-rune-info { text-align: center; color: var(--text2); }

#prestige-items-list {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.prestige-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px;
  display: flex; flex-direction: column; gap: 6px;
}

.prestige-card .pc-header {
  display: flex; gap: 8px; align-items: center;
}
.prestige-card .pc-icon { font-size: 1.4rem; }
.prestige-card .pc-name { font-weight: 700; color: var(--text); }
.prestige-card .pc-level { font-size: 0.75rem; color: var(--gold); }
.prestige-card .pc-desc { font-size: 0.8rem; color: var(--text2); }
.prestige-card .pc-cost { font-size: 0.8rem; color: var(--purple2); }

.btn-buy-prestige {
  padding: 5px 12px; font-size: 0.8rem;
  background: rgba(155,89,182,0.2);
  border: 1px solid var(--purple);
  color: var(--purple2); border-radius: 5px;
  cursor: pointer; transition: all 0.2s; align-self: flex-end;
}
.btn-buy-prestige:hover:not(:disabled) {
  background: var(--purple); color: #fff;
}
.btn-buy-prestige:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================================
   ANIMATIONS & EFFECTS
   ============================================================ */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-5px); }
  40%       { transform: translateX(5px); }
  60%       { transform: translateX(-3px); }
  80%       { transform: translateX(3px); }
}

.shake { animation: shake 0.4s ease; }

@keyframes flash-red {
  0%, 100% { box-shadow: none; }
  50%       { box-shadow: 0 0 20px rgba(231,76,60,0.6) inset; }
}

.flash-hit { animation: flash-red 0.4s ease; }

@keyframes glow-gold {
  0%, 100% { box-shadow: none; }
  50%       { box-shadow: 0 0 20px rgba(201,162,39,0.6); }
}

.flash-loot { animation: glow-gold 0.6s ease; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  #game-main {
    grid-template-columns: 180px 1fr 180px;
  }
}

@media (max-width: 700px) {
  #game-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    overflow-y: auto;
  }
  .panel { max-height: 300px; }
  .game-title { font-size: 2rem; }
  .class-cards { flex-direction: column; align-items: center; }
  .class-card { width: 100%; max-width: 340px; }
}
