* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --blue: #4da6ff;
  --red: #ff5d6c;
  --gold: #ffd166;
  --ink: #0b0e1a;
  --glass: rgba(13, 17, 33, 0.72);
  --stroke: rgba(255, 255, 255, 0.12);
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  font-family: 'Inter', -apple-system, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#cam {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 0;
  background: var(--ink);
}
#gl { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; }

.hidden { display: none !important; }

/* ---------- экраны ---------- */
.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(77, 166, 255, 0.16), transparent 60%),
    radial-gradient(120% 90% at 50% 100%, rgba(255, 93, 108, 0.14), transparent 60%),
    var(--ink);
  padding: 24px;
  text-align: center;
}
#screen-arm, #screen-end, #screen-info {
  background: rgba(8, 10, 20, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* ---------- лобби ---------- */
.lobby-inner { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 26px; }
.logo-swords { font-size: 56px; filter: drop-shadow(0 0 24px rgba(255, 209, 102, 0.5)); }
h1 {
  font-family: 'Russo One', sans-serif;
  font-size: clamp(32px, 11vw, 46px); letter-spacing: 6px; margin-top: 6px;
  background: linear-gradient(180deg, #fff 30%, #7fb9ff);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 40px rgba(77, 166, 255, 0.35);
}
.tagline { color: rgba(255,255,255,0.6); font-size: 14px; margin-top: 8px; }

.lobby-buttons { display: flex; flex-direction: column; gap: 14px; }
.btn {
  border: none; border-radius: 16px; cursor: pointer;
  font-family: 'Russo One', sans-serif; font-size: 17px; letter-spacing: 1px;
  padding: 17px 22px; color: #fff; transition: transform 0.12s, filter 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, #2f7ee0, #4da6ff);
  box-shadow: 0 6px 28px rgba(77, 166, 255, 0.45), inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--stroke);
}
.btn-ghost { background: transparent; color: rgba(255,255,255,0.55); font-size: 14px; }
.btn-big { font-size: 22px; padding: 20px 40px; }

.join-row { display: flex; gap: 10px; }
#inp-code {
  flex: 1; min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke); border-radius: 16px;
  color: #fff; font-family: 'Russo One', sans-serif;
  font-size: 24px; letter-spacing: 10px; text-align: center; text-transform: uppercase;
  padding: 12px;
}
#inp-code:focus { outline: none; border-color: var(--blue); }
#inp-code::placeholder { color: rgba(255,255,255,0.25); letter-spacing: 4px; }

.rules { text-align: left; background: rgba(255,255,255,0.045); border: 1px solid var(--stroke); border-radius: 14px; padding: 14px 16px; font-size: 13.5px; }
.rules summary { cursor: pointer; font-weight: 600; color: rgba(255,255,255,0.85); }
.rules ul { margin: 12px 0 2px 18px; display: flex; flex-direction: column; gap: 7px; color: rgba(255,255,255,0.75); }
.lobby-err { color: var(--red); font-size: 14px; min-height: 18px; font-weight: 600; }

/* ---------- ожидание ---------- */
.wait-inner { display: flex; flex-direction: column; gap: 18px; align-items: center; width: 100%; max-width: 340px; }
.wait-label { color: rgba(255,255,255,0.55); font-size: 14px; letter-spacing: 2px; text-transform: uppercase; }
.room-code {
  font-family: 'Russo One', sans-serif; font-size: 64px; letter-spacing: 18px; padding-left: 18px;
  color: var(--gold);
  text-shadow: 0 0 38px rgba(255, 209, 102, 0.55);
}
.wait-hint { color: rgba(255,255,255,0.65); font-size: 15px; display: flex; align-items: center; gap: 10px; }
.pulse-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 0.35; transform: scale(0.8);} 50% { opacity: 1; transform: scale(1.15);} }
#btn-share { width: 100%; }

/* ---------- arm ---------- */
.arm-inner { display: flex; flex-direction: column; gap: 22px; align-items: center; }
.arm-vs { font-family: 'Russo One', sans-serif; font-size: 30px; display: flex; gap: 16px; align-items: baseline; }
.vs-you { color: var(--blue); text-shadow: 0 0 24px rgba(77,166,255,0.6); }
.vs-opp { color: var(--red); text-shadow: 0 0 24px rgba(255,93,108,0.6); }
.vs-x { color: var(--gold); font-size: 20px; }
.arm-hint { color: rgba(255,255,255,0.65); font-size: 15px; line-height: 1.5; }
.arm-status { color: rgba(255,255,255,0.55); font-size: 14px; min-height: 18px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; gap: 10px; align-items: flex-start;
  padding: calc(10px + env(safe-area-inset-top)) 12px 0;
}
.fighter-panel { flex: 1; min-width: 0; }
.fighter-panel.right { text-align: right; }
.fp-name { font-family: 'Russo One', sans-serif; font-size: 13px; letter-spacing: 1.5px; margin-bottom: 5px; }
.fp-name.you { color: var(--blue); }
.fp-name.opp { color: var(--red); }
.hpbar {
  height: 14px; border-radius: 8px; overflow: hidden;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--stroke);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.hpfill { height: 100%; width: 100%; border-radius: 7px; transition: width 0.6s cubic-bezier(.2,.9,.3,1); }
