@import url('https://fonts.googleapis.com/css2?family=Russo+One&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --bg: #07070d;
  --surface: #12121f;
  --surface2: #1a1a30;
  --border: #2a2a45;
  --primary: #00ff88;
  --primary-dim: #00cc6a;
  --secondary: #ff6b35;
  --gold: #ffd700;
  --danger: #ff4757;
  --text: #e8e8f0;
  --text-dim: #8888aa;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { overflow-x: hidden; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(0,255,136,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(255,107,53,0.04) 0%, transparent 50%);
  pointer-events: none; z-index: 0;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  position: relative; z-index: 1;
}

h1, h2, h3 { font-family: 'Russo One', sans-serif; letter-spacing: 0.02em; }

h1 {
  font-size: 2.4rem;
  background: linear-gradient(135deg, var(--primary), var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  text-align: center; margin-bottom: 0.3rem;
}

.subtitle { text-align: center; color: var(--text-dim); margin-bottom: 2.5rem; font-size: 1rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem; margin-bottom: 1.5rem;
  transition: border-color 0.3s;
}
.card:hover { border-color: var(--primary-dim); }
.card h2 { font-size: 1.2rem; margin-bottom: 1rem; color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1.8rem; border: none; border-radius: 8px;
  font-family: 'Russo One', sans-serif; font-size: 0.95rem;
  cursor: pointer; transition: all 0.2s; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #000; }
.btn-primary:hover { background: #33ffaa; transform: translateY(-2px); box-shadow: 0 4px 20px rgba(0,255,136,0.3); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #ff6b7a; }
.btn-sm { padding: 0.4rem 1rem; font-size: 0.8rem; }

input[type="text"], input[type="password"], textarea {
  width: 100%; padding: 0.8rem 1rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-family: 'Nunito', sans-serif; font-size: 16px;
  transition: border-color 0.3s;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; min-height: 100px; }

label {
  display: block; margin-bottom: 0.4rem;
  font-weight: 700; color: var(--text-dim);
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em;
}

.form-group { margin-bottom: 1.2rem; }

.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 2rem; text-align: center; cursor: pointer;
  transition: all 0.3s; background: var(--bg);
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: rgba(0,255,136,0.03); }
.upload-zone img { max-width: 120px; max-height: 120px; border-radius: 8px; margin-top: 0.5rem; }

.texture-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem; margin-top: 1rem;
}
.texture-item {
  position: relative; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0.5rem; text-align: center;
}
.texture-item img { width: 100%; height: 80px; object-fit: contain; border-radius: 4px; }
.texture-item .delete-btn {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--danger); color: #fff; border: none;
  cursor: pointer; font-size: 14px; line-height: 24px; display: none;
}
.texture-item:hover .delete-btn { display: block; }

.leaderboard { width: 100%; border-collapse: collapse; }
.leaderboard th {
  text-align: left; padding: 0.5rem 0.6rem; color: var(--text-dim);
  font-size: 0.75rem; text-transform: uppercase; border-bottom: 1px solid var(--border);
}
.leaderboard td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.leaderboard tr:first-child td { color: var(--gold); font-weight: 800; }

