:root {
  --page: #05070b;
  --stage: #0b111d;
  --panel: rgba(8, 14, 25, 0.68);
  --panel-strong: rgba(8, 14, 25, 0.84);
  --line: rgba(134, 167, 214, 0.26);
  --line-strong: rgba(119, 194, 255, 0.48);
  --text: #ecf6ff;
  --muted: #8ea1ba;
  --cyan: #2ed3ff;
  --blue: #3277ff;
  --red: #ff4f63;
  --gold: #f2bd4b;
  --green: #20d08c;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: #06111f;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.app-shell {
  min-height: 100vh;
  padding: clamp(12px, 1.7vw, 22px);
}

.game-app {
  width: min(1280px, 100%);
  margin: 0 auto;
}

.game-stage {
  position: relative;
  height: calc(100vh - clamp(24px, 3.4vw, 44px));
  min-height: 620px;
  overflow: hidden;
  border: 1px solid rgba(98, 152, 219, 0.32);
  border-radius: 8px;
  background: #06111f;
  box-shadow: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.setup-panel,
.hud,
.control-pad,
.notice {
  position: absolute;
  z-index: 3;
}

.setup-panel {
  top: 16px;
  left: 16px;
  width: min(680px, calc(100% - 32px));
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.setup-panel summary {
  display: none;
}

.panel-content {
  padding: 14px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(260px, 360px);
  gap: 14px;
  align-items: end;
}

.brand-block {
  min-width: 0;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.brand-block p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.ticker-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 8px;
}

.ticker-form input {
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 9, 16, 0.7);
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  text-transform: uppercase;
  outline: none;
}

.ticker-form input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(46, 211, 255, 0.16);
}

.ticker-form button,
.range-tab,
.preset-row button,
.control-btn {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(7, 13, 24, 0.66);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.ticker-form button {
  height: 40px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 900;
}

.range-row,
.preset-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 10px 0 1px;
  scrollbar-width: thin;
}

.range-row::-webkit-scrollbar,
.preset-row::-webkit-scrollbar {
  height: 0;
}

.range-tab,
.preset-row button {
  flex: 0 0 auto;
  height: 32px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
}

.range-tab {
  width: 62px;
}

.range-tab.active {
  border-color: var(--cyan);
  background: rgba(46, 211, 255, 0.18);
  color: #e9fbff;
}

.preset-row {
  padding-top: 8px;
}

.preset-row button {
  width: 62px;
  min-width: 0;
  padding: 0;
}

.preset-row button.active {
  border-color: var(--red);
  background: rgba(255, 79, 99, 0.18);
  color: #ffe7eb;
}

.hud {
  top: 16px;
  right: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(82px, 1fr));
  gap: 8px;
  width: min(454px, calc(100% - 736px));
  min-width: 360px;
}

.hud-item {
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(14px);
}

.hud-item span,
.hud-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.hud-item strong {
  margin-top: 4px;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.12;
}

.notice {
  top: 128px;
  left: 16px;
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(5, 9, 16, 0.82);
  color: #ffffff;
  font-size: 13px;
  line-height: 1.45;
  transform: translateY(0);
  opacity: 1;
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(12px);
}

.notice.hidden {
  pointer-events: none;
  transform: translateY(-6px);
  opacity: 0;
}

.control-pad {
  left: 16px;
  right: 16px;
  bottom: 14px;
  display: flex;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
}

.control-cluster {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.control-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto;
  place-items: center;
  padding: 6px;
  text-align: center;
}

