:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --green: #10b981;
  --cyan: #0ea5e9;
  --red: #ff6b6b;
  --yellow: #f59e0b;
  --blue: #2563eb;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.06);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% -10%, rgba(14, 165, 233, 0.16), transparent 34%),
    radial-gradient(circle at 85% 0%, rgba(16, 185, 129, 0.14), transparent 32%),
    linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-height: 40px;
  box-shadow: var(--shadow-soft);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 44px;
}

.topbar,
.hero,
.panel-title,
.actions,
.shoulder-row {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px;
  border: 1px solid rgba(226, 232, 240, 0.82);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 3.2vw, 42px);
  line-height: 1.04;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

:lang(ja) h1,
:lang(ko) h1,
:lang(zh-CN) h1,
:lang(zh-Hant) h1 {
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.12;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 124px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow-soft);
}

.device-panel .connection-pill {
  width: fit-content;
  margin: -6px 0 18px;
}

.connection-pill.connected {
  color: var(--text);
  border-color: rgba(16, 185, 129, 0.45);
  background: #ecfdf5;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 14px rgba(255, 107, 107, 0.45);
}

.connected .status-dot {
  background: var(--green);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.5);
}

.hero {
  align-items: stretch;
  gap: 18px;
  margin-bottom: 18px;
}

.language-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}

.language-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
}

.language-link:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.language-link.active {
  border-color: rgba(37, 99, 235, 0.35);
  background: #eff6ff;
  color: var(--blue);
  font-weight: 700;
}

.language-select-field {
  display: grid;
  gap: 6px;
  min-width: 180px;
  color: var(--muted);
  font-size: 13px;
}

.language-select-field span {
  font-weight: 700;
}

.language-select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  box-shadow: var(--shadow-soft);
}

.language-select:focus {
  border-color: rgba(37, 99, 235, 0.5);
  outline: 3px solid rgba(37, 99, 235, 0.12);
}

