/* =========================
   VARIABLES / BASE
========================= */
:root{
  --menu-width: 220px;

  --bg: #111;
  --panel: rgba(0,0,0,.35);
  --panel-solid: #1c1c1c;
  --border: rgba(255,255,255,.08);
  --text: #eee;
  --muted: #aaa;

  --gold: #ffd27d;
  --danger: #c0392b;
}

/* Uwaga: tło ustalone raz (wcześniej było zdublowane i w złym miejscu) */
body{
  background-color: var(--bg);
  background-image: url("/assets/img/background.jpg");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;

  color: var(--text);
  font-family: Arial, sans-serif;

  box-sizing: border-box;
  margin-left: var(--menu-width);
  padding: 40px;
}

*, *::before, *::after{ box-sizing: inherit; }

a{ color: inherit; }

/* =========================
   MAIN MENU
========================= */
.main-menu{
  position: fixed;
  top: 0;
  left: 0;
  width: var(--menu-width);
  height: 100vh;

  display: flex;
  flex-direction: column;

  background: #121212;
  padding: 12px 8px;

  box-shadow: 2px 0 8px rgba(0,0,0,0.4);
  z-index: 1000;
}

.menu-item{
  position: relative;
  overflow: hidden;

  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: 6px;

  text-decoration: none;
  color: #ddd;
  background: #1c1c1c;

  transition: background .15s, color .15s, border-color .15s;
}

.menu-item:hover{
  background: #2a2a2a;
  color: #fff;
}

/* aktywna pozycja */
.menu-item.active{
  background: linear-gradient(180deg, rgba(255,210,125,.12), rgba(0,0,0,.10));
  border: 1px solid rgba(255,210,125,.18);
}

.menu-item.active::before{
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #ffd27d, #c0392b);
}

.menu-item.logout{
  margin-top: auto;
  background: #2a1515;
}


/* =========================
   LAYOUT / PANELS
========================= */
.box{
  max-width: 650px;
  margin: 0 auto;
  background: var(--panel-solid);
  padding: 20px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

.log{
  background: #000;
  padding: 10px;
  margin-top: 15px;
  border-radius: 8px;
  font-size: 14px;
  border: 1px solid rgba(255,255,255,.06);
}

.dead{
  color: red;
  font-weight: bold;
  text-align: center;
}

/* =========================
   GLOBAL BUTTONS
   (duże przyciski akcji)
========================= */
button{
  padding: 10px;
  background: #c0392b;
  border: none;
  color: #fff;
  cursor: pointer;
  transition: filter .15s, transform .05s;
}

/* TYLKO przyciski akcji mają być belkami */
button:not(.btn-small):not(.btn-stat){
  width: 100%;
  margin-top: 10px;
}

/* hover/active tylko dla dużych */
button:not(.btn-small):not(.btn-stat):hover{
  filter: brightness(1.07);
}

button:not(.btn-small):not(.btn-stat):active{
  transform: translateY(1px);
}

/* link wylogowania */
a.logout{
  color: #aaa;
  font-size: 12px;
  float: right;
}


/* =========================
   GLOBAL BUTTONS
   (zostają szerokie dla normalnych akcji)
========================= */
button:not(.btn-small):not(.btn-stat) {
    padding: 10px;
    width: 100%;
    margin-top: 10px;
    background: #c0392b;
    border: none;
    color: #fff;
    cursor: pointer;
    transition: filter .15s, transform .05s;
}
button:hover{ filter: brightness(1.07); }
button:active{ transform: translateY(1px); }

a.logout{
  color: #aaa;
  font-size: 12px;
  float: right;
}

/* =========================
   PLAYER HUD
========================= */
.player-header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 15px 0;
}

.player-stats p{
  margin: 4px 0;
  font-size: 14px;
}

.player-avatar-base{
  width: 192px;
  height: 192px;
  border-radius: 10px;

  background: #111;
  border: 2px solid #333;

  display: flex;
  align-items: center;
  justify-content: center;
}

.player-avatar-base img{
  max-width: 90%;
  max-height: 90%;
  image-rendering: pixelated;
}

/* Gdy trwa animacja walki, ukryj górny HUD */
#game-ui.locked .player-hud{ display: none; }

/* =========================
   BARS (HP / EXP / FATIGUE)
========================= */
.hp-bar{
  position: relative;
  width: 100%;
  height: 18px;
  background: #333;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
  border: 1px solid rgba(255,255,255,.08);
}

.hp-fill{
  height: 100%;
  transition: width 0.4s ease;
}

.hp-text{
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 12px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 4px rgba(0,0,0,0.9);
  pointer-events: none;
  z-index: 2;
}

