* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0c1018;
  --panel: rgba(24, 31, 46, 0.88);
  --panel2: #232c40;
  --accent: #ffb545;
  --accent2: #4fc3f7;
  --text: #e8ecf4;
  --dim: #8a94a8;
  --danger: #ff5252;
  --ok: #7ed957;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Tahoma, sans-serif;
  overflow: hidden;
  user-select: none;
}

/* ===== Ekranlar ===== */
.screen {
  display: none;
  position: absolute; inset: 0;
  align-items: center; justify-content: center;
}
.screen.active { display: flex; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#screen-menu.active, #screen-setup.active, #screen-armory.active,
#screen-stats.active, #screen-help.active {
  background:
    radial-gradient(ellipse 60% 45% at 75% 15%, rgba(255, 181, 69, 0.10) 0%, transparent 60%),
    radial-gradient(ellipse 70% 55% at 25% 85%, rgba(79, 195, 247, 0.10) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 30%, #1d2941 0%, var(--bg) 72%);
}

.menu-box {
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(120, 150, 200, 0.22);
  border-radius: 18px;
  padding: 36px 44px;
  text-align: center;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  max-width: 520px;
  width: 92%;
  max-height: 92vh;
  overflow-y: auto;
}
.menu-box.wide { max-width: 900px; }
.menu-box h2 {
  font-size: 26px; letter-spacing: 1px; margin-bottom: 6px;
}

.title {
  font-size: 42px; font-weight: 900; letter-spacing: 3px;
  background: linear-gradient(180deg, #ffffff 20%, #b8cfe8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 24px rgba(79, 195, 247, 0.25);
}
.title span {
  background: linear-gradient(180deg, #ffd27a, #f09a1c);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle { color: var(--dim); margin: 6px 0 18px; letter-spacing: 0.5px; }

.profile-badge {
  background: rgba(19, 25, 38, 0.75);
  border: 1px solid rgba(120, 150, 200, 0.15);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: 14px; color: var(--dim);
}
.profile-badge b { color: var(--accent); }
.profile-badge .xpbar {
  height: 8px; background: #0d1220; border-radius: 4px; margin-top: 8px; overflow: hidden;
}
.profile-badge .xpbar > div {
  height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(255, 181, 69, 0.6);
  transition: width .5s ease;
}

/* ===== Düymələr ===== */
.btn {
  display: block; width: 100%;
  margin: 8px 0;
  padding: 12px 18px;
  font-size: 17px; font-weight: 700;
  color: var(--text);
  background: linear-gradient(180deg, #2a3550, #202940);
  border: 1px solid rgba(120, 150, 200, 0.25);
  border-radius: 12px;
  cursor: pointer;
  transition: all .15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.btn:hover {
  border-color: var(--accent2);
  box-shadow: 0 4px 16px rgba(79, 195, 247, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}
.btn:active { transform: translateY(0); }
.btn.big {
  background: linear-gradient(180deg, #ffc75e, #ef941a);
  color: #2a1c02; font-size: 20px; border: none;
  letter-spacing: 1px;
  box-shadow: 0 6px 20px rgba(240, 154, 28, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn.big:hover {
  filter: brightness(1.08);
  box-shadow: 0 8px 28px rgba(240, 154, 28, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn.small { font-size: 13px; padding: 8px 12px; }

/* ===== Quruluş ===== */
.setup-players { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.player-slot {
  background: rgba(19, 25, 38, 0.7);
  border: 1px solid rgba(120, 150, 200, 0.15);
  border-radius: 12px; padding: 12px;
  display: flex; align-items: center; gap: 10px;
}
.player-slot .dot {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.player-slot input[type=text] {
  width: 110px; background: #0d1220; color: var(--text);
  border: 1px solid #35415f; border-radius: 8px; padding: 6px 8px; font-size: 14px;
}
select {
  background: #0d1220; color: var(--text);
  border: 1px solid #35415f; border-radius: 8px;
  padding: 6px 8px; font-size: 14px; cursor: pointer;
}
select:hover { border-color: var(--accent2); }
.setup-row {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 10px; margin: 14px 0; font-size: 14px; color: var(--dim);
}
.setup-buttons { margin-top: 10px; }

/* ===== Arsenal ===== */
.armory-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px; margin: 16px 0; text-align: left;
}
.wcard {
  background: rgba(28, 36, 54, 0.85);
  border: 1px solid rgba(120, 150, 200, 0.12);
  border-radius: 12px; padding: 10px 12px;
  border-left: 4px solid var(--accent2);
  transition: transform .15s ease, box-shadow .15s ease;
}
.wcard:hover:not(.locked) {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}
.wcard.locked { opacity: .42; border-left-color: #555; }
.wcard .wname { font-weight: 700; font-size: 15px; }
.wcard .wdesc { font-size: 12px; color: var(--dim); margin: 4px 0; min-height: 30px; }
.wcard .wstats { font-size: 11px; color: var(--accent); }
.wcard .wlock { font-size: 11px; color: var(--danger); }

/* ===== Statistika / Kömək ===== */
.stats-body { text-align: left; font-size: 16px; line-height: 2; margin: 12px 0; }
.stats-body b { color: var(--accent); }
.help-body { text-align: left; font-size: 14px; line-height: 1.6; color: var(--text); }
.help-body p { margin: 10px 0; }
.help-table { width: 100%; margin: 10px 0; border-collapse: collapse; }
.help-table td { padding: 5px 10px; border-bottom: 1px solid rgba(120, 150, 200, 0.12); font-size: 14px; }
.help-table td:first-child { color: var(--accent2); width: 160px; }

/* ===== Oyun ekranı ===== */
#screen-game { background: #000; flex-direction: column; --hud-h: 96px; }
#canvas {
  max-width: 100vw;
  /* aşağı panel oyun sahəsini örtməsin — kanvas panelin üstündə qalır */
  max-height: calc(100vh - var(--hud-h));
  margin-bottom: var(--hud-h);
  aspect-ratio: 16 / 9;
  display: block;
}

#hud {
  position: absolute; inset: 0;
  pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
}
#hud-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 18px;
}
#hud-top > div {
  background: rgba(10, 14, 22, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(120, 150, 200, 0.18);
  border-radius: 12px;
  padding: 8px 18px; text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
#hud-player-name { font-weight: 800; font-size: 18px; text-shadow: 0 0 12px currentColor; }
.hud-label { display: block; font-size: 10px; color: var(--dim); letter-spacing: 1.5px; }
#hud-wind-val, #hud-round-val { font-weight: 700; font-size: 16px; }

#hud-bottom {
  display: flex; align-items: center; gap: 18px;
  background: linear-gradient(180deg, rgba(10, 14, 22, 0.82), rgba(10, 14, 22, 0.94));
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(120, 150, 200, 0.18);
  padding: 12px 20px;
  pointer-events: auto;
}
.hud-group { display: flex; flex-direction: column; gap: 3px; }
.hud-group.grow { flex: 1; }
.hud-value { font-size: 22px; font-weight: 800; color: var(--accent2); min-width: 64px; text-shadow: 0 0 10px rgba(79, 195, 247, 0.4); }
#hud-weapon { min-width: 190px; font-size: 15px; padding: 8px; }

#hud-power {
  -webkit-appearance: none;
  appearance: none;
  width: 100%; height: 8px;
  background: linear-gradient(90deg, #2e5c37, #b8a03a, #b04030);
  border-radius: 4px;
  outline: none;
}
#hud-power::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  background: radial-gradient(circle at 35% 35%, #fff, var(--accent));
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(255, 181, 69, 0.7);
}

.fuel-bar {
  width: 90px; height: 13px; background: #0d1220;
  border: 1px solid rgba(120, 150, 200, 0.2);
  border-radius: 7px; overflow: hidden;
}
#hud-fuel {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #4a9f3c, #7ed957);
  border-radius: 6px;
  box-shadow: 0 0 8px rgba(126, 217, 87, 0.5);
  transition: width .1s linear;
}

#btn-fire {
  padding: 14px 36px; font-size: 22px; font-weight: 900;
  background: linear-gradient(180deg, #ff7057, #d02c20);
  color: #fff; border: none; border-radius: 14px; cursor: pointer;
  letter-spacing: 2px;
  box-shadow: 0 6px 22px rgba(214, 48, 36, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  animation: firePulse 1.6s ease-in-out infinite;
  transition: filter .12s;
}
@keyframes firePulse {
  0%, 100% { box-shadow: 0 6px 22px rgba(214, 48, 36, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
  50% { box-shadow: 0 6px 32px rgba(214, 48, 36, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
}
#btn-fire:hover { filter: brightness(1.15); }
#btn-fire:disabled { filter: grayscale(1) brightness(.55); cursor: default; animation: none; }

/* ===== Overlay-lər ===== */
.overlay {
  display: none;
  position: absolute; inset: 0;
  background: rgba(4, 6, 12, 0.72);
  backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
  z-index: 20;
}
.overlay.active { display: flex; animation: fadeIn .35s ease; }
#go-title { text-shadow: 0 0 20px currentColor; }
#go-body { text-align: left; margin: 14px 0; font-size: 15px; line-height: 1.8; }
#go-body table { width: 100%; border-collapse: collapse; }
#go-body td, #go-body th { padding: 4px 10px; border-bottom: 1px solid rgba(120, 150, 200, 0.14); font-size: 14px; text-align: left; }
#go-body .xp-gain { color: var(--accent); font-weight: 700; }
#go-body .unlock { color: var(--ok); font-weight: 700; }

/* ===== Onlayn ===== */
.dim { color: var(--dim); font-weight: 400; font-size: 0.9em; }
.auth-form input {
  display: block; width: 100%;
  margin: 8px 0;
  padding: 12px 14px;
  font-size: 16px;
  background: #0d1220; color: var(--text);
  border: 1px solid #35415f; border-radius: 10px;
}
.auth-form input:focus { border-color: var(--accent2); outline: none; }
.auth-error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 4px 0; }

.online-me {
  background: rgba(19, 25, 38, 0.7);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 14px;
  font-size: 15px;
}
.online-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; text-align: left; }
.online-col h3 { margin-bottom: 8px; color: var(--accent2); }
.join-row { display: flex; gap: 8px; margin: 8px 0; }
.join-row input {
  flex: 1;
  padding: 10px 12px; font-size: 16px;
  background: #0d1220; color: var(--text);
  border: 1px solid #35415f; border-radius: 10px;
}
.join-row .btn { width: auto; margin: 0; }
.hint { font-size: 12px; color: var(--dim); line-height: 1.5; margin-top: 8px; }

.friend-list { max-height: 220px; overflow-y: auto; margin-top: 6px; }
.friend-row {
  display: flex; align-items: center; gap: 8px;
  background: rgba(19, 25, 38, 0.6);
  border-radius: 8px;
  padding: 7px 10px; margin: 5px 0;
  font-size: 14px;
}
.friend-row.request { border-left: 3px solid var(--accent); }
.friend-row .btn.inline { width: auto; margin: 0 0 0 auto; padding: 4px 10px; }
.friend-row .btn.inline + .btn.inline { margin-left: 6px; }
.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #555; flex-shrink: 0;
}
.status-dot.on { background: var(--ok); box-shadow: 0 0 7px var(--ok); }

.room-code-box {
  background: rgba(19, 25, 38, 0.75);
  border: 1px dashed var(--accent);
  border-radius: 12px;
  padding: 12px;
  margin: 12px 0;
  font-size: 16px; letter-spacing: 1px;
}
.room-code-box span {
  color: var(--accent); font-size: 28px; font-weight: 900; letter-spacing: 6px;
  text-shadow: 0 0 14px rgba(255, 181, 69, 0.5);
}
.btn.inline { display: inline-block; width: auto; margin: 0 4px; padding: 6px 12px; }

.lobby-players { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.lobby-player {
  display: flex; align-items: center; gap: 10px;
  background: rgba(19, 25, 38, 0.7);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 15px;
}
.lobby-player .dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }

#toasts {
  position: fixed; top: 14px; right: 14px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 100;
  max-width: 340px;
}
.toast {
  background: rgba(20, 27, 42, 0.95);
  border: 1px solid rgba(120, 150, 200, 0.3);
  border-left: 3px solid var(--accent2);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: toastIn .25s ease;
  display: flex; align-items: center; gap: 10px;
}
@keyframes toastIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Çat ===== */
#chat-box {
  display: none; /* yalnız onlayn oyunda görünür */
  position: absolute;
  left: 12px; bottom: calc(var(--hud-h, 96px) + 10px);
  width: 290px;
  flex-direction: column; gap: 6px;
  pointer-events: auto;
  z-index: 10;
}
#chat-msgs { display: flex; flex-direction: column; gap: 3px; }
.chat-msg {
  background: rgba(10, 14, 22, 0.72);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
  animation: toastIn .2s ease;
}
.chat-input-row { display: flex; gap: 6px; }
.chat-input-row input {
  flex: 1;
  background: rgba(10, 14, 22, 0.85);
  color: var(--text);
  border: 1px solid rgba(120, 150, 200, 0.3);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
}
.chat-input-row input:focus { border-color: var(--accent2); outline: none; }
.chat-input-row button {
  background: var(--panel2);
  color: var(--accent2);
  border: 1px solid rgba(120, 150, 200, 0.3);
  border-radius: 8px;
  width: 36px;
  cursor: pointer;
  font-size: 14px;
}
.chat-input-row button:hover { border-color: var(--accent2); }

#lobby-chat { margin: 12px 0; text-align: left; }
#lobby-chat-msgs {
  max-height: 140px; overflow-y: auto;
  background: rgba(13, 18, 32, 0.6);
  border: 1px solid rgba(120, 150, 200, 0.15);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 6px;
  min-height: 40px;
}
#lobby-chat-msgs .chat-msg { background: transparent; padding: 2px 4px; animation: none; }

@media (max-width: 900px) {
  #chat-box { width: 210px; }
  .chat-msg { font-size: 12px; }
}

/* ===== Level cədvəli ===== */
.level-table-wrap {
  max-height: 300px; overflow-y: auto;
  margin: 14px 0;
  border: 1px solid rgba(120, 150, 200, 0.18);
  border-radius: 10px;
}
.level-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.level-table th {
  position: sticky; top: 0;
  background: var(--panel2);
  padding: 7px 10px; text-align: left;
  color: var(--accent2); font-size: 12px; letter-spacing: 1px;
}
.level-table td { padding: 5px 10px; border-top: 1px solid rgba(120, 150, 200, 0.1); }
.level-table tr.done td { color: var(--dim); }
.level-table tr.current td {
  background: rgba(255, 181, 69, 0.12);
  color: var(--accent); font-weight: 700;
}

/* ===== Qaraj ===== */
.garage-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px; margin: 16px 0; text-align: center;
}
.skin-card {
  background: rgba(28, 36, 54, 0.85);
  border: 2px solid rgba(120, 150, 200, 0.15);
  border-radius: 14px; padding: 10px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.skin-card canvas { width: 100%; height: auto; }
.skin-card:hover:not(.locked) { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.4); }
.skin-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(255, 181, 69, 0.35);
}
.skin-card.locked { opacity: .45; cursor: default; }
.skin-card.locked canvas { filter: grayscale(1); }
.skin-card .wname { font-weight: 700; font-size: 15px; }
.skin-card .wdesc { font-size: 12px; color: var(--dim); margin: 3px 0; }
.skin-card .wlock { font-size: 11px; color: var(--danger); }

.menu-row { display: flex; gap: 8px; }
.menu-row .btn { flex: 1; }

/* ===== Tam ekran düyməsi (oyun HUD) ===== */
#btn-fs-game {
  pointer-events: auto;
  background: rgba(10, 14, 22, 0.78);
  border: 1px solid rgba(120, 150, 200, 0.18);
  border-radius: 12px;
  color: var(--text);
  font-size: 20px;
  width: 46px; height: 46px;
  cursor: pointer;
}
#btn-fs-game:hover { border-color: var(--accent2); }

/* ===== Toxunma idarəetməsi ===== */
#canvas { touch-action: none; }
body { touch-action: manipulation; }
.touch-only { display: none; }
.move-btns { display: flex; gap: 6px; }
.move-btns button {
  width: 52px; height: 44px;
  font-size: 20px; font-weight: 900;
  background: linear-gradient(180deg, #2a3550, #202940);
  border: 1px solid rgba(120, 150, 200, 0.3);
  border-radius: 10px;
  color: var(--text);
  touch-action: none;
  user-select: none;
}
.move-btns button:active { background: #35456a; }

#rotate-hint {
  display: none;
  position: fixed; inset: 0;
  background: rgba(6, 9, 16, 0.96);
  z-index: 200;
  align-items: center; justify-content: center;
  text-align: center;
  font-size: 26px; font-weight: 800; line-height: 1.6;
}

/* ===== Mobil / planşet ===== */
@media (pointer: coarse) {
  .touch-only { display: flex; }
  .btn { padding: 14px 18px; }               /* daha böyük toxunma sahəsi */
  #hud-power { height: 14px; }
  #hud-power::-webkit-slider-thumb { width: 28px; height: 28px; }
}

@media (max-width: 900px) {
  #screen-game { --hud-h: 118px; } /* mobildə panel hündürdür (sətirlər qatlanır) */
  .menu-box { padding: 20px 18px; border-radius: 14px; }
  .title { font-size: 30px; }
  .menu-box h2 { font-size: 21px; }
  .online-cols { grid-template-columns: 1fr; }
  .setup-players { grid-template-columns: 1fr; }
  .lobby-players { grid-template-columns: 1fr; }
  #hud-top { padding: 6px 8px; }
  #hud-top > div { padding: 5px 10px; }
  #hud-player-name { font-size: 14px; }
  #hud-bottom { gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
  #hud-weapon { min-width: 120px; font-size: 13px; }
  .hud-value { font-size: 17px; min-width: 46px; }
  .fuel-bar { width: 60px; }
  #btn-fire { padding: 10px 18px; font-size: 17px; border-radius: 10px; }
  #btn-fs-game { width: 38px; height: 38px; font-size: 16px; }
}

@media (orientation: portrait) and (pointer: coarse) {
  /* yalnız döyüş zamanı üfüqi rejim tələb et — menyular portretdə də işləyir */
  #screen-game.active ~ #rotate-hint { display: flex; }
}

/* ===== Sürüşdürmə zolağı ===== */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #35415f; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #45557a; }
