@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

body,
html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  overflow: hidden;
  font-family: "Press Start 2P", Courier, monospace;
  color: white;
  user-select: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #050508;
  image-rendering: pixelated;
}

.scanlines {
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  background-size: 100% 4px, 6px 100%;
  box-shadow: inset 0 0 150px rgba(0, 0, 0, 0.95);
  pointer-events: none;
  z-index: 100;
}

#menu-ui {
  position: absolute;
  inset: 0;
}

.menu-top-left-actions {
  position: absolute;
  left: 28px;
  top: 24px;
  display: flex;
  gap: 12px;
  z-index: 3;
}

.menu-corner-actions {
  position: absolute;
  right: 28px;
  bottom: 24px;
  display: flex;
  gap: 12px;
  z-index: 3;
}

.menu-corner-button {
  border: 3px solid #00ffcc;
  background: rgba(0, 0, 0, 0.82);
  color: #00ffcc;
  font: inherit;
  font-size: 0.58rem;
  padding: 12px 16px;
  box-shadow: 6px 6px 0 rgba(0, 255, 204, 0.45);
  cursor: pointer;
}

.music-toggle-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 172px;
}

.music-toggle-icon {
  position: relative;
  width: 32px;
  height: 22px;
  display: inline-block;
  flex: 0 0 auto;
}

.music-toggle-speaker {
  position: absolute;
  left: 0;
  top: 6px;
  width: 11px;
  height: 10px;
  background: currentColor;
}

.music-toggle-speaker::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 2px;
  width: 5px;
  height: 6px;
  background: currentColor;
}

.music-toggle-speaker::after {
  content: "";
  position: absolute;
  left: 11px;
  top: -3px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 10px solid currentColor;
}

.music-toggle-wave {
  position: absolute;
  border: 3px solid currentColor;
  border-left: 0;
  border-bottom: 0;
  border-radius: 0 999px 0 0;
  transform: rotate(45deg);
  transform-origin: center;
}

.music-toggle-wave-one {
  left: 18px;
  top: 7px;
  width: 7px;
  height: 7px;
}

.music-toggle-wave-two {
  left: 21px;
  top: 2px;
  width: 13px;
  height: 13px;
}

.music-toggle-slash {
  position: absolute;
  left: 21px;
  top: -1px;
  width: 4px;
  height: 24px;
  background: transparent;
  transform: rotate(38deg);
  opacity: 0;
}

.music-toggle-slash::before {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.music-toggle-label {
  display: inline-block;
  min-width: 92px;
  text-align: left;
}

.menu-corner-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0 rgba(0, 255, 204, 0.65);
}

.menu-corner-button.is-muted {
  border-color: #ff00ff;
  color: #ff9df5;
  box-shadow: 6px 6px 0 rgba(255, 0, 255, 0.35);
}

.music-toggle-button.is-muted .music-toggle-wave {
  opacity: 0;
}

.music-toggle-button.is-muted .music-toggle-slash {
  opacity: 1;
}

.legal-modal {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.72);
  z-index: 40;
}

.legal-modal.is-open {
  display: flex;
}

.legal-card {
  width: min(860px, 94vw);
  max-height: min(760px, 88vh);
  overflow: auto;
  border: 4px solid #00ffcc;
  background: rgba(4, 8, 14, 0.96);
  box-shadow: 0 0 34px rgba(0, 255, 204, 0.22);
  padding: 22px 22px 18px;
}

.legal-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.legal-card-title {
  color: #ffffff;
  font-size: 1rem;
  text-shadow: 0 0 12px rgba(0, 255, 204, 0.35);
}

.legal-close-btn {
  min-width: 132px;
  font-size: 0.62rem;
}

.legal-card-body {
  font-size: 0.68rem;
  line-height: 2.1;
  color: #cfe6df;
}

.legal-card-body p {
  margin: 0 0 14px;
}

.legal-card-body a {
  color: #00ffcc;
}

#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
  flex-direction: column;
  justify-content: space-between;
  padding-bottom: 30px;
  box-sizing: border-box;
  z-index: 10;
}

.opponent-indicator {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  display: none;
  z-index: 80;
  pointer-events: none;
}

.opponent-indicator.is-visible {
  display: block;
}

