@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --bg: #101313;
  --panel: #191e1e;
  --line: #303838;
  --text: #eef1e9;
  --muted: #9ca8a1;
  --accent: #d4f36a;
  --danger: #ff8e7e;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 90% 0%, #293523 0, transparent 34%), var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 4rem); letter-spacing: 0; line-height: .95; }
h2 { font-size: 1.7rem; }
h3 { color: var(--text); font-size: 1rem; }
a { color: var(--accent); }
code { overflow-wrap: anywhere; color: var(--accent); font-family: 'DM Mono', monospace; }

.shell { max-width: 920px; margin: 0 auto; padding: 7vh 24px 72px; }
.topbar { display: flex; align-items: end; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); padding-bottom: 28px; }
.eyebrow { margin-bottom: 12px; color: var(--accent); font-family: 'DM Mono', monospace; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }
.header-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.primary, .secondary, button { display: inline-flex; align-items: center; justify-content: center; border-radius: 5px; font: inherit; text-decoration: none; cursor: pointer; }
.primary, button { border: 0; padding: 12px 16px; background: var(--accent); color: #18200f; font-weight: 600; }
.secondary { border: 1px solid var(--line); padding: 11px 15px; background: transparent; color: var(--text); font-weight: 600; }
.primary:hover, button:hover { filter: brightness(1.06); }
.secondary:hover { border-color: var(--accent); color: var(--accent); }
button:disabled { cursor: wait; opacity: .6; }
.page-lede { max-width: 680px; padding: 24px 0 18px; color: var(--muted); font-size: 1.05rem; line-height: 1.6; }
.muted { color: var(--muted); }

.status-panel, .settings-panel, .events-panel { border: 1px solid var(--line); background: var(--panel); }
.status-panel { display: grid; gap: 8px; padding: 16px 20px; }
.status-panel p { min-height: 1.5em; font-size: .9rem; line-height: 1.5; }
.joystick-connection { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.joystick-connection p { margin: 0; }
.connection-connected { color: #9be39a; }
.connection-disconnected { color: #ff8e7e; }
.joystick-connection .primary { padding: 8px 12px; font-size: .88rem; }
.settings-panel, .events-panel { margin-top: 24px; padding: 24px; }
.section-heading { margin-bottom: 22px; }
.section-heading .eyebrow { margin-bottom: 7px; }

#settings { display: grid; gap: 14px; }
#tip-settings, #menu-settings { display: grid; gap: 14px; }
#settings h3 { margin-top: 12px; padding-top: 18px; border-top: 1px solid var(--line); }
#settings h3:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
#settings > p { line-height: 1.5; }
.helper-text { font-size: .88rem; }
label { display: grid; min-width: 0; gap: 7px; color: var(--muted); font-size: .88rem; }
input, select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 11px 12px;
  background: #101414;
  color: var(--text);
  font: inherit;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
input[type="number"] { max-width: 18rem; }
input[type="checkbox"] { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.inline-option { display: flex; align-items: center; gap: 10px; }

.tier, .menu-rule {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 12px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.01);
}
.tier + .tier, .menu-rule + .menu-rule { margin-top: 10px; }
.tier label, .menu-rule label { min-width: 0; margin: 0; }
.tier input, .tier select, .menu-rule input, .menu-rule select { width: 100%; }
.tier legend, .menu-rule legend { padding: 0 6px; color: var(--accent); font-family: 'DM Mono', monospace; font-size: .78rem; }
.menu-rule .named-triggers {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  min-width: 0;
  margin: 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
}
.menu-rule .named-triggers .inline-option { display: flex; width: auto; align-items: center; gap: 8px; }
.activation-card {
  margin: 0 0 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.01);
}
.activation-card > summary {
  padding: 14px 16px;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}
.activation-body { display: grid; gap: 14px; padding: 0 16px 16px; }
.activation-shockers {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
}
.activation-shockers legend { padding: 0 6px; color: var(--accent); font-family: 'DM Mono', monospace; font-size: .78rem; }
.activation-shockers .inline-option { display: flex; width: auto; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.activation-shockers input[type="checkbox"] { flex: 0 0 17px; width: 17px; height: 17px; }
.activation-commands, .activation-named { display: grid; gap: 10px; }
.activation-commands h4, .activation-named h4 { margin: 0; color: var(--text); }
.activation-test-panel { display: grid; gap: 12px; margin-top: 18px; padding: 16px; border: 1px solid var(--line); }
.activation-test-panel h4 { margin: 0; color: var(--text); }
.activation-test-panel label { max-width: 100%; }
.activation-test-panel select, .activation-test-panel input { width: 100%; }
.activation-test-panel #test-activation { justify-self: start; }
.remove-activation { justify-self: start; }
.remove-tier, .danger { border: 1px solid #60403d; background: transparent; color: var(--danger); }
#test { justify-self: start; }
#save-settings { margin-top: 4px; }
.form-status { min-height: 1.5em; margin-top: 12px; color: var(--muted); line-height: 1.5; }

.events-panel #log { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.events-panel #log li { padding: 10px 12px; border: 1px solid var(--line); color: var(--muted); font-family: 'DM Mono', monospace; font-size: .8rem; line-height: 1.5; overflow-wrap: anywhere; }
.events-panel #log time { color: var(--accent); }

.overlay-page { min-height: 0; background: transparent; overflow: hidden; font-family: 'Space Grotesk', sans-serif; }
.overlay-page #alert {
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: min(90%, 760px);
  padding: 1rem 1.5rem;
  border: 1px solid var(--accent);
  background: rgb(25 30 30 / 94%);
  color: var(--text);
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 1rem) scale(.98);
  transition: opacity .25s, transform .25s;
  box-shadow: 0 12px 50px #0008;
}
.overlay-page #alert.visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.overlay-page #details { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem 1.25rem; }
.overlay-page .metric { color: var(--muted); font-size: .72em; font-weight: 500; }

@media (max-width: 760px) {
  .topbar { align-items: start; flex-direction: column; }
  .header-actions { justify-content: start; }
  .tier, .menu-rule { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  .shell { padding: 32px 16px 48px; }
  .settings-panel, .events-panel { padding: 18px 14px; }
  .tier, .menu-rule { grid-template-columns: minmax(0, 1fr); }
}
