:root {
  --text: #f8fcff;
  --button: #e03e31;
  --button-shadow: #7d1c13;
  --pixel-font: "Press Start 2P", "Trebuchet MS", sans-serif;
  --body-font: "Trebuchet MS", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  font-family: var(--body-font);
  color: var(--text);
  background: #101018;
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 0;
}

.page-shell {
  width: 100vw;
  height: 100vh;
  position: relative;
}

.top-bar,
.status-strip,
.status-card,
.label {
  display: none;
}

.eyebrow {
  margin: 0 0 5px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.56rem;
  color: rgba(255, 255, 255, 0.72);
  font-family: var(--pixel-font);
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  letter-spacing: 0.03em;
  font-family: var(--pixel-font);
  line-height: 1.35;
}

.game-panel {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #5ab5ff;
}

.hud-actions {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.party-hud {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(6, 12, 24, 0.84);
  border: 2px solid rgba(255, 255, 255, 0.88);
  font-family: var(--pixel-font);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.18);
}

.party-hud.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.party-hud-label {
  font-size: 0.42rem;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#partyHudCode {
  font-size: 0.62rem;
  color: #ffe86c;
  letter-spacing: 0.1em;
}

.touch-controls {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.touch-controls.visible {
  display: block;
}

.touch-button,
.touch-joystick {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.touch-button {
  width: 92px;
  height: 92px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.92);
  background: radial-gradient(circle at 30% 30%, rgba(255, 177, 110, 0.96), rgba(222, 60, 40, 0.92));
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.28);
  color: #fff7ee;
  font-family: var(--pixel-font);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.touch-button:active,
.touch-button.pressed {
  transform: scale(0.96);
  filter: brightness(1.06);
}

.touch-jump {
  right: 18px;
  bottom: 18px;
}

.touch-fire {
  right: 24px;
  bottom: 118px;
  width: 80px;
  height: 80px;
  font-size: 0.64rem;
  background: radial-gradient(circle at 30% 30%, rgba(255, 214, 117, 0.98), rgba(228, 86, 34, 0.92));
}

.touch-joystick {
  left: 16px;
  bottom: 16px;
  width: 126px;
  height: 126px;
}

.touch-joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.88);
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.26), rgba(17, 25, 43, 0.56));
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.26);
}

.touch-joystick-stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  margin-top: -28px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  background: radial-gradient(circle at 30% 30%, rgba(122, 255, 230, 0.92), rgba(23, 149, 144, 0.92));
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.28);
  transition: transform 80ms ease-out;
}

.hud-button {
  padding: 7px 10px;
  font-size: 0.6rem;
  border-radius: 9px;
  background: rgba(18, 20, 24, 0.82);
  box-shadow: none;
  border: 2px solid rgba(255, 255, 255, 0.88);
}

.hud-button:hover {
  transform: translateY(0);
  box-shadow: none;
  filter: brightness(1.08);
}

.hud-button:active {
  transform: translateY(1px);
  box-shadow: none;
}

.hud-fire-button {
  min-width: 78px;
  background: linear-gradient(180deg, rgba(255, 202, 95, 0.95), rgba(224, 76, 36, 0.95));
  color: #fff7ee;
  border-color: rgba(255, 242, 188, 0.95);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  background: linear-gradient(180deg, #8ce1ff 0%, #e1fbff 70%, #f9f0b3 100%);
  image-rendering: pixelated;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  background: rgba(5, 10, 25, 0.45);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(600px, 100%);
  padding: 15px 16px;
  border-radius: 12px;
  background: rgba(4, 12, 34, 0.88);
  border: 3px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}

.overlay-card p {
  margin-top: 8px;
  line-height: 1.4;
  font-size: 0.74rem;
}

.character-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.character-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 108px;
  padding: 8px 6px 7px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(180deg, rgba(24, 35, 64, 0.96), rgba(10, 16, 33, 0.96));
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.28);
  text-transform: none;
  letter-spacing: 0.04em;
}

.character-option:hover {
  transform: translateY(1px);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.28);
  filter: brightness(1.06);
}

.character-option:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.28);
}

.character-option.active {
  border-color: #ffe86c;
  background: linear-gradient(180deg, rgba(35, 75, 60, 0.98), rgba(13, 28, 30, 0.96));
  box-shadow: 0 5px 0 rgba(7, 19, 18, 0.42);
}

.character-option.locked {
  opacity: 0.62;
  filter: grayscale(0.18);
}

.character-option.locked .character-preview {
  filter: grayscale(0.15) brightness(0.94);
}

.character-preview {
  width: 48px;
  height: 64px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.18));
}

.character-preview:not([src]),
.character-preview[src=""] {
  opacity: 0;
}

.character-name {
  font-family: var(--pixel-font);
  font-size: 0.54rem;
  color: #fff7ee;
}

.character-lives {
  font-family: var(--pixel-font);
  font-size: 0.42rem;
  color: #ffe86c;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.character-status {
  font-family: var(--pixel-font);
  font-size: 0.42rem;
  color: rgba(255, 255, 255, 0.76);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.character-status:empty {
  display: none;
}

.character-option.locked .character-status {
  color: #ffb4b4;
}

.small-note {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.66rem;
}

.party-panel {
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(15, 22, 43, 0.88), rgba(10, 16, 32, 0.78));
}

.player-name-panel {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
}

.player-name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
}

.player-name-input {
  letter-spacing: 0.08em;
  text-transform: none;
  font-size: 0.58rem;
}

.party-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 6px;
  align-items: end;
}