.opponent-indicator-pulse {
  margin-left: -29px;
  margin-top: -20px;
  animation: opponent-indicator-pulse 1s ease-in-out infinite;
  transform-origin: center;
}

.opponent-indicator-arrow {
  width: 58px;
  height: 40px;
  background: #33ccff;
  clip-path: polygon(100% 50%, 18% 0, 30% 50%, 18% 100%);
  box-shadow: 0 0 18px rgba(51, 204, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

.opponent-indicator-arrow-core {
  width: 36px;
  height: 22px;
  background: #ffffff;
  clip-path: polygon(100% 50%, 16% 0, 30% 50%, 16% 100%);
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.9));
}

@keyframes opponent-indicator-pulse {
  0%,
  100% {
    transform: scale(0.9);
  }
  50% {
    transform: scale(1.15);
  }
}

.hud-container {
  display: flex;
  justify-content: space-between;
  padding: 15px 40px;
  align-items: flex-end;
}

.post-match-overlay {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.post-match-card {
  width: min(680px, 92vw);
  padding: 26px 24px;
  background: rgba(4, 6, 10, 0.94);
  border: 4px solid #00ffcc;
  box-shadow: 0 0 30px rgba(0, 255, 204, 0.24);
  text-align: center;
  pointer-events: all;
  position: relative;
}

.post-match-topbar {
  display: flex;
  justify-content: flex-start;
}

.post-match-back-btn {
  margin: 0;
  padding: 12px 20px;
  font-size: 0.7rem;
  box-shadow: 6px 6px 0 #33ccff;
}

.post-match-title {
  font-size: 1rem;
  color: #ffffff;
  text-shadow: 0 0 12px rgba(0, 255, 204, 0.45);
}

.post-match-subtitle {
  margin-top: 18px;
  font-size: 0.58rem;
  line-height: 1.8;
  color: #b9cbc9;
}

.post-match-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
  pointer-events: all;
}

.post-match-actions .top-btn {
  min-width: 220px;
}

.post-match-players {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.post-match-player-card {
  width: min(240px, 42vw);
  min-height: 168px;
  background: rgba(0, 0, 0, 0.72);
  border: 4px solid #ffffff;
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.12);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.post-match-player-you {
  border-color: #ff3366;
  box-shadow: 0 0 18px rgba(255, 51, 102, 0.18);
}

.post-match-player-opponent {
  border-color: #33ccff;
  box-shadow: 0 0 18px rgba(51, 204, 255, 0.18);
}

.post-match-player-label {
  font-size: 0.55rem;
  color: #b8c9d9;
}

.post-match-player-name {
  font-size: 0.75rem;
  line-height: 1.6;
  word-break: break-word;
}

.player-card-skin-preview {
  width: 72px;
  height: 72px;
  display: block;
  image-rendering: pixelated;
}

.post-match-player-ready {
  min-height: 1.2rem;
  font-size: 0.6rem;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.35);
}

.top-btn.is-disabled {
  opacity: 0.55;
  filter: grayscale(0.15);
  cursor: default;
  transform: none;
  box-shadow: 8px 8px 0 #444;
}

.player-hud {
  text-align: center;
  background: rgba(0, 0, 0, 0.85);
  padding: 6px 12px;
  border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2), 3px 3px 0 rgba(0, 0, 0, 0.9);
  min-width: 140px;
}

#p1-hud {
  border-color: #ff3366;
  box-shadow: 0 0 10px rgba(255, 51, 102, 0.4), 3px 3px 0 rgba(0, 0, 0, 0.9);
}

#p2-hud {
  border-color: #33ccff;
  box-shadow: 0 0 10px rgba(51, 204, 255, 0.4), 3px 3px 0 rgba(0, 0, 0, 0.9);
}

.name {
  font-size: 0.5rem;
  margin-bottom: 3px;
  color: #fff;
}

#p1-name {
  color: #ff3366;
  text-shadow: 0 0 10px #ff3366;
}

#p2-name {
  color: #33ccff;
  text-shadow: 0 0 10px #33ccff;
}

.status {
  font-size: 0.9rem;
  text-shadow: 2px 2px 0 #000;
  margin: 4px 0;
}

.dash-count {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 6px;
}