.control-icon {
  grid-row: auto;
  color: var(--cyan);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.control-label {
  min-width: 0;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.control-key {
  min-width: 0;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}

.control-btn.throttle {
  border-color: rgba(255, 79, 99, 0.64);
  background: rgba(255, 79, 99, 0.2);
}

.control-btn.brake {
  border-color: rgba(236, 246, 255, 0.28);
}

.control-btn.jump {
  border-color: rgba(242, 189, 75, 0.62);
  background: rgba(242, 189, 75, 0.14);
}

.control-btn.reset .control-icon {
  color: var(--blue);
}

.control-btn.pressed,
.control-btn:active {
  transform: translateY(1px);
  filter: brightness(1.18);
}

@media (max-width: 1080px) {
  .hud {
    top: max(10px, env(safe-area-inset-top));
    right: 16px;
    bottom: auto;
    width: min(300px, calc(100% - 32px));
    min-width: 0;
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 760px) {
  .app-shell {
    min-height: 100vh;
    padding: 0;
  }

  .game-app,
  .game-stage {
    width: 100%;
    min-height: 100vh;
    height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .setup-panel {
    top: max(10px, env(safe-area-inset-top));
    left: 10px;
    width: min(318px, calc(100% - 20px));
    max-height: calc(100vh - 190px);
    overflow: hidden;
  }

  .setup-panel summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 42px;
    padding: 9px 12px;
    cursor: pointer;
    list-style: none;
  }

  .setup-panel summary::-webkit-details-marker {
    display: none;
  }

  .summary-title {
    color: var(--text);
    font-size: 16px;
    font-weight: 900;
  }

  .summary-meta {
    min-width: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .setup-panel[open] .panel-content {
    display: block;
  }

  .setup-panel:not([open]) .panel-content {
    display: none;
  }

  .setup-panel:not([open]) {
    width: 204px;
  }

  .panel-content {
    padding: 0 10px 10px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .brand-block {
    display: none;
  }

  .ticker-form {
    grid-template-columns: minmax(0, 1fr) 64px;
  }

  .ticker-form input,
  .ticker-form button {
    height: 36px;
  }

  .ticker-form input {
    font-size: 16px;
  }

  .range-row,
  .preset-row {
    gap: 6px;
    padding-top: 8px;
  }

  .range-tab,
  .preset-row button {
    height: 30px;
    border-radius: 7px;
    font-size: 11px;
  }

  .range-tab {
    width: 54px;
  }

  .preset-row button {
    width: 54px;
    min-width: 0;
    padding: 0;
  }

  .hud {
    top: max(10px, env(safe-area-inset-top));
    right: 10px;
    left: auto;
    bottom: auto;
    width: 150px;
    min-width: 0;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .hud-item {
    padding: 7px 8px;
    border-radius: 7px;
  }

  .hud-item span {
    font-size: 10px;
  }

  .hud-item strong {
    font-size: 14px;
  }

  .notice {
    top: 58px;
    left: 10px;
    right: 10px;
    max-width: none;
    font-size: 12px;
  }

  .control-pad {
    left: 0;
    right: 0;
    bottom: max(14px, env(safe-area-inset-bottom));
    justify-content: space-between;
    align-items: end;
    padding: 0 14px;
  }

  .control-cluster {
    display: grid;
    gap: 10px;
  }

  .control-cluster-left {
    grid-template-columns: 58px 58px;
  }

  .control-cluster-right {
    grid-template-columns: 58px 58px;
    grid-template-rows: 58px 58px;
  }

  .control-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    place-items: center;
    padding: 5px;
    text-align: center;
  }

  .control-cluster-right .throttle {
    grid-row: 1 / 3;
    grid-column: 2;
    align-self: center;
    justify-self: center;
    width: 58px;
    height: 58px;
  }

  .control-cluster-right .jump {
    grid-row: 1;
    grid-column: 1;
  }

  .control-cluster-right .brake {
    grid-row: 2;
    grid-column: 1;
  }

  .control-cluster-right .reset {
    display: none;
  }

  .control-icon {
    grid-row: auto;
    font-size: 24px;
  }

  .control-label {
    font-size: 11px;
  }

  .control-key {
    font-size: 9px;
  }
}

/* v28 cockpit layout */
body {
  background: #06111f;
}

.app-shell {
  min-height: 100vh;
  padding: 0;
}

.game-app {
  width: 100%;
}

.game-stage {
  height: 100vh;
  min-height: 620px;
  border: 0;
  border-radius: 0;
  background: #06111f;
  box-shadow: none;
}

.setup-panel {
  top: clamp(24px, 4.6vh, 48px);
  left: clamp(24px, 5.2vw, 92px);
  width: min(620px, calc(100% - 780px));
  min-width: 520px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.panel-content {
  padding: 0;
}

.topbar {
  grid-template-columns: minmax(210px, 1fr) 288px;
  gap: 32px;
  align-items: start;
}

.brand-heading {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark,
.progress-mark {
  display: inline-grid;
  grid-template-columns: repeat(3, 5px);
  align-items: end;
  gap: 4px;
  width: 28px;
  height: 30px;
}

.brand-mark span,
.progress-mark span {
  display: block;
  width: 5px;
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(180deg, #2ed3ff, #2677ff);
  box-shadow: 0 0 12px rgba(46, 211, 255, 0.52);
}

.brand-mark span:nth-child(1),
.progress-mark span:nth-child(1) {
  height: 12px;
}

.brand-mark span:nth-child(2),
.progress-mark span:nth-child(2) {
  height: 20px;
}

.brand-mark span:nth-child(3),
.progress-mark span:nth-child(3) {
  height: 28px;
}

h1 {
  font-size: clamp(30px, 2.4vw, 42px);
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(46, 211, 255, 0.12);
}

.brand-block p {
  margin: 8px 0 0 42px;
  color: rgba(196, 214, 235, 0.74);
  font-size: 17px;
  font-weight: 700;
}

.ticker-form {
  width: 288px;
  grid-template-columns: 210px 72px;
  gap: 0;
  justify-self: start;
  border: 1px solid rgba(70, 124, 182, 0.48);
  border-radius: 8px;
  background: rgba(3, 11, 22, 0.56);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025);
}

.ticker-form input {
  height: 44px;
  border: 0;
  border-radius: 8px 0 0 8px;
  background: transparent;
  font-size: 19px;
  font-weight: 800;
}

.ticker-form button {
  height: 44px;
  border: 0;
  border-left: 1px solid rgba(70, 124, 182, 0.52);
  border-radius: 0 8px 8px 0;
  background: rgba(11, 30, 53, 0.8);
  color: #dff4ff;
}

.range-row,
.preset-row {
  gap: 8px;
  padding: 24px 0 0 42px;
  overflow: visible;
}

.preset-row {
  padding-top: 14px;
}

.range-tab,
.preset-row button {
  height: 40px;
  border-radius: 6px;
  border-color: rgba(72, 126, 186, 0.5);
  background: rgba(4, 12, 24, 0.7);
  color: rgba(226, 239, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02), 0 12px 30px rgba(0, 0, 0, 0.16);
  font-size: 16px;
}

.range-tab {
  width: 74px;
}

.preset-row button {
  width: 74px;
  min-width: 0;
  padding: 0;
}

.range-tab.active {
  border-color: rgba(46, 211, 255, 0.78);
  background: rgba(16, 54, 85, 0.68);
  color: #59d8ff;
}

.preset-row button.active {
  border-color: rgba(255, 79, 99, 0.82);
  background: linear-gradient(180deg, rgba(255, 79, 99, 0.26), rgba(119, 20, 36, 0.42));
  color: #ffffff;
}

.hud {
  top: clamp(26px, 4.8vh, 48px);
  right: clamp(26px, 3.8vw, 66px);
  width: min(660px, calc(100% - 710px));
  min-width: 600px;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.hud-item {
  min-height: 108px;
  padding: 17px 18px;
  border-color: rgba(79, 137, 190, 0.48);
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(8, 20, 36, 0.88), rgba(4, 13, 24, 0.72));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03), 0 18px 44px rgba(0, 0, 0, 0.24);
}

.hud-item span {
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(210, 224, 242, 0.76);
  font-size: 15px;
}

.hud-icon {
  color: #54cfff;
  font-size: 22px;
  line-height: 1;
}

.hud-item:nth-child(2) .hud-icon {
  color: #f2d563;
}

.hud-item:nth-child(4) .hud-icon {
  color: #826dff;
}

.hud-item strong {
  margin-top: 16px;
  font-size: 29px;
  line-height: 1;
}

.notice {
  top: 70px;
  left: clamp(24px, 5.2vw, 92px);
  max-width: 320px;
  border-color: rgba(70, 124, 182, 0.32);
  background: rgba(3, 10, 18, 0.84);
}

.control-pad {
  left: 50%;
  right: auto;
  bottom: clamp(58px, 9.2vh, 92px);
  transform: translateX(-50%);
  justify-content: center;
  gap: 12px;
}

.control-cluster {
  gap: 12px;
}

.control-btn {
  width: 64px;
  height: 64px;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto;
  place-items: center;
  padding: 6px;
  border-radius: 50%;
  border-color: rgba(72, 126, 186, 0.48);
  background: rgba(4, 13, 25, 0.76);
  text-align: center;
}

.control-icon {
  color: #71c9ff;
  font-size: 21px;
  line-height: 1;
}

.control-label {
  font-size: 12px;
  line-height: 1;
}

.control-key {
  font-size: 9px;
  line-height: 1;
}

.control-btn.throttle {
  border-color: rgba(255, 79, 99, 0.88);
  background: linear-gradient(180deg, rgba(255, 79, 99, 0.24), rgba(73, 12, 24, 0.62));
}

.control-btn.jump {
  border-color: rgba(242, 189, 75, 0.72);
  background: rgba(18, 23, 24, 0.8);
}

.progress-hud {
  position: absolute;
  z-index: 3;
  left: clamp(24px, 5.2vw, 92px);
  bottom: clamp(28px, 4vh, 42px);
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: none;
}

.progress-mark {
  width: 24px;
  height: 24px;
  transform: scale(0.78);
  transform-origin: left center;
}

.progress-label {
  color: rgba(230, 244, 255, 0.86);
  font-size: 15px;
  font-weight: 800;
}

.progress-track {
  position: relative;
  width: min(420px, 32vw);
  height: 15px;
  overflow: hidden;
  border-radius: 5px;
  background:
    repeating-linear-gradient(105deg, rgba(255, 255, 255, 0.09) 0 18px, rgba(255, 255, 255, 0.02) 18px 20px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.progress-fill {
  position: absolute;
  inset: 0;
  transform: scaleX(0);
  transform-origin: left center;
  background:
    repeating-linear-gradient(105deg, #ff4f63 0 18px, #ad2638 18px 20px);
  box-shadow: 0 0 18px rgba(255, 79, 99, 0.38);
}

.setup-panel,
.hud {
  --top-ui-scale: 0.7;
}

.setup-panel {
  transform: scale(var(--top-ui-scale));
  transform-origin: top left;
}

.hud {
  transform: scale(var(--top-ui-scale));
  transform-origin: top right;
}

@media (max-width: 1180px) {
  .setup-panel {
    width: min(620px, calc(100% - 48px));
    min-width: 0;
  }

  .hud {
    top: max(10px, env(safe-area-inset-top));
    right: clamp(16px, 2vw, 24px);
    bottom: auto;
    width: min(300px, calc(100% - 32px));
    min-width: 0;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .hud-item {
    min-height: 76px;
    padding: 11px 12px;
  }

  .hud-item strong {
    margin-top: 8px;
    font-size: 20px;
  }
}

@media (max-width: 760px) {
  .game-stage {
    min-height: 100vh;
  }

  .setup-panel {
    top: max(10px, env(safe-area-inset-top));
    left: 10px;
    width: min(330px, calc(100% - 20px));
    max-height: calc(100vh - 190px);
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: transparent;
    backdrop-filter: none;
  }

  .setup-panel summary {
    display: flex;
  }

  .setup-panel:not([open]) {
    width: 204px;
  }

  .setup-panel:not([open]) .panel-content {
    display: none;
  }

  .panel-content {
    padding: 0 10px 10px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .brand-block {
    display: none;
  }

  .ticker-form {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) 64px;
  }

  .ticker-form input,
  .ticker-form button {
    height: 36px;
  }

  .range-row,
  .preset-row {
    padding-left: 0;
    gap: 6px;
    flex-wrap: wrap;
    overflow: hidden;
  }

  .range-tab,
  .preset-row button {
    height: 30px;
    font-size: 11px;
  }

  .range-tab {
    width: 54px;
  }

  .preset-row button {
    width: 54px;
    min-width: 0;
    padding: 0;
  }

  .hud {
    top: max(10px, env(safe-area-inset-top));
    right: 10px;
    bottom: auto;
    width: 150px;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .hud-item {
    min-height: 0;
    padding: 7px 8px;
  }

  .hud-icon {
    display: none;
  }

  .hud-item span {
    font-size: 10px;
  }

  .hud-item strong {
    font-size: 14px;
  }

  .control-pad {
    left: 0;
    right: 0;
    bottom: max(14px, env(safe-area-inset-bottom));
    transform: none;
    justify-content: space-between;
    align-items: end;
    padding: 0 14px;
  }

  .control-cluster {
    display: grid;
    gap: 10px;
  }

  .control-cluster-left {
    grid-template-columns: 58px 58px;
  }

  .control-cluster-right {
    grid-template-columns: 58px 58px;
    grid-template-rows: 58px 58px;
  }

  .control-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    place-items: center;
    padding: 5px;
    text-align: center;
  }

  .control-cluster-right .throttle {
    grid-row: 1 / 3;
    grid-column: 2;
    align-self: center;
    justify-self: center;
    width: 58px;
    height: 58px;
  }

  .control-cluster-right .jump {
    grid-row: 1;
    grid-column: 1;
  }

  .control-cluster-right .brake {
    grid-row: 2;
    grid-column: 1;
  }

  .control-cluster-right .reset {
    display: none;
  }

  .control-icon {
    grid-row: auto;
    font-size: 19px;
  }

  .control-label {
    font-size: 10px;
  }

  .control-key {
    font-size: 8px;
  }

  .progress-hud {
    display: none;
  }
}

.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 8, 15, 0.48);
  backdrop-filter: blur(10px);
}

.modal-overlay.hidden {
  display: none;
}

.modal-panel {
  position: relative;
  width: min(380px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid rgba(119, 194, 255, 0.42);
  border-radius: 8px;
  background: rgba(7, 14, 26, 0.92);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.38);
}

.modal-panel h2 {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.1;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(236, 246, 255, 0.92);
  font-size: 22px;
  line-height: 1;
}

.name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 8px;
  margin-bottom: 14px;
}

.name-row input {
  min-width: 0;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 9, 18, 0.86);
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  outline: none;
}

.name-row input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(46, 211, 255, 0.14);
}

.dice-btn,
.primary-modal-btn {
  border: 1px solid rgba(119, 194, 255, 0.42);
  border-radius: 8px;
  color: var(--text);
  background: rgba(12, 31, 52, 0.78);
  font-weight: 900;
}

.dice-btn {
  height: 46px;
  font-size: 22px;
}

.primary-modal-btn {
  width: 100%;
  height: 44px;
  background: rgba(255, 79, 99, 0.24);
  border-color: rgba(255, 79, 99, 0.58);
}

.onboarding-guide {
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid rgba(119, 194, 255, 0.22);
}

.onboarding-guide h3 {
  margin: 0 0 9px;
  color: #fff4cf;
  font-size: 15px;
  line-height: 1.2;
}

.onboarding-guide ol {
  margin: 0;
  padding-left: 20px;
  color: rgba(236, 246, 255, 0.84);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}

.onboarding-guide li + li {
  margin-top: 4px;
}

.result-message {
  margin: 0;
  color: rgba(236, 246, 255, 0.94);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.7;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.result-stats span {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.result-stats strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 18px;
}

@media (max-width: 760px) {
  .modal-overlay {
    padding: 14px;
  }

  .modal-panel {
    width: min(340px, calc(100vw - 28px));
    padding: 18px;
  }

  .modal-panel h2 {
    font-size: 21px;
  }

  .name-row input,
  .dice-btn {
    height: 42px;
  }

  .onboarding-guide {
    margin-top: 12px;
    padding-top: 11px;
  }

  .onboarding-guide h3 {
    font-size: 14px;
  }

  .onboarding-guide ol {
    font-size: 12px;
    line-height: 1.45;
  }
}

/* Final setup panel layout */
.setup-panel {
  --top-ui-scale: 1;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  width: min(380px, calc(100vw - 24px));
  min-width: 0;
  max-height: calc(100vh - 24px);
  overflow: hidden;
  border: 1px solid rgba(70, 124, 182, 0.42);
  border-radius: 8px;
  background: rgba(4, 12, 23, 0.76);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.24);
  transform: none;
  backdrop-filter: blur(14px);
}

.setup-panel:not([open]) summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 9px 12px;
  cursor: pointer;
  list-style: none;
}

.setup-panel[open] summary {
  display: none;
}

.setup-panel summary::-webkit-details-marker {
  display: none;
}

.summary-title {
  min-width: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.summary-meta {
  min-width: 0;
  color: rgba(196, 214, 235, 0.82);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-panel:not([open]) {
  width: min(260px, calc(100vw - 24px));
}

.setup-panel:not([open]) .panel-content {
  display: none;
}

.panel-content {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.panel-subtitle {
  display: none;
}

.setup-panel .range-row,
.setup-panel .preset-row {
  display: grid;
  gap: 7px;
  padding: 0;
  overflow: visible;
}

.setup-panel .range-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.setup-panel .preset-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.setup-panel .range-tab,
.setup-panel .preset-row button {
  width: auto;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 13px;
  white-space: nowrap;
}

.setup-panel .ticker-form {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 66px;
  gap: 7px;
  justify-self: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.setup-panel .ticker-form input,
.setup-panel .ticker-form button {
  height: 38px;
  border: 1px solid rgba(70, 124, 182, 0.48);
  border-radius: 7px;
}

.setup-panel .ticker-form input {
  padding: 0 10px;
  background: rgba(3, 9, 18, 0.72);
  font-size: 16px;
}

.setup-panel .ticker-form button {
  border-left: 1px solid rgba(70, 124, 182, 0.48);
  border-color: rgba(242, 189, 75, 0.64);
  background: linear-gradient(180deg, rgba(242, 189, 75, 0.34), rgba(151, 76, 22, 0.62));
  color: #fff4cf;
  font-size: 13px;
}

@media (min-width: 761px) {
  .setup-panel {
    top: clamp(18px, 3.4vh, 36px);
    left: clamp(18px, 3vw, 48px);
  }
}

@media (max-width: 760px) {
  .setup-panel {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    width: min(340px, calc(100vw - 16px));
    max-height: calc(100vh - 16px);
  }

  .setup-panel:not([open]) {
    width: min(220px, calc(100vw - 16px));
  }

  .setup-panel .range-tab,
  .setup-panel .preset-row button {
    height: 32px;
    padding: 0 6px;
    font-size: 12px;
  }

  .setup-panel .ticker-form {
    grid-template-columns: minmax(0, 1fr) 62px;
  }

  .setup-panel .ticker-form input,
  .setup-panel .ticker-form button {
    height: 36px;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .setup-panel {
    width: min(312px, calc(100vw - 16px));
    max-height: calc(100vh - 16px);
  }

  .setup-panel summary {
    min-height: 34px;
    padding: 7px 9px;
  }

  .panel-content {
    gap: 6px;
    padding: 7px;
  }

  .setup-panel .range-row,
  .setup-panel .preset-row {
    gap: 5px;
  }

  .setup-panel .range-tab,
  .setup-panel .preset-row button {
    height: 28px;
    padding: 0 4px;
    border-radius: 6px;
    font-size: 11px;
  }

  .setup-panel .ticker-form {
    grid-template-columns: minmax(0, 1fr) 56px;
    gap: 5px;
  }

  .setup-panel .ticker-form input,
  .setup-panel .ticker-form button {
    height: 31px;
    font-size: 12px;
  }
}
