:root {
  --bg: #07070a;
  --ink: #f3efe6;
  --muted: #a39e93;
  --accent: #e85d04;
  --accent2: #3d5a80;
  --danger: #c1121f;
  --ok: #2a9d8f;
  --panel: rgba(10, 10, 14, 0.82);
  --line: rgba(243, 239, 230, 0.14);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Oswald", system-ui, sans-serif;
  overflow: hidden;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#c {
  display: block;
  width: 100%;
  height: 100%;
}

.hidden { display: none !important; }

.panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: calc(1.2rem + var(--safe-t)) 1.2rem calc(1.2rem + var(--safe-b));
  background:
    radial-gradient(ellipse at 50% 0%, rgba(232, 93, 4, 0.22), transparent 55%),
    linear-gradient(180deg, rgba(7, 7, 10, 0.55), rgba(7, 7, 10, 0.92));
  backdrop-filter: blur(6px);
  text-align: center;
  z-index: 5;
}

.brand {
  font-family: "Bebas Neue", "Oswald", sans-serif;
  font-size: clamp(3.4rem, 16vw, 5.5rem);
  letter-spacing: 0.06em;
  line-height: 0.9;
  text-shadow: 0 0 40px rgba(232, 93, 4, 0.35);
}

.brand.small { font-size: clamp(2.4rem, 12vw, 3.6rem); }

.tagline {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0.04em;
}

.lobby-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  width: min(420px, 100%);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
  max-width: 28rem;
}

.wait-title {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#qrImg {
  width: min(260px, 70vw);
  height: auto;
  border-radius: 12px;
  background: #f4f4f0;
  padding: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.invite-link {
  color: var(--ink);
  font-size: 0.78rem;
  word-break: break-all;
  opacity: 0.75;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.85rem 1.4rem;
  border-radius: 999px;
  min-width: 12rem;
  cursor: pointer;
}

.btn.primary {
  background: linear-gradient(135deg, #e85d04, #9b2226);
  border-color: transparent;
  box-shadow: 0 10px 30px rgba(232, 93, 4, 0.28);
}

.btn:active { transform: scale(0.97); }

.error {
  color: #ffb4a2;
  background: rgba(193, 18, 31, 0.2);
  border: 1px solid rgba(193, 18, 31, 0.4);
  padding: 0.7rem 1rem;
  border-radius: 10px;
  max-width: 24rem;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(0.55rem + var(--safe-t)) 0.7rem 0;
  z-index: 4;
  pointer-events: none;
}

.bars {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.55rem;
  align-items: center;
}

.bar {
  position: relative;
  height: 1.15rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.bar-p1 { border-radius: 2px 0 0 2px; }
.bar-p2 { border-radius: 0 2px 2px 0; }

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: linear-gradient(90deg, #e85d04, #ffba08);
  transition: width 0.12s linear;
}

.bar-p2 .bar-fill {
  left: auto;
  right: 0;
  background: linear-gradient(270deg, #3d5a80, #98c1d9);
}

.bar-name, .wins {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 2px #000;
  z-index: 1;
}

.bar-p1 .bar-name { left: 0.4rem; }
.bar-p2 .bar-name { right: 0.4rem; }
.bar-p1 .wins { right: 0.4rem; }
.bar-p2 .wins { left: 0.4rem; }

.timer {
  min-width: 2.6rem;
  text-align: center;
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.8rem;
  line-height: 1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}

.you-tag {
  margin-top: 0.35rem;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}

.combo-hud {
  position: absolute;
  left: 50%;
  top: calc(3.2rem + var(--safe-t));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.85);
  animation: comboPop 0.25s ease-out;
}

.combo-hud #comboCount {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(2.4rem, 10vw, 3.6rem);
  line-height: 0.9;
  color: #ffba08;
}

.combo-hud .combo-x {
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  color: #ffe8a3;
}

.combo-hud .combo-label {
  margin-top: 0.15rem;
  font-size: 1rem;
  letter-spacing: 0.12em;
  color: #ff6b35;
  text-transform: uppercase;
}

.combo-hint {
  position: absolute;
  left: 50%;
  bottom: calc(5.8rem + var(--safe-b));
  transform: translateX(-50%);
  margin: 0;
  z-index: 4;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: rgba(243, 239, 230, 0.55);
  white-space: nowrap;
  pointer-events: none;
}

@keyframes comboPop {
  from { transform: translateX(-50%) scale(0.7); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

#banner {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  z-index: 4;
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(2.8rem, 14vw, 5rem);
  letter-spacing: 0.08em;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.75);
  pointer-events: none;
  white-space: nowrap;
}

#controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem calc(0.7rem + var(--safe-b));
  z-index: 4;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.45));
}

.pad, .actions {
  display: flex;
  gap: 0.45rem;
}

.ctrl {
  width: 4.1rem;
  height: 4.1rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(20, 20, 26, 0.72);
  color: var(--ink);
  font: inherit;
  font-size: 1.25rem;
  backdrop-filter: blur(4px);
}

.ctrl.act {
  width: 4.4rem;
  height: 4.4rem;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ctrl.punch { background: rgba(232, 93, 4, 0.55); }
.ctrl.kick { background: rgba(193, 18, 31, 0.55); }
.ctrl.block { background: rgba(61, 90, 128, 0.55); }
.ctrl.pressed, .ctrl:active {
  transform: scale(0.94);
  filter: brightness(1.2);
}

@media (min-width: 700px) and (orientation: landscape) {
  .ctrl { width: 4.6rem; height: 4.6rem; }
  .ctrl.act { width: 5rem; height: 5rem; }
}

@media (orientation: portrait) {
  #controls { padding-bottom: calc(1rem + var(--safe-b)); }
}