.controller-stage {
  flex: 1 1 720px;
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #1e293b;
  border-radius: 8px;
  background:
    linear-gradient(115deg, rgba(14, 165, 233, 0.18), transparent 42%),
    linear-gradient(180deg, #172033, #0f172a);
  box-shadow: var(--shadow);
}

.controller-body {
  width: min(720px, 92%);
  aspect-ratio: 1.75;
  position: relative;
  padding: 42px 48px 38px;
  border: 1px solid #465142;
  border-radius: 46% 46% 38% 38% / 42% 42% 58% 58%;
  background:
    radial-gradient(circle at 18% 72%, #252d24 0 21%, transparent 22%),
    radial-gradient(circle at 82% 72%, #252d24 0 21%, transparent 22%),
    linear-gradient(145deg, #30372e, #171c17 72%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.08), 0 24px 70px rgba(0, 0, 0, 0.42);
}

.shoulder-row {
  justify-content: space-between;
  gap: 18px;
}

.shoulder-group {
  width: 210px;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.shoulder-group.right {
  grid-template-columns: minmax(0, 1fr) 64px;
}

.shoulder-group.right .shoulder-button {
  grid-column: 2;
  grid-row: 1;
}

.shoulder-group.right .trigger-meter {
  grid-column: 1;
  grid-row: 1;
}

.shoulder-button {
  min-height: 38px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.trigger-meter {
  width: 100%;
  display: grid;
  gap: 8px;
  color: #cbd5e1;
  font-size: 13px;
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #111510;
}

.meter i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #34d399, #38bdf8);
}

.controller-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr 1fr 1fr;
  align-items: center;
  gap: 22px;
  height: calc(100% - 54px);
}

.controller-body button {
  background: #1f2937;
  border-color: #475569;
  color: #f8fafc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.controller-body button:hover:not(:disabled) {
  border-color: #94a3b8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 10px 22px rgba(2, 6, 23, 0.28);
}

.controller-body [data-button].active {
  background: rgba(16, 185, 129, 0.28);
  border-color: #34d399;
  color: #f0fdf4;
}

.stick-wrap {
  display: grid;
  justify-items: center;
  gap: 10px;
  color: #cbd5e1;
}

.stick {
  width: 132px;
  aspect-ratio: 1;
  position: relative;
  border: 1px solid #50594b;
  border-radius: 50%;
  background:
    linear-gradient(#20261f 1px, transparent 1px),
    linear-gradient(90deg, #20261f 1px, transparent 1px),
    #101410;
  background-size: 50% 50%;
}

.stick span {
  width: 48px;
  height: 48px;
  position: absolute;
  left: 50%;
  top: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6f7c68, #222922 72%);
  transform: translate(-50%, -50%);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.38);
}

.center-cluster {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-items: center;
  justify-items: center;
}

.mini-button {
  min-width: 54px;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
}

.home-button {
  width: 42px;
  min-height: 42px;
  border-radius: 50%;
}

.home-button::before {
  content: "";
  display: block;
  width: 13px;
  height: 13px;
  margin: auto;
  border: 2px solid #cbd5e1;
  border-top-color: transparent;
  transform: rotate(45deg);
}

.dpad {
  grid-column: 1 / -1;
  width: 112px;
  height: 112px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.dpad button {
  min-height: 34px;
  border-radius: 6px;
}

.dpad button:nth-child(1) { grid-column: 2; grid-row: 1; }
.dpad button:nth-child(2) { grid-column: 1; grid-row: 2; }
.dpad button:nth-child(3) { grid-column: 3; grid-row: 2; }
.dpad button:nth-child(4) { grid-column: 2; grid-row: 3; }

.face-buttons {
  width: 150px;
  height: 150px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.face {
  width: 52px;
  min-height: 52px;
  border-radius: 50%;
  font-weight: 700;
}

.face.y { grid-column: 2; grid-row: 1; color: var(--yellow); }
.face.x { grid-column: 1; grid-row: 2; color: var(--blue); }
.face.b { grid-column: 3; grid-row: 2; color: var(--red); }
.face.a { grid-column: 2; grid-row: 3; color: var(--green); }

[data-button].active {
  background: rgba(16, 185, 129, 0.18);
  border-color: #34d399;
  color: #064e3b;
  box-shadow: 0 0 22px rgba(16, 185, 129, 0.22);
}

.device-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.device-panel {
  flex: 0 0 340px;
  min-width: 0;
  padding: 22px;
  align-self: stretch;
}

.panel-title {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.device-panel > .panel-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

#padName {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

#padIndex {
  white-space: nowrap;
  padding-top: 3px;
}

.panel-title span,
.hint,
dt,
.range-field {
  color: var(--muted);
}

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

.stats-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.select-field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 13px;
}

.select-field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  box-shadow: var(--shadow-soft);
}

.select-field select:disabled {
  opacity: 0.55;
}

dt {
  margin-bottom: 8px;
  font-size: 12px;
}

dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.actions {
  gap: 10px;
  margin-bottom: 14px;
}

.actions button {
  flex: 1;
}

.primary {
  background: linear-gradient(135deg, #2563eb, #059669);
  border-color: rgba(37, 99, 235, 0.28);
  color: #ffffff;
}

.hint {
  margin-bottom: 0;
  line-height: 1.6;
  padding: 12px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.panel {
  padding: 20px;
}

.wide {
  grid-column: 1 / -1;
}

.range-field {
  display: grid;
  grid-template-columns: auto auto 150px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

input[type="range"] {
  accent-color: var(--green);
}

.axis-list,
.button-list {
  display: grid;
  gap: 10px;
}

.axis-row,
.button-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 62px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.bar {
  height: 10px;
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.bar i {
  position: absolute;
  left: 50%;
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: var(--blue);
}

.button-row .bar i {
  left: 0;
  background: var(--green);
}

.event-log {
  min-height: 120px;
  max-height: 220px;
  margin: 0;
  padding: 0 0 0 22px;
  overflow: auto;
  color: var(--muted);
  line-height: 1.7;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  padding-top: 10px;
  padding-bottom: 10px;
}

.event-log li::marker {
  color: var(--green);
}

.seo-content {
  margin-top: 18px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow-soft);
}

.seo-intro {
  max-width: 820px;
}

.seo-intro p {
  color: var(--muted);
  line-height: 1.75;
}

.faq-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.faq-list details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
}

.faq-list summary {
  cursor: pointer;
  font-weight: 700;
}

.faq-list p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding: 18px 4px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.site-footer span:first-child {
  color: var(--text);
  font-weight: 700;
}

@media (max-width: 940px) {
  .hero,
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    display: grid;
  }

  .device-panel {
    flex-basis: auto;
  }

  .controller-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .controller-body {
    aspect-ratio: auto;
    min-height: 560px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .language-select-field {
    width: 100%;
  }

  .site-footer {
    flex-direction: column;
  }

  .controller-stage {
    min-height: 640px;
  }

  .controller-body {
    width: 96%;
    min-height: 600px;
    padding: 24px 18px;
    border-radius: 28px;
  }

  .shoulder-row,
  .actions {
    flex-direction: column;
  }

  .shoulder-group,
  .trigger-meter,
  .actions button {
    width: 100%;
  }

  .shoulder-group,
  .shoulder-group.right {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .shoulder-group.right .shoulder-button,
  .shoulder-group.right .trigger-meter {
    grid-column: auto;
    grid-row: auto;
  }

  .controller-grid {
    gap: 14px;
  }

  .stick {
    width: 112px;
  }

  .axis-row,
  .button-row {
    grid-template-columns: 56px minmax(0, 1fr) 52px;
    font-size: 13px;
  }

  .range-field {
    grid-template-columns: auto auto;
  }

  .range-field input {
    grid-column: 1 / -1;
    width: 100%;
  }
}
