:root {
  color-scheme: dark;
  font-family: "Courier New", Courier, monospace;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, #1f2937, #0b1220 50%, #030712);
  color: #e5e7eb;
}

.app {
  width: min(860px, 100%);
  padding: 1rem;
  text-align: center;
}

#connectionStatus {
  color: #93c5fd;
  min-height: 1.25rem;
  margin: 0.25rem 0 0.5rem;
}

#appVersion {
  display: block;
  color: #94a3b8;
  margin-bottom: 0.2rem;
}

#appGithubLinkWrap {
  display: block;
  margin-bottom: 0.5rem;
}

#appGithubLink {
  color: #93c5fd;
}

#appGithubLink:visited {
  color: #bfdbfe;
}

#appFooter {
  margin-top: 0.5rem;
}

.updates-section {
  color: #94a3b8;
  text-align: left;
  width: fit-content;
  margin: 0 auto;
}

.updates-section h2 {
  color: #cbd5e1;
  font-size: 1rem;
  margin: 0.35rem 0;
}

#helpToggle,
#updatesToggle {
  margin-bottom: 0.35rem;
}

#updatesPanel h3 {
  color: #cbd5e1;
  font-size: 0.95rem;
  margin: 0.35rem 0 0.2rem;
}

#updatesPanel ul {
  margin: 0 0 0.5rem 1.1rem;
  padding: 0;
}

#deviceSummary {
  color: #94a3b8;
  margin: 0 auto 0.75rem;
  min-height: 2.4rem;
}

#deviceSummary p {
  margin: 0.15rem 0;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  align-items: center;
}

#authModeSeparator {
  color: #94a3b8;
}

.auth-panel {
  width: min(460px, 95vw);
  margin: 0 auto 0.75rem;
  padding: 0.65rem;
  border: 1px solid #334155;
  border-radius: 0.6rem;
  background: rgb(17 24 39 / 60%);
}

.auth-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: #cbd5e1;
}

.auth-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.35rem 0;
}

.auth-row label {
  color: #cbd5e1;
  min-width: 135px;
  text-align: right;
}

.auth-row input {
  background: #111827;
  color: #e5e7eb;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  padding: 0.4rem 0.6rem;
  width: min(280px, 60vw);
}

.auth-hint {
  color: #94a3b8;
  margin: 0.35rem 0 0.5rem;
  font-size: 0.92rem;
}

#authSessionText {
  margin: 0;
  color: #cbd5e1;
}

.nickname-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.nickname-row label {
  color: #cbd5e1;
}

.nickname-row input {
  background: #111827;
  color: #e5e7eb;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  padding: 0.4rem 0.6rem;
  width: min(320px, 70vw);
}

button,
select {
  background: #1d4ed8;
  color: white;
  border: 1px solid #3b82f6;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
}

button:hover {
  background: #1e40af;
}

button:disabled {
  background: #475569;
  border-color: #64748b;
  cursor: not-allowed;
}

canvas {
  background: #111827;
  border: 2px solid #60a5fa;
  border-radius: 8px;
  box-shadow: 0 0 20px rgb(96 165 250 / 35%);
}

#status {
  height: 2rem;
  color: #86efac;
  margin-bottom: 0.75rem;
}

#instructions {
  color: #94a3b8;
  text-align: left;
  margin: 0.35rem auto 0;
  width: fit-content;
}

#instructions h3 {
  color: #cbd5e1;
  font-size: 0.95rem;
  margin: 0.35rem 0 0.2rem;
}

.hidden {
  display: none !important;
}

#settingsModal {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 70%);
  display: grid;
  place-items: center;
}

.modal-content {
  min-width: 300px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 0.75rem;
  padding: 1rem;
  display: grid;
  gap: 0.5rem;
}

/* ── Mobile controls panel ─────────────────────────────────────────────── */

/* Hide on pointer:fine (mouse) devices; show on touch screens */
@media (hover: hover) and (pointer: fine) {
  .mobile-controls {
    display: none;
  }
}

/* Extra bottom padding so the fixed panel doesn't cover footer content */
@media not all and (hover: hover) and (pointer: fine) {
  .app {
    padding-bottom: 3rem;
  }
}

.mobile-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgb(15 23 42 / 95%);
  border-top: 1px solid #334155;
  z-index: 100;
}

.mobile-toggle-btn {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  color: #e5e7eb;
  font-family: inherit;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.mobile-controls-body {
  display: none;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.75rem 1rem 1rem;
  align-items: flex-start;
  justify-content: center;
}

.mobile-controls[data-expanded="true"] .mobile-controls-body {
  display: flex;
}

/* D-pad: 3×3 cross layout */
.dpad {
  display: grid;
  grid-template-areas:
    ". up ."
    "left mid right"
    ". down .";
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 2px;
}

.dpad-btn {
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 6px;
  color: #e5e7eb;
  font-size: 1.1rem;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dpad-btn:active {
  background: #334155;
}

.dpad-up    { grid-area: up; }
.dpad-left  { grid-area: left; }
.dpad-center { grid-area: mid; }
.dpad-right { grid-area: right; }
.dpad-down  { grid-area: down; }

/* Action buttons row */
.mobile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.mobile-action-btn {
  min-height: 48px;
  padding: 0.25rem 0.75rem;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 6px;
  color: #e5e7eb;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.mobile-action-btn:active {
  background: #334155;
}

.mobile-action-btn--wide {
  flex: 1 0 100%;
}
