:root {
  --red: #e3262e;
  --red-dark: #8f1218;
  --gold: #ffc93c;
  --ink: #0d1020;
  --paper: #fff7e6;
  --slate: #2b3158;
  --slate-dark: #171b36;
}

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

input,
textarea {
  user-select: text;
  -webkit-user-select: text;
}

html,
body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink);
  color: var(--paper);
  font-family: Arial, Helvetica, sans-serif;
  touch-action: none;
}

#c {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

#c.punch-cursor {
  cursor: none;
}

.hidden {
  display: none !important;
}

.screen.hidden,
.hud.hidden {
  display: flex !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.hud.hidden {
  display: block !important;
}

/* HUD */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: calc(12px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 0 calc(14px + env(safe-area-inset-left));
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.hud-box {
  min-width: 96px;
  padding: 6px 14px 7px;
  background: rgba(13, 16, 32, 0.88);
  border: 2px solid var(--gold);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.mult-pill {
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--red);
  border: 2px solid var(--gold);
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-size: 20px;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 2px 0 #000;
  box-shadow: 0 4px 14px rgba(227, 38, 46, 0.45);
}

.mult-pill.x3 {
  background: linear-gradient(135deg, #e3262e, #ff7b00);
  color: #fff;
}

.lbl {
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-transform: uppercase;
}

.val {
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-size: 26px;
  line-height: 1.1;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}

.bar {
  margin-top: 10px;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.barfill {
  width: 100%;
  height: 100%;
  background: var(--gold);
  border-radius: 999px;
  transform-origin: left center;
  transform: scaleX(1);
  transition: background-color 0.2s ease;
}

.barfill.danger {
  background: var(--red);
}

.combo {
  position: fixed;
  top: calc(100px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(20px, 5vw, 28px);
  letter-spacing: 0.04em;
  color: var(--gold);
  text-shadow: 0 3px 0 #000, 0 0 14px rgba(255, 201, 60, 0.45);
  opacity: 0;
  white-space: nowrap;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.combo.active {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.combo.pop {
  transform: translateX(-50%) scale(1.18);
}

/* Overlay Screens */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 16px calc(64px + env(safe-area-inset-bottom));
  background: rgba(13, 16, 32, 0.84);
  backdrop-filter: blur(2px);
  transition: opacity 0.2s ease;
  overflow-y: auto;
  touch-action: pan-y;
}

.card {
  width: 100%;
  max-width: 430px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.emblem-wrap {
  margin-bottom: 12px;
}

.avatar-btn {
  position: relative;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  display: inline-block;
  transition: transform 0.12s ease;
}

.avatar-btn:hover {
  transform: scale(1.04);
}

.emblem {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 5px solid var(--gold);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
  background: #171c36;
  display: block;
}

.avatar-badge {
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  background: var(--slate);
  border: 2px solid var(--gold);
  color: var(--paper);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}

h1 {
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(30px, 8.5vw, 48px);
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 4px 0 var(--red), 0 8px 0 rgba(0, 0, 0, 0.45);
  margin: 4px 0 10px;
  word-break: break-word;
}

.desc {
  font-size: 15px;
  line-height: 1.45;
  color: var(--paper);
  max-width: 350px;
  margin-bottom: 16px;
}

.desc strong {
  color: var(--gold);
}

/* Custom Photo & Name Controls */
.custom-panel {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 201, 60, 0.28);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 18px;
  text-align: left;
}

.field-label {
  display: block;
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--gold);
  margin-bottom: 8px;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.name-input {
  flex: 1 1 160px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: rgba(13, 16, 32, 0.9);
  color: var(--paper);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s ease;
}

.name-input:focus {
  border-color: var(--gold);
}

.name-input::placeholder {
  color: rgba(255, 247, 230, 0.45);
}

.btn-mini {
  border: 2px solid var(--gold);
  background: var(--slate);
  color: var(--paper);
  font-weight: 700;
  font-size: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.12s ease, transform 0.08s ease;
}

.btn-mini:hover {
  filter: brightness(1.12);
}

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

.btn-mini-ghost {
  background: transparent;
  border-color: rgba(255, 247, 230, 0.35);
  color: rgba(255, 247, 230, 0.85);
}

/* Buttons */
.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 260px;
  margin-top: 16px;
}

.btn {
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-size: 19px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 36px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.12s ease;
}

.btn:hover {
  filter: brightness(1.06);
}

.btn-red {
  background: var(--red);
  box-shadow: 0 6px 0 var(--red-dark), 0 12px 24px rgba(0, 0, 0, 0.45);
}

.btn-red:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--red-dark), 0 6px 12px rgba(0, 0, 0, 0.45);
}

.btn-slate {
  background: var(--slate);
  font-size: 16px;
  padding: 12px 26px;
  box-shadow: 0 5px 0 var(--slate-dark), 0 10px 20px rgba(0, 0, 0, 0.4);
}

.btn-slate:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--slate-dark), 0 5px 10px rgba(0, 0, 0, 0.4);
}

.sub-note {
  margin-top: 14px;
  font-size: 12px;
  color: rgba(255, 247, 230, 0.62);
}

/* End Screen */
.sub {
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.big {
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(58px, 16vw, 76px);
  line-height: 1.05;
  color: var(--gold);
  text-shadow: 0 5px 0 var(--red), 0 10px 0 rgba(0, 0, 0, 0.45);
  margin: 4px 0;
  font-variant-numeric: tabular-nums;
}

.stats {
  margin-top: 14px;
  font-size: 15px;
  color: var(--paper);
  line-height: 1.45;
}

.breakdown {
  margin-top: 6px;
  font-size: 13px;
  color: rgba(255, 247, 230, 0.72);
}

.sharemsg {
  margin-top: 12px;
  min-height: 18px;
  font-size: 13px;
  color: var(--gold);
}

/* Mute Button */
.mute {
  position: fixed;
  right: calc(14px + env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 30;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: rgba(13, 16, 32, 0.88);
  color: var(--paper);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.mute:hover {
  transform: scale(1.06);
}

.mute:active {
  transform: scale(0.95);
}

@media (max-width: 480px) {
  .hud-box {
    min-width: 78px;
    padding: 5px 10px 6px;
  }

  .val {
    font-size: 22px;
  }

  .mult-pill {
    font-size: 16px;
    padding: 5px 12px;
  }

  .emblem {
    width: 98px;
    height: 98px;
  }

  .desc {
    font-size: 14px;
    margin-bottom: 12px;
  }

  .custom-panel {
    padding: 10px;
    margin-bottom: 14px;
  }

  .btn {
    padding: 13px 28px;
    font-size: 18px;
  }
}

@media (max-height: 660px) {
  .emblem {
    width: 88px;
    height: 88px;
  }

  h1 {
    margin: 2px 0 6px;
  }

  .desc {
    margin-bottom: 10px;
  }

  .custom-panel {
    margin-bottom: 12px;
  }
}