.hpfill.me { background: linear-gradient(90deg, #2f7ee0, #6fd0ff); box-shadow: 0 0 14px rgba(77,166,255,0.7); }
.hpfill.opp { background: linear-gradient(90deg, #ff8a5c, #ff5d6c); box-shadow: 0 0 14px rgba(255,93,108,0.7); float: right; }
.energy { display: flex; gap: 5px; margin-top: 6px; }
.fighter-panel.right .energy { justify-content: flex-end; }
.energy i {
  width: 16px; height: 9px; border-radius: 3px;
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.18);
  transform: skewX(-18deg);
  transition: background 0.3s, box-shadow 0.3s;
}
.energy i.on { background: var(--gold); box-shadow: 0 0 9px rgba(255, 209, 102, 0.85); border-color: var(--gold); }

.round-badge { width: 86px; flex: none; text-align: center; }
#round-num {
  font-family: 'Russo One', sans-serif; font-size: 15px; padding: 7px 4px 6px;
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 12px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.timerbar { height: 4px; margin-top: 5px; border-radius: 3px; background: rgba(255,255,255,0.13); overflow: hidden; }
#timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--gold), #ff9d5c); border-radius: 3px; }
#timer-fill.run { transition: width linear; }

.toast {
  position: absolute; left: 50%; top: 24%;
  transform: translateX(-50%);
  background: var(--glass); border: 1px solid var(--stroke); border-radius: 16px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 13px 22px; font-size: 16px; font-weight: 600;
  text-align: center; line-height: 1.55; white-space: nowrap;
  box-shadow: 0 10px 40px rgba(0,0,0,0.45);
  animation: toast-in 0.25s ease;
  z-index: 6;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(12px);} }
.toast .tl-me { color: #9ecfff; }
.toast .tl-opp { color: #ffb3ba; }
.toast .tl-big { font-family: 'Russo One', sans-serif; font-size: 19px; color: var(--gold); }

.opp-status {
  position: absolute; top: calc(86px + env(safe-area-inset-top)); right: 12px;
  background: rgba(255, 93, 108, 0.16); border: 1px solid rgba(255, 93, 108, 0.4);
  color: #ffc2c8; border-radius: 20px; font-size: 12.5px; font-weight: 600;
  padding: 6px 12px;
}

/* ---------- кнопки действий ---------- */
.actions {
  position: absolute; left: 0; right: 0;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; gap: 12px;
  pointer-events: auto; padding: 0 10px;
}
.act {
  width: 78px; height: 92px; border-radius: 20px; border: 1px solid var(--stroke);
  background: var(--glass);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: #fff; cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.12s, border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 8px 26px rgba(0,0,0,0.4);
}
.act:active { transform: scale(0.93); }
.act-ico { font-size: 30px; line-height: 1; }
.act-lbl { font-family: 'Russo One', sans-serif; font-size: 11.5px; letter-spacing: 0.5px; color: rgba(255,255,255,0.85); }
.act.picked { border-color: var(--gold); box-shadow: 0 0 22px rgba(255, 209, 102, 0.55); background: rgba(60, 50, 14, 0.75); }
.act:disabled { opacity: 0.38; pointer-events: none; }
.act-super .act-cost {
  position: absolute; top: -7px; right: -5px;
  background: var(--gold); color: #2a1d00;
  font-size: 11px; font-weight: 800; border-radius: 10px; padding: 2px 7px;
}
.act-super.charged { border-color: var(--gold); animation: super-glow 1.4s infinite; }
@keyframes super-glow {
  0%,100% { box-shadow: 0 0 12px rgba(255,209,102,0.4); }
  50% { box-shadow: 0 0 30px rgba(255,209,102,0.9); }
}

/* ---------- конец ---------- */
.end-inner { display: flex; flex-direction: column; gap: 16px; align-items: center; width: 100%; max-width: 320px; }
.end-title {
  font-family: 'Russo One', sans-serif; font-size: 52px; letter-spacing: 4px;
  animation: end-pop 0.5s cubic-bezier(.2,1.6,.4,1);
}
.end-title.small { font-size: 26px; }
.end-title.win { color: var(--gold); text-shadow: 0 0 50px rgba(255,209,102,0.8); }
.end-title.lose { color: var(--red); text-shadow: 0 0 40px rgba(255,93,108,0.6); }
.end-title.draw { color: #b9c4ff; text-shadow: 0 0 40px rgba(150,160,255,0.6); }
@keyframes end-pop { from { transform: scale(0.4); opacity: 0; } }
.end-sub { color: rgba(255,255,255,0.65); font-size: 15px; margin-bottom: 8px; }
#btn-rematch, #btn-info-menu { width: 100%; }

/* ---------- урон/вспышка ---------- */
#dmg-layer { position: fixed; inset: 0; z-index: 7; pointer-events: none; overflow: hidden; }
.dmg-num {
  position: absolute; transform: translate(-50%, -50%);
  font-family: 'Russo One', sans-serif; font-size: 30px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.7);
  animation: dmg-float 1.15s ease-out forwards;
}
.dmg-num.big { font-size: 44px; }
.dmg-num.blocked { font-size: 22px; }
@keyframes dmg-float {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  12% { opacity: 1; transform: translate(-50%, -58%) scale(1.18); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(0.95); }
}
#flash { position: fixed; inset: 0; z-index: 8; pointer-events: none; opacity: 0; background: radial-gradient(circle, transparent 35%, rgba(255, 40, 60, 0.55)); }
#flash.hit { animation: flash-hit 0.45s ease-out; }
@keyframes flash-hit { 0% { opacity: 1; } 100% { opacity: 0; } }
#flash.super { background: radial-gradient(circle, rgba(255,230,150,0.35), rgba(255, 120, 40, 0.6)); }

@media (max-width: 380px) {
  .act { width: 70px; height: 86px; }
  .room-code { font-size: 52px; letter-spacing: 13px; }
}