.dash-bar {
  width: 14px;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #555;
}

.dash-bar.filled {
  background: #00ffcc;
  border-color: #fff;
  box-shadow: 0 0 5px #00ffcc;
}

#global-timer {
  font-size: 1.5rem;
  background: rgba(0, 0, 0, 0.85);
  padding: 8px 18px;
  border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3), 3px 3px 0 #000;
  color: #fff;
  text-shadow: 0 0 8px #fff;
}

.controls-overlay {
  display: flex;
  justify-content: flex-start;
  gap: 20px;
  padding: 20px 40px;
  font-size: 0.7rem;
  line-height: 1.6;
  position: absolute;
  bottom: 30px;
  width: 100%;
  box-sizing: border-box;
  pointer-events: none;
}

.ctrl-box {
  background: rgba(0, 0, 0, 0.7);
  padding: 15px 25px;
  border: 4px solid #555;
  box-shadow: 6px 6px 0 #000;
  text-align: left;
}

.ctrl-box p {
  margin: 8px 0;
}

.highlight {
  color: #ffd700;
  text-shadow: 0 0 8px #ffd700;
}

#menu-ui,
#network-ui {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  pointer-events: all;
}

#network-ui {
  display: none;
  overflow: hidden;
}

.main-title {
  color: #ff00ff;
  text-shadow: 0 0 20px #ff00ff, 6px 6px 0 #000;
  font-size: 4rem;
  margin-bottom: 60px;
  text-align: center;
}

.menu-btn-small {
  padding: 12px 24px;
  margin-top: -2px;
  margin-bottom: 4px;
  font-size: 0.72rem;
}

.friend-mode-panel {
  display: none;
  width: min(520px, calc(100vw - 40px));
  margin: 6px 0 10px;
  padding: 16px 18px 14px;
  border: 3px solid rgba(51, 204, 255, 0.5);
  background: rgba(3, 7, 18, 0.88);
  box-shadow: 0 0 24px rgba(51, 204, 255, 0.12);
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.friend-mode-panel.is-open {
  display: flex;
}

.friend-mode-title {
  color: #33ccff;
  font-size: 0.7rem;
  text-align: center;
  text-shadow: 0 0 10px rgba(51, 204, 255, 0.45);
}

.friend-mode-actions,
.friend-mode-join-row {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.friend-mode-action-btn {
  padding: 12px 18px;
  margin: 0;
  font-size: 0.62rem;
  box-shadow: 6px 6px 0 #33ccff;
}

.friend-mode-divider {
  color: #8ea9c7;
  font-size: 0.55rem;
}

#friend-code-input {
  width: min(180px, 100%);
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.92);
  color: #fff;
  border: 3px solid #33ccff;
  padding: 12px 14px;
  font-family: "Press Start 2P";
  font-size: 0.7rem;
  text-align: center;
  letter-spacing: 0.28rem;
  box-shadow: 6px 6px 0 #11253e;
  outline: none;
}

#friend-code-input::placeholder {
  color: rgba(183, 215, 255, 0.45);
  letter-spacing: 0.28rem;
}

#friend-code-input:focus {
  border-color: #00ffcc;
  box-shadow: 6px 6px 0 #003b38;
}

.friend-mode-hint {
  min-height: 1.2rem;
  color: #a7b5cc;
  font-size: 0.5rem;
  line-height: 1.6;
  text-align: center;
}

.friend-mode-hint.is-error {
  color: #ff7b96;
  text-shadow: 0 0 10px rgba(255, 51, 102, 0.2);
}

.identity-entry {
  display: flex;
  flex-direction: row;
  gap: 14px;
  align-items: center;
  width: auto;
  margin: 16px 0 12px;
  z-index: 3;
}

.name-entry,
.skin-entry {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.name-entry {
  flex: none;
  width: min(220px, 28vw);
}

.skin-entry {
  flex: none;
  width: auto;
}

.name-entry label,
.skin-entry label {
  color: #00ffcc;
  font-size: 0.75rem;
  text-shadow: 0 0 10px #00ffcc;
}

.name-entry input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.92);
  color: #fff;
  border: 4px solid #00ffcc;
  padding: 14px 16px;
  font-family: "Press Start 2P";
  font-size: 0.72rem;
  box-shadow: 8px 8px 0 #003b38;
  outline: none;
}

