html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #26150f;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  font-family: Inter, ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#game-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 210, 136, 0.12), transparent 34rem),
    linear-gradient(180deg, #3a1e14 0%, #20100c 100%);
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
  cursor: pointer;
}

#instructions {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}


#network-open {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  border: 2px solid #7a4526;
  border-radius: 999px;
  padding: 9px 14px;
  background: #fff0cf;
  color: #63321f;
  font: 900 12px/1 ui-rounded, system-ui, sans-serif;
  box-shadow: 0 4px 14px rgba(24, 10, 7, 0.35);
  touch-action: manipulation;
}

#network-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 12px;
  touch-action: manipulation;
}

#network-panel[hidden],
#network-open[hidden] {
  display: none !important;
}

.network-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 15, 11, 0.72);
}

.network-card {
  position: relative;
  width: min(440px, calc(100vw - 24px));
  max-height: min(720px, calc(100vh - 24px));
  overflow-y: auto;
  border: 3px solid #754122;
  border-radius: 24px;
  background: #fff1d0;
  color: #63321f;
  box-shadow: 0 12px 36px rgba(24, 10, 7, 0.45);
  padding: 18px;
  box-sizing: border-box;
  user-select: text;
  -webkit-user-select: text;
}

.network-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.network-header h2 {
  margin: 0;
  color: #c8573d;
  font: 900 24px/1.1 ui-rounded, system-ui, sans-serif;
}

.network-header p,
.network-note,
.network-empty {
  margin: 4px 0 0;
  color: #96664a;
  font: 650 12px/1.35 ui-rounded, system-ui, sans-serif;
}

#network-close {
  border: 0;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  background: #c8573d;
  color: #fff5dc;
  font: 900 22px/1 ui-rounded, system-ui, sans-serif;
}

#network-status {
  min-height: 18px;
  margin: 4px 0 8px;
  color: #5f8f3e;
  font: 800 12px/1.35 ui-rounded, system-ui, sans-serif;
}

#network-status.network-error {
  color: #b33d31;
}

.network-section {
  margin-top: 12px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(111, 60, 32, 0.075);
}

.network-section[hidden] {
  display: none !important;
}

.network-section h3 {
  margin: 0 0 8px;
  font: 900 14px/1.2 ui-rounded, system-ui, sans-serif;
}

.network-section form,
.network-profile-top,
.network-code-row,
.network-leaderboard-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.network-profile-top,
.network-code-row {
  justify-content: space-between;
  margin-bottom: 8px;
}

.network-leaderboard-controls {
  flex-wrap: wrap;
  align-items: flex-end;
}

.network-leaderboard-controls label {
  display: grid;
  gap: 3px;
  color: #82543a;
  font: 800 10px/1.2 ui-rounded, system-ui, sans-serif;
}

.network-label {
  display: block;
  color: #96664a;
  font: 800 10px/1.2 ui-rounded, system-ui, sans-serif;
  text-transform: uppercase;
}

#network-friend-code {
  color: #c8573d;
  font: 900 21px/1.1 ui-monospace, monospace;
  letter-spacing: 2px;
}

.network-section input,
.network-section select {
  min-width: 0;
  border: 2px solid rgba(117, 65, 34, 0.28);
  border-radius: 10px;
  background: #fff9e9;
  color: #63321f;
  padding: 8px 9px;
  font: 750 14px/1.2 ui-rounded, system-ui, sans-serif;
  box-sizing: border-box;
  user-select: text;
  -webkit-user-select: text;
}

.network-section input[type="date"] {
  width: 132px;
}

.network-section select {
  width: 92px;
}

.network-section form input {
  flex: 1;
}

.network-section button {
  border: 0;
  border-radius: 10px;
  padding: 9px 11px;
  background: #c8573d;
  color: #fff5dc;
  font: 900 11px/1 ui-rounded, system-ui, sans-serif;
  white-space: nowrap;
  touch-action: manipulation;
}

.network-section button:active,
#network-open:active,
#network-close:active {
  transform: translateY(1px);
}

.network-small-button {
  background: #9a6a43 !important;
}

.network-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.network-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 12px;
  background: rgba(255, 249, 233, 0.78);
  padding: 9px 10px;
}

.network-row > div {
  display: grid;
  min-width: 0;
}

.network-row strong {
  overflow: hidden;
  color: #63321f;
  font: 900 12px/1.25 ui-rounded, system-ui, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.network-row span {
  color: #96664a;
  font: 700 10px/1.25 ui-rounded, system-ui, sans-serif;
}

.network-score-row {
  display: grid;
  grid-template-columns: 38px 1fr auto;
}

.network-rank {
  color: #c8573d !important;
  font: 900 12px/1 ui-rounded, system-ui, sans-serif !important;
}

.network-score {
  color: #c8573d !important;
  font-size: 15px !important;
}

@media (max-width: 390px) {
  .network-card {
    padding: 14px;
  }

  .network-profile-top,
  .network-code-row {
    align-items: stretch;
    flex-direction: column;
  }

  .network-section input[type="date"] {
    width: 122px;
  }
}