.game-list { display: grid; gap: 1rem; margin-top: 1rem; }
.game-item {
  display: flex; align-items: center; gap: 1rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  text-decoration: none; color: var(--text); transition: all 0.2s;
}
.game-item:hover { border-color: var(--primary); transform: translateX(4px); }
.game-item img { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.game-item-info h3 { font-size: 1rem; }
.game-item-info p { color: var(--text-dim); font-size: 0.85rem; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab {
  padding: 0.5rem 1rem; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-dim); cursor: pointer;
  font-size: 0.8rem; font-weight: 700; transition: all 0.2s;
}
.tab.active, .tab:hover { border-color: var(--primary); color: var(--primary); }

.alert { padding: 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-success { background: rgba(0,255,136,0.1); border: 1px solid var(--primary); color: var(--primary); }
.alert-error { background: rgba(255,71,87,0.1); border: 1px solid var(--danger); color: var(--danger); }

.link-box {
  background: var(--bg); border: 1px solid var(--primary);
  border-radius: 8px; padding: 1rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.link-box input { flex: 1; background: transparent; border: none; color: var(--primary); font-size: 0.85rem; }
.link-box input:focus { outline: none; }

/* ====== BANNER ====== */
.promo-banner {
  background: linear-gradient(135deg, rgba(255,215,0,0.08), rgba(255,107,53,0.08));
  border: 1px solid rgba(255,215,0,0.2);
  border-radius: 10px;
  padding: 10px 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--gold);
  line-height: 1.5;
  display: none;
  margin: 8px auto;
  max-width: 700px;
  backdrop-filter: blur(4px);
}
.promo-banner a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}
.promo-banner a:hover { text-decoration: underline; }

/* ====== GAME LAYOUT ====== */
#game-wrapper {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.5rem;
}
#game-container { width: 100%; position: relative; touch-action: none; }
#game-container canvas { border-radius: 8px; display: block; margin: 0 auto; width: 100% !important; height: auto !important; }

.game-title-bar {
  text-align: center; padding: 6px;
  font-family: 'Russo One', sans-serif; font-size: 1.2rem;
  background: linear-gradient(135deg, var(--primary), var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

#game-hud {
  display: flex; justify-content: space-between;
  padding: 6px 12px;
  background: var(--surface);
  border-radius: 8px 8px 0 0;
  border: 1px solid var(--border); border-bottom: none;
}
#game-hud > div { font-family: 'Russo One', sans-serif; font-size: 1rem; }

#weapon-bar {
  display: flex; justify-content: center; gap: 0.5rem;
  padding: 8px; background: var(--surface);
  border-radius: 0 0 10px 10px;
  border: 1px solid var(--border); border-top: none;
}

.weapon-btn {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 16px; border-radius: 8px; cursor: pointer;
  background: var(--surface2); border: 2px solid var(--border);
  color: var(--text); font-family: 'Nunito', sans-serif; font-weight: 700;
  transition: all 0.2s; min-width: 90px;
}
.weapon-btn.active { border-color: var(--primary); background: rgba(0,255,136,0.1); }
.weapon-btn:hover { border-color: var(--primary); }
.weapon-btn .weapon-icon { font-size: 1.5rem; }
.weapon-btn .weapon-name { font-size: 0.7rem; text-transform: uppercase; }
.weapon-btn .weapon-pts { font-size: 0.65rem; color: var(--gold); }
.weapon-btn .weapon-cd { font-size: 0.6rem; }
.weapon-btn kbd { font-size: 0.6rem; background: var(--bg); padding: 1px 4px; border-radius: 3px; color: var(--text-dim); }

.cd-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.7);
  display: none; pointer-events: none;
  transition: height 0.05s linear;
}
.cd-text {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Russo One', sans-serif;
  font-size: 1.1rem; color: var(--danger);
  display: none; pointer-events: none;
  z-index: 2; text-shadow: 0 0 6px rgba(0,0,0,0.8);
}

.nickname-screen {
  text-align: center; padding: 2rem 1rem;
}
.nickname-screen h1 { font-size: 1.8rem; margin-bottom: 0.3rem; }
.nickname-screen .avatar-preview {
  width: 100px; height: 100px; border-radius: 50%;
  object-fit: cover; border: 3px solid var(--primary);
  margin: 1rem auto; display: block;
}
.nickname-screen input { max-width: 320px; margin: 0 auto 1rem; text-align: center; }

.back-btn {
  position: fixed; top: 8px; left: 8px; z-index: 999;
  padding: 5px 12px; border-radius: 8px; font-size: 0.75rem;
  background: rgba(18,18,31,0.9); border: 1px solid var(--border);
  color: var(--text-dim); text-decoration: none; font-family: 'Nunito', sans-serif;
  font-weight: 700; transition: all 0.2s; backdrop-filter: blur(4px);
}
.back-btn:hover { border-color: var(--primary); color: var(--primary); }