.player-hp{ background: linear-gradient(90deg, #27ae60, #2ecc71); }
.monster-hp{ background: linear-gradient(90deg, #c0392b, #e74c3c); }

/* EXP */
.exp-bar{
  position: relative;
  width: 100%;
  height: 14px;
  background: #333;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;

  display: flex;
  align-items: center;
  justify-content: center;

  border: 1px solid rgba(255,255,255,.08);
}

.exp-fill{
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, #f1c40f, #f39c12);
  transition: width 0.4s ease;
}

.exp-text{
  position: relative;
  z-index: 2;
  font-size: 11px;
  color: #fff;
  font-weight: bold;
  pointer-events: none;
}

/* Fatigue */
.fatigue-bar{
  position: relative;
  width: 100%;
  height: 14px;
  background: #333;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
  border: 1px solid rgba(255,255,255,.08);
}

.fatigue-fill{ height: 100%; transition: width .4s ease; }
.fatigue-low{ background: linear-gradient(90deg, #27ae60, #2ecc71); }
.fatigue-mid{ background: linear-gradient(90deg, #f1c40f, #f39c12); }
.fatigue-high{ background: linear-gradient(90deg, #c0392b, #e74c3c); }

.fatigue-text{
  position: absolute;
  width: 100%;
  text-align: center;
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  top: 0;
  line-height: 14px;
  text-shadow: 0 0 4px rgba(0,0,0,0.8);
  pointer-events: none;
}

.fatigue-warning{
  color: #e67e22;
  font-size: 13px;
  font-weight: bold;
}

/* =========================
   COMBAT / AVATARS / DAMAGE
========================= */
.combat-area{
  position: relative;
  margin-bottom: 15px;
}

.damage-layer{
  position: absolute;
  top: -20px;
  left: 0;
  width: 100%;
  height: 60px;
  pointer-events: none;
}

.damage-number{
  position: absolute;
  font-weight: bold;
  font-size: 28px;
  pointer-events: none;
  animation: floatUp 1s ease-out forwards;
  opacity: 1;
}

.damage-player{ color: #e74c3c; }
.damage-crit{
  color: gold;
  font-size: 38px;
  text-shadow: 0 0 6px #f1c40f;
}

@keyframes floatUp{
  0%{ transform: translate(-50%, 0); opacity: 1; }
  100%{ transform: translate(-50%, -40px); opacity: 0; }
}

.hit{ animation: hitFlash .3s; }
@keyframes hitFlash{
  0%{ filter: brightness(1); }
  50%{ filter: brightness(2); }
  100%{ filter: brightness(1); }
}

.avatar{
  width: 256px;
  height: 256px;
  margin: 0 auto 10px;
}
.avatar img{
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.monster-combat, .player-combat{ text-align: center; }

.avatar.hit img{ animation: avatarHit .3s; }
@keyframes avatarHit{
  0%{ transform: translateX(0); }
  25%{ transform: translateX(-6px); }
  50%{ transform: translateX(6px); }
  75%{ transform: translateX(-4px); }
  100%{ transform: translateX(0); }
}

.avatar.dodge img{ animation: avatarDodge .4s; }
@keyframes avatarDodge{
  0%{ transform: translateX(0); opacity: 1; }
  50%{ transform: translateX(20px); opacity: .5; }
  100%{ transform: translateX(0); opacity: 1; }
}

/* Śmierć potwora */
.monster-dead{ animation: monsterDeath .8s ease forwards; }
@keyframes monsterDeath{
  0%{ opacity: 1; transform: translateY(0) scale(1); }
  100%{ opacity: 0; transform: translateY(20px) scale(.9); }
}

.monster-dead .avatar{ animation: avatarDeath .8s forwards; }
@keyframes avatarDeath{
  to{ opacity: 0; transform: translateY(20px) scale(.9); }
}

/* Layout walki */
.battle-layout{
  display: flex;
  justify-content: space-between;
  gap: 40px;
  margin: 20px 0;
}
.battle-layout .side{ width: 50%; }
.battle-layout .left{ text-align: left; }
.battle-layout .right{ text-align: right; }
.battle-layout .combat-area{ text-align: center; }
.left .avatar{ margin-left: auto; }
.right .avatar{ margin-right: auto; }

/* Boss / Elite */
.monster-avatar.boss{ width: 256px; height: 256px; }
.monster-avatar.boss img{ transform: scale(1.1); }

.monster-avatar.elite{
  box-shadow: 0 0 12px rgba(0, 200, 255, 0.8);
  border-radius: 50%;
}
.monster-avatar.elite img{ transform: scale(1.1); }

/* =========================
   RANKING / MAP LOCK
========================= */
.ranking{ margin-top: 20px; }
.ranking h3{ margin-top: 15px; color: #f1c40f; }
.ranking ol{ padding-left: 20px; }
.ranking li{ margin-bottom: 6px; font-size: 14px; }

.map-locked{
  opacity: .5;
  padding: 8px;
  margin: 5px 0;
  border: 1px dashed #555;
  text-align: center;
}
.map-hint{ font-size: 12px; color: #aaa; }

/* =========================
   SHOP / LOOT
========================= */
.shop-list{
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.shop-item{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;

  border: 1px solid #333;
  border-radius: 10px;
  background: rgba(0,0,0,0.25);
}
.shop-item button{
  padding: 8px 14px;
  width: auto;
  margin-top: 0;
  border-radius: 10px;
}

.loot-log{
  margin-top: 10px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #333;
  background: #111;
}
.loot-log.rarity-common{ border-color:#555; }
.loot-log.rarity-rare{ border-color:#2e86de; }
.loot-log.rarity-epic{ border-color:#9b59b6; }

/* =========================
   INVENTORY MODAL
========================= */
#inventory-ui{ display: none; }

.inv-open{
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 12px;
}
.modal-overlay.is-open{ display: flex; }

.modal{
  width: min(980px, 100%);
  max-height: 90vh;
  overflow: hidden;

  background: #151515;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.45);
}

.modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.modal-close{
  cursor:pointer;
  padding: 6px 10px;
  border-radius: 10px;
}

.modal-body{
  padding: 12px;
  overflow: auto;
  max-height: calc(90vh - 54px);
}

.inv-layout{
  display:grid;
  grid-template-columns: 320px 1fr;
  gap: 12px;
}

.inv-panel{
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 12px;
}

.char-slots{
  display:flex;
  flex-direction:column;
  gap: 10px;
  margin-top: 10px;
}

.char-slot{
  padding: 10px;
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
}

.char-slot-name{
  font-size: 12px;
  color: #aaa;
  margin-bottom: 6px;
}

.char-slot-empty{
  color: #777;
  font-size: 13px;
}

.inv-list{
  list-style:none;
  padding: 0;
  margin: 10px 0 0 0;
  display:flex;
  flex-direction:column;
  gap: 8px;
}

.inv-row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.06);
}

.inv-row-sub{
  font-size: 12px;
  color: #888;
  margin-top: 3px;
}

.inv-row-stats{
  font-size: 12px;
  color: #bbb;
  margin-top: 6px;
}

.inv-row-actions form{
  display:flex;
  gap: 6px;
}

@media (max-width: 820px){
  .inv-layout{ grid-template-columns: 1fr; }
  .modal{ max-height: 92vh; }
}

/* =========================
   BASE STATS (tooltips + mały +)
========================= */

.tooltip{
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px 12px;
  margin: 6px 0;

  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(0,0,0,.18));
  border: 1px solid rgba(255,215,128,0.10);
  border-radius: 12px;
}

.stat-left{
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
}

.bonus{
  color: var(--gold);
  margin-left: 4px;
  font-size: 13px;
}

/* + zawsze po prawej */
.stat-add-form{
  margin-left: auto;
  display: inline-flex;
  flex: 0 0 auto;
}

/* mały czerwony + (kwadratowy) */
.btn-stat{
  width: 28px !important;
  height: 28px !important;
  padding: 0 !important;
  margin: 0 !important;

  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  border-radius: 6px !important; /* kwadrat z lekkim zaokrągleniem */
  border: 1px solid rgba(255,80,80,0.6) !important;

  background: radial-gradient(circle at 30% 30%, #c0392b, #7f1d1d) !important;
  color: #fff !important;

  font-weight: 900 !important;
  font-size: 16px !important;
  line-height: 1 !important;

  box-shadow: 0 0 8px rgba(220,60,60,0.45) !important;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}

.btn-stat:hover{
  transform: scale(1.1);
  box-shadow: 0 0 14px rgba(220,60,60,0.75) !important;
  filter: brightness(1.1);
}


/* Tooltip dymek */
.tooltip-box{
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translate(12px, -50%);

  min-width: 220px;
  padding: 10px 12px;

  background: #000;
  color: #eee;
  border-radius: 10px;
  border: 1px solid rgba(255,215,128,0.12);

  font-size: 13px;
  line-height: 1.4;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .15s ease;

  z-index: 2000;
}

.tooltip:hover .tooltip-box{
  opacity: 1;
  visibility: visible;
}

/* Mobile: tooltip pod spodem */
@media (max-width: 768px){
  .tooltip-box{
    left: 0;
    top: 100%;
    transform: translate(0, 10px);
    width: 100%;
    min-width: unset;
  }

  .tooltip:focus-within .tooltip-box{
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

