* {
  box-sizing: border-box;
  touch-action: manipulation;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: #14151a;
  color: #e8e8ea;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

h1 {
  font-size: 1.1rem;
  margin: 0;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.status {
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: #2a2b31;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45vw;
}

#conn {
  flex: none;
  font-size: 0.85rem;
  padding: 0.5rem 0.9rem;
  min-height: 40px;
  background: #2a2b31;
}
#conn.primary { background: #3b6df0; }
.status.connected { background: #1d4d2b; }
.status.disconnected { background: #5b2326; }

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem;
  width: 100%;
  max-width: 28rem;
  margin: 0 auto;
}

/* The `display: flex` on #pair / #controls (id selector) outranks the UA
   [hidden] { display: none }, so toggling `.hidden` would not actually hide
   them — this id+attr rule wins back. */
#pair[hidden],
#controls[hidden] {
  display: none;
}

#pair {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

#pair input {
  font-size: 1rem;
  padding: 0.8rem;
  border-radius: 0.5rem;
  border: 1px solid #3a3b42;
  background: #1d1e24;
  color: inherit;
  width: 100%;
}

button {
  font-size: 1rem;
  padding: 0.8rem 1.2rem;
  min-height: 44px;
  min-width: 44px;
  border-radius: 0.6rem;
  border: none;
  background: #3b6df0;
  color: white;
  font-weight: 600;
}
button:active { filter: brightness(1.2); }
button.danger { background: #b3413f; }

#controls {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
  align-items: center;
}

#pad {
  position: relative;
  width: min(78vw, 20rem);
  aspect-ratio: 1;
  border-radius: 1.25rem;
  background: radial-gradient(circle at center, #23242b 0%, #1b1c22 100%);
  border: 1px solid #33343c;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #3b6df0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: left 0.12s ease-out, top 0.12s ease-out;
}
#pad.active #stick { transition: none; }

.pad-hint {
  position: absolute;
  bottom: 0.6rem;
  width: 100%;
  text-align: center;
  color: #5a5b63;
  font-size: 0.8rem;
}

.slider-row {
  display: grid;
  grid-template-columns: 5.2rem 1fr 3.2rem;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
}

.slider-row input[type="range"] {
  width: 100%;
  min-height: 44px;
  accent-color: #3b6df0;
}

.slider-row output {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #9a9ba3;
}

.button-row {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}
.button-row button { flex: 1; }

#tilt {
  width: 100%;
  background: #2a2b31;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#tilt.active { background: #1d4d2b; }

#emotes {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.emote-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}
button.emote {
  font-size: 0.9rem;
  padding: 0.5rem 0.8rem;
  min-height: 40px;
  background: #2a2b31;
}
button.emote.small {
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  min-height: 36px;
}
.emote-group h4 {
  margin: 0.5rem 0 0.3rem;
  font-size: 0.85rem;
  color: #9a9ba3;
  font-weight: 600;
}
#emote-more summary {
  cursor: pointer;
  color: #7ea2f7;
  font-size: 0.9rem;
  padding: 0.4rem 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 44px;
  font-size: 0.9rem;
  color: #9a9ba3;
}
.toggle-row input {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: #3b6df0;
}