.result-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(7,7,13,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(8px);
  padding: 1rem; overflow-y: auto;
}
.result-card {
  position: relative;
  background: var(--surface); border: 2px solid var(--gold);
  border-radius: 16px; padding: 2rem;
  text-align: center; max-width: 420px; width: 100%;
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.result-card .score-big {
  font-family: 'Russo One', sans-serif;
  font-size: 3rem; color: var(--gold); margin: 0.3rem 0;
}
.hidden { display: none !important; }

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
  .container { padding: 1rem 0.8rem; }
  h1 { font-size: 1.6rem; }
  .subtitle { font-size: 0.85rem; margin-bottom: 1.5rem; }
  .card { padding: 1.2rem; }

  .game-title-bar { font-size: 1rem; padding: 4px; }
  #game-hud { padding: 5px 8px; }
  #game-hud > div { font-size: 0.75rem; }

  #weapon-bar { gap: 0.3rem; padding: 6px; }
  .weapon-btn { padding: 5px 10px; min-width: 75px; }
  .weapon-btn .weapon-icon { font-size: 1.2rem; }
  .weapon-btn .weapon-name { font-size: 0.6rem; }
  .weapon-btn .weapon-pts { font-size: 0.55rem; }
  .weapon-btn kbd { display: none; }

  .nickname-screen { padding: 1rem 0.5rem; }
  .nickname-screen h1 { font-size: 1.4rem; }
  .nickname-screen .avatar-preview { width: 80px; height: 80px; }

  .result-card { padding: 1.5rem 1rem; }
  .result-card .score-big { font-size: 2.5rem; }

  .back-btn { padding: 4px 10px; font-size: 0.7rem; }

  .leaderboard th, .leaderboard td { padding: 0.4rem; font-size: 0.8rem; }

  .promo-banner { font-size: 0.75rem; padding: 8px 12px; margin: 6px 8px; }

  .game-item { padding: 0.8rem; gap: 0.7rem; }
  .game-item img { width: 44px; height: 44px; }
  .game-item-info h3 { font-size: 0.9rem; }
  .game-item-info p { font-size: 0.75rem; }

  .tabs { gap: 0.3rem; }
  .tab { padding: 0.4rem 0.7rem; font-size: 0.7rem; }

  .texture-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 0.5rem; }
}

@media (max-width: 400px) {
  h1 { font-size: 1.3rem; }
  #game-hud > div { font-size: 0.65rem; }
  .weapon-btn { padding: 4px 6px; min-width: 60px; }
  .weapon-btn .weapon-icon { font-size: 1rem; }
  .weapon-btn .weapon-name { font-size: 0.55rem; }
  .weapon-btn .weapon-cd { display: none; }
  .result-card .score-big { font-size: 2rem; }
}

/* Telegram WebApp fixes */
@supports (padding: env(safe-area-inset-bottom)) {
  #weapon-bar { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .result-overlay { padding-bottom: env(safe-area-inset-bottom); }
}

/* ====== AGE GATE ====== */
.age-gate {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(7,7,13,0.97);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; padding: 1rem;
}
.age-gate-box {
  background: var(--surface);
  border: 2px solid var(--secondary);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 380px; width: 100%;
  animation: popIn 0.3s ease-out;
}
.age-gate-box .age-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.age-gate-box h2 { font-family: 'Russo One', sans-serif; font-size: 1.3rem; margin-bottom: 0.5rem; }
.age-gate-box p { color: var(--text-dim); font-size: 0.85rem; line-height: 1.5; margin-bottom: 1.2rem; }
.age-gate-btns { display: flex; gap: 0.8rem; justify-content: center; }

/* ====== FOOTER ====== */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-dim);
  font-size: 0.72rem;
  line-height: 1.6;
  opacity: 0.6;
  transition: opacity 0.3s;
}
.site-footer:hover { opacity: 1; }
.site-footer a { color: var(--text-dim); text-decoration: none; }
.site-footer a:hover { color: var(--primary); text-decoration: underline; }