.name-entry input::placeholder {
  color: rgba(111, 217, 207, 0.55);
}

.skin-picker {
  width: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.name-entry input:focus {
  border-color: #ff00ff;
  box-shadow: 8px 8px 0 #3d003d;
}

.skin-picker-btn {
  flex: 0 0 28px;
  height: 56px;
  border: 4px solid #00ffcc;
  background: rgba(0, 0, 0, 0.92);
  color: #00ffcc;
  font: inherit;
  font-size: 0.58rem;
  line-height: 1;
  box-shadow: 6px 6px 0 #003b38;
  cursor: pointer;
  padding: 0;
}

.skin-picker-btn:hover {
  border-color: #ff00ff;
  color: #ff9df5;
  box-shadow: 6px 6px 0 #3d003d;
}

.skin-preview-card {
  flex: none;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.skin-preview-canvas {
  width: 54px;
  height: 54px;
  display: block;
  image-rendering: pixelated;
}

.skin-preview-name {
  font-size: 0.46rem;
  color: #ffffff;
  text-align: center;
}

@media (max-width: 780px) {
  .identity-entry {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 14px 0 10px;
  }

  .name-entry {
    width: min(220px, 62vw);
  }

  .skin-entry {
    flex-basis: auto;
  }

  .skin-picker-btn {
    flex-basis: 24px;
    height: 48px;
  }
}

.debug-only {
  display: none;
}

.match-found-intro {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 42px;
  background: radial-gradient(circle at center, rgba(35, 8, 49, 0.85), rgba(0, 0, 0, 0.92));
  z-index: 20;
  pointer-events: none;
}

.match-found-intro.active {
  display: flex;
}

.match-found-title {
  font-size: 1.1rem;
  color: #ffd700;
  text-shadow: 0 0 16px #ffd700;
  opacity: 0;
  transform: translateY(-18px) scale(0.9);
}

.match-found-stage {
  display: flex;
  align-items: center;
  gap: 34px;
}

.match-player-card {
  width: 260px;
  min-height: 210px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(0, 0, 0, 0.86);
  border: 4px solid #fff;
  box-shadow: 12px 12px 0 rgba(0, 0, 0, 0.7);
  opacity: 0;
}

.match-player-left {
  border-color: #ff3366;
  box-shadow: 0 0 18px rgba(255, 51, 102, 0.45), 12px 12px 0 rgba(0, 0, 0, 0.7);
  transform: translateX(-220px) rotate(-8deg) scale(0.88);
}

.match-player-right {
  border-color: #33ccff;
  box-shadow: 0 0 18px rgba(51, 204, 255, 0.45), 12px 12px 0 rgba(0, 0, 0, 0.7);
  transform: translateX(220px) rotate(8deg) scale(0.88);
}

.match-player-label {
  font-size: 0.65rem;
  color: #ffffff;
  opacity: 0.75;
}

.match-player-name {
  font-size: 0.95rem;
  line-height: 1.45;
  text-align: center;
  max-width: 200px;
  word-break: break-word;
}

.match-player-left .match-player-name {
  color: #ff3366;
  text-shadow: 0 0 14px #ff3366;
}

.match-player-right .match-player-name {
  color: #33ccff;
  text-shadow: 0 0 14px #33ccff;
}

.match-found-vs {
  font-size: 2.4rem;
  color: #ffffff;
  text-shadow: 0 0 20px #ffffff;
  opacity: 0;
  transform: scale(0.45);
}

.match-found-intro.active .match-found-title {
  animation: match-found-title-in 0.35s ease-out forwards;
}

.match-found-intro.active .match-player-left {
  animation: match-player-left-in 0.55s cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

.match-found-intro.active .match-player-right {
  animation: match-player-right-in 0.55s cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

.match-found-intro.active .match-found-vs {
  animation: match-found-vs-in 0.42s ease-out 0.18s forwards;
}

@keyframes match-found-title-in {
  from {
    opacity: 0;
    transform: translateY(-18px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes match-player-left-in {
  from {
    opacity: 0;
    transform: translateX(-220px) rotate(-8deg) scale(0.88);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotate(-2deg) scale(1);
  }
}

@keyframes match-player-right-in {
  from {
    opacity: 0;
    transform: translateX(220px) rotate(8deg) scale(0.88);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotate(2deg) scale(1);
  }
}

@keyframes match-found-vs-in {
  from {
    opacity: 0;
    transform: scale(0.45);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.menu-btn,
.top-btn {
  background: #000;
  color: #fff;
  border: 4px solid #fff;
  padding: 20px 40px;
  font-family: "Press Start 2P";
  font-size: 1.2rem;
  cursor: pointer;
  margin: 12px;
  box-shadow: 8px 8px 0 #ff00ff;
  transition: all 0.1s;
}

.menu-btn:hover,
.top-btn:hover {
  background: #fff;
  color: #000;
  box-shadow: 8px 8px 0 #00ffcc;
  transform: translate(-2px, -2px);
}

.menu-btn:active,
.top-btn:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 #000;
}

.difficulty-row {
  display: flex;
  gap: 10px;
  margin-top: -6px;
  margin-bottom: 10px;
}

.difficulty-btn {
  background: #000;
  color: #aaa;
  border: 2px solid #555;
  padding: 10px 14px;
  font-family: "Press Start 2P";
  font-size: 0.7rem;
  cursor: pointer;
  box-shadow: 4px 4px 0 #111;
  transition: all 0.1s;
}

.difficulty-btn:hover {
  color: #fff;
  border-color: #00ffcc;
  transform: translate(-1px, -1px);
}

.difficulty-btn.active {
  color: #000;
  background: #00ffcc;
  border-color: #00ffcc;
  box-shadow: 4px 4px 0 #ff00ff;
}

.cpu-config {
  width: min(520px, calc(100vw - 40px));
  margin: 6px 0 10px;
  padding: 14px 14px 10px;
  border: 3px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.55);
  box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
}

.cpu-config-title {
  font-family: "Press Start 2P";
  font-size: 0.9rem;
  color: #fff;
  margin-bottom: 10px;
  text-align: center;
  letter-spacing: 1px;
}

.cpu-config-section {
  margin-bottom: 10px;
}

.cpu-config-label {
  font-family: "Press Start 2P";
  font-size: 0.6rem;
  color: #aaa;
  margin-bottom: 6px;
}

.cpu-choice-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.cpu-choice-btn {
  background: #000;
  color: #aaa;
  border: 2px solid #555;
  padding: 10px 14px;
  font-family: "Press Start 2P";
  font-size: 0.7rem;
  cursor: pointer;
  box-shadow: 4px 4px 0 #111;
  transition: all 0.1s;
}

.cpu-choice-btn:hover {
  color: #fff;
  border-color: #33ccff;
  transform: translate(-1px, -1px);
}

.cpu-choice-btn.active {
  color: #000;
  background: #33ccff;
  border-color: #33ccff;
  box-shadow: 4px 4px 0 #ff00ff;
}

.cpu-choice-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.cpu-config-hint {
  font-family: "Press Start 2P";
  font-size: 0.55rem;
  color: #aaa;
  margin-top: 2px;
  min-height: 14px;
}

#editor-ui {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  pointer-events: none;
}

.editor-sidebar {
  pointer-events: all;
  position: absolute;
  left: 0;
  top: 0;
  width: 240px;
  height: 100%;
  background: rgba(10, 10, 15, 0.95);
  border-right: 4px solid #fff;
  padding: 15px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-sizing: border-box;
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.8);
}

.editor-topbar {
  pointer-events: all;
  position: absolute;
  top: 0;
  left: 240px;
  width: calc(100% - 240px);
  display: flex;
  gap: 15px;
  padding: 20px;
  align-items: center;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 100%);
  flex-wrap: wrap;
}

.tool-btn {
  background: #000;
  color: #aaa;
  border: 2px solid #444;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-family: "Press Start 2P";
  font-size: 0.55rem;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
  border-radius: 4px;
}

.tool-btn:hover {
  background: #151515;
  color: #fff;
  border-color: #888;
  transform: translateX(4px);
}

.tool-btn.active {
  background: #0a1a1a;
  color: #fff;
  border-color: #00ffcc;
  box-shadow: 0 0 12px rgba(0, 255, 204, 0.4);
  transform: translateX(4px);
}

.tool-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
}

#btn-exit-test {
  display: none;
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: #ff0000;
  color: #fff;
  border: 4px solid #fff;
  padding: 15px 30px;
  font-family: "Press Start 2P";
  font-size: 1rem;
  cursor: pointer;
  pointer-events: all;
  box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: all;
}

.modal-content,
.network-card {
  background: #050508;
  border: 4px solid #00ffcc;
  padding: 18px;
  width: min(620px, 90vw);
  box-shadow: 0 0 30px rgba(0, 255, 204, 0.3);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-content textarea {
  width: 100%;
  min-height: 150px;
  background: #000;
  color: #00ffcc;
  border: 2px solid #555;
  font-family: monospace;
  font-size: 14px;
  padding: 10px;
  box-sizing: border-box;
  resize: vertical;
  outline: none;
}

#editor-status-msg {
  color: #00ffcc;
  text-shadow: 0 0 10px #00ffcc;
  font-size: 0.8rem;
  margin-left: 10px;
  transition: opacity 0.3s;
  opacity: 0;
}

.network-status {
  color: #00ffcc;
  font-size: 0.78rem;
  min-height: 1.4rem;
  text-align: center;
  text-shadow: 0 0 10px rgba(0, 255, 204, 0.5);
}

.network-heading {
  text-align: center;
}

.network-subheading {
  margin-top: 8px;
  min-height: 0.7rem;
  color: #8ea9c7;
  font-size: 0.52rem;
}

.friend-network-panel {
  display: none;
  padding: 14px 12px 12px;
  border: 2px solid #27436d;
  background: rgba(7, 15, 30, 0.9);
  text-align: center;
  gap: 10px;
  flex-direction: column;
  align-items: center;
}

.friend-network-panel.is-visible {
  display: flex;
}

.friend-network-label {
  color: #8ea9c7;
  font-size: 0.5rem;
}

.friend-network-code {
  color: #ffffff;
  font-size: 1.28rem;
  letter-spacing: 0.34rem;
  text-shadow: 0 0 14px rgba(51, 204, 255, 0.45);
}

.friend-network-hint {
  color: #b9c7d9;
  font-size: 0.5rem;
  line-height: 1.6;
  max-width: 420px;
}

.friend-network-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.friend-network-btn {
  margin: 0;
  padding: 12px 18px;
  font-size: 0.6rem;
  box-shadow: 6px 6px 0 #33ccff;
}

.network-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.network-metric {
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid #173a37;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: inset 0 0 18px rgba(0, 255, 204, 0.06);
}

.network-metric-label {
  color: #7aa8a1;
  font-size: 0.52rem;
}

.network-metric-value {
  color: #fff;
  font-size: 0.72rem;
}

.network-mini-game-shell {
  background: rgba(0, 0, 0, 0.72);
  border: 3px solid #222f45;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.network-mini-game-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.network-mini-game-title,
.network-mini-game-score {
  font-size: 0.56rem;
}

.network-mini-game-title {
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.45);
}

.network-mini-game-score {
  color: #8fbdb7;
}

#network-mini-game {
  width: 100%;
  max-width: 420px;
  align-self: center;
  height: auto;
  background: linear-gradient(180deg, rgba(5, 15, 25, 0.95), rgba(7, 7, 10, 1));
  border: 3px solid #00ffcc;
  box-shadow: 0 0 20px rgba(0, 255, 204, 0.15);
  image-rendering: pixelated;
}

.network-mini-game-hint {
  color: #9d9d9d;
  font-size: 0.5rem;
  text-align: center;
  line-height: 1.5;
}

@media (max-width: 760px) {
  .network-metrics {
    grid-template-columns: 1fr;
  }

  .network-heading,
  .network-mini-game-head {
    justify-content: center;
    text-align: center;
  }

  .friend-network-code {
    font-size: 1rem;
    letter-spacing: 0.2rem;
  }
}

@media (max-width: 780px) {
  .friend-mode-panel {
    width: min(440px, calc(100vw - 32px));
  }

  .friend-mode-join-row {
    flex-direction: column;
  }

  #friend-code-input {
    width: min(220px, 100%);
  }
}