.party-button {
  min-width: 0;
}

.party-button-secondary {
  background: linear-gradient(180deg, #4ecf75 0%, #219c49 100%);
  box-shadow: 0 6px 0 #12602d;
}

.party-button-secondary:hover {
  box-shadow: 0 5px 0 #12602d;
}

.party-button-secondary:active {
  box-shadow: 0 2px 0 #12602d;
}

.party-button-alt {
  background: linear-gradient(180deg, #59b9ff 0%, #1f75d8 100%);
  box-shadow: 0 6px 0 #154887;
}

.party-button-alt:hover {
  box-shadow: 0 5px 0 #154887;
}

.party-button-alt:active {
  box-shadow: 0 2px 0 #154887;
}

.party-button-ghost {
  padding: 7px 10px;
  font-size: 0.48rem;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.party-button-ghost:hover,
.party-button-ghost:active {
  box-shadow: none;
}

.party-button-ghost:disabled,
.party-button:disabled {
  opacity: 0.46;
  cursor: default;
  transform: none;
  filter: none;
}

.party-join-group {
  display: grid;
  gap: 5px;
}

.party-input-label {
  font-family: var(--pixel-font);
  font-size: 0.42rem;
  color: rgba(255, 255, 255, 0.74);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.party-join-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
}

.party-code-input {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: rgba(4, 10, 21, 0.9);
  color: #fff8ee;
  font-family: var(--pixel-font);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  outline: none;
}

.party-code-input:focus {
  border-color: #ffe86c;
  box-shadow: 0 0 0 3px rgba(255, 232, 108, 0.16);
}

.party-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.party-code-card {
  display: grid;
  gap: 4px;
}

.party-meta-label {
  font-family: var(--pixel-font);
  font-size: 0.4rem;
  color: rgba(255, 255, 255, 0.66);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.party-code-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 6px 8px 5px;
  border-radius: 8px;
  background: rgba(255, 232, 108, 0.14);
  border: 2px solid rgba(255, 232, 108, 0.36);
  font-family: var(--pixel-font);
  font-size: 0.62rem;
  color: #ffe86c;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.party-meta-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.party-status-text {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.62rem;
}

.party-roster {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
  min-height: 20px;
}

.party-roster-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.12);
  font-family: var(--pixel-font);
  font-size: 0.42rem;
  color: #fff8ee;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.party-roster-pill strong {
  color: #ffe86c;
  font-weight: 400;
}

.friends-panel {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 2px solid rgba(255, 255, 255, 0.12);
}

.friends-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(220px, 0.9fr);
  gap: 8px;
}

.friends-card {
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.friends-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.friends-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
  margin-top: 5px;
}

.friends-name-input {
  letter-spacing: 0.08em;
  text-transform: none;
  font-size: 0.58rem;
}

.friends-note {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.58rem;
}

.friends-list {
  display: grid;
  gap: 5px;
  margin-top: 6px;
  align-content: start;
  min-height: 60px;
}

.friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.12);
}

.friend-name {
  min-width: 0;
  font-family: var(--pixel-font);
  font-size: 0.46rem;
  color: #fff8ee;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.friend-action-button {
  padding: 6px 9px;
  font-size: 0.44rem;
  box-shadow: 0 4px 0 var(--button-shadow);
}

.friend-action-button:hover {
  box-shadow: 0 3px 0 var(--button-shadow);
}

.friend-action-button:active {
  box-shadow: 0 1px 0 var(--button-shadow);
}

.friend-remove-button {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.friend-remove-button:hover,
.friend-remove-button:active {
  box-shadow: none;
}

.friends-empty {
  padding: 6px 0 2px;
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.6rem;
}

button {
  border: 0;
  border-radius: 9px;
  padding: 8px 13px;
  font-family: var(--pixel-font);
  font-size: 0.58rem;
  font-weight: 700;
  color: #fff8ee;
  cursor: pointer;
  background: linear-gradient(180deg, #ff705d 0%, var(--button) 100%);
  box-shadow: 0 4px 0 var(--button-shadow);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

button:hover {
  transform: translateY(1px);
  box-shadow: 0 3px 0 var(--button-shadow);
  filter: saturate(1.1);
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--button-shadow);
}

.bottom-bar {
  display: none;
}

.toast {
  position: absolute;
  left: 50%;
  top: 58px;
  transform: translateX(-50%) translateY(-12px);
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(10, 10, 12, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.15);
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-family: var(--pixel-font);
  font-size: 0.6rem;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 860px) {
  body {
    padding: 0;
  }

  .party-row {
    grid-template-columns: 1fr;
  }

  .party-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .party-meta-actions {
    justify-content: stretch;
  }

  .party-button-ghost {
    flex: 1 1 0;
  }

  .character-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .character-option {
    min-height: 116px;
  }
}

@media (max-width: 620px) {
  .character-picker {
    grid-template-columns: 1fr;
  }

  .party-join-controls {
    grid-template-columns: 1fr;
  }

  .friends-add-row {
    grid-template-columns: 1fr;
  }

  .player-name-row {
    grid-template-columns: 1fr;
  }

  .friends-layout {
    grid-template-columns: 1fr;
  }

  .friend-row {
    align-items: stretch;
    flex-direction: column;
  }

  .friend-actions {
    width: 100%;
  }

  .friend-action-button {
    flex: 1 1 0;
  }
}

@media (pointer: coarse) {
  .hud-actions {
    right: 14px;
    top: 14px;
    bottom: auto;
  }

  .hud-button {
    padding: 10px 12px;
  }
}
