.panel {
  background: linear-gradient(180deg, rgba(78, 28, 120, 0.92), rgba(32, 10, 58, 0.92));
  border: 3px solid rgba(255, 215, 0, 0.88);
  border-radius: 22px;
  box-shadow: 0 8px 0 rgba(122, 16, 32, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.22);
  padding: 14px;
  min-width: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 16px;
  border: 3px solid #fff6e4;
  text-align: center;
  line-height: 1.1;
  white-space: normal;
}

.btn:active { transform: translateY(4px); }

.btn-gold {
  color: #4a1408;
  background: linear-gradient(180deg, #fff3b0 0%, #ffd700 46%, #ff8f00 100%);
  box-shadow: 0 6px 0 #9a3412, inset 0 2px 0 rgba(255, 255, 255, 0.8);
}

.btn-gold:active { box-shadow: 0 2px 0 #9a3412, inset 0 2px 0 rgba(255, 255, 255, 0.8); }

.btn-red {
  color: white;
  background: linear-gradient(180deg, #ff6b6b, #c8102e 60%, #8d0b22);
  box-shadow: 0 6px 0 #5c0a16, inset 0 2px 0 rgba(255, 255, 255, 0.35);
}

.btn-red:active { box-shadow: 0 2px 0 #5c0a16; }

.btn-ghost {
  color: var(--cream);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.28);
}

.btn-block { width: 100%; }

.btn:disabled {
  filter: saturate(0.7);
  opacity: 0.75;
  transform: none;
}

.sheet-actions, .stack-actions, .sign-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.stack-actions .btn, .sign-actions .btn { flex: 1; min-width: 0; }

.modal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 12px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(12, 2, 24, 0.62);
  pointer-events: auto;
}

.sheet {
  width: min(460px, 100%);
  max-height: min(78dvh, 680px);
  overflow: auto;
  background: linear-gradient(180deg, #5a248c, #2a0c4a);
  border: 3px solid var(--gold);
  border-radius: 24px 24px 18px 18px;
  box-shadow: 0 12px 0 #6a1020;
  padding: 16px;
  display: grid;
  gap: 10px;
}

.sheet-title { font-size: clamp(28px, 8vw, 40px); line-height: 0.95; color: var(--gold); }

.sheet-copy, .howto, .result-copy { display: grid; gap: 8px; }

.result-copy .star-row { font-size: 1.4rem; }

.toast {
  pointer-events: none;
  max-width: min(420px, 100%);
  padding: 10px 14px;
  border-radius: 14px;
  background: #2a0c4a;
  border: 2px solid var(--gold);
  color: var(--cream);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-in { opacity: 1; transform: none; }
.toast-good { border-color: var(--success); }
.toast-bad { border-color: var(--danger); }

.switch-row, .field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  min-width: 0;
}

.switch-row span:first-child, .field span { display: grid; min-width: 0; }

.switch { position: relative; width: 54px; height: 32px; flex: 0 0 auto; }

.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; }

.switch-ui {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: #4a2468;
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.35);
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--cream);
  transition: transform 0.18s ease;
}

.switch input:checked + .switch-ui { background: linear-gradient(180deg, #ffd700, #ff6f00); }
.switch input:checked + .switch-ui::after { transform: translateX(22px); }

.name-field {
  width: 100%;
  min-width: 0;
  margin-top: 8px;
  font-size: 16px;
  border-radius: 14px;
  border: 3px solid var(--gold);
  background: #2a0d4a;
  color: var(--cream);
  padding: 12px 14px;
}

.meter {
  height: 10px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.28);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.meter > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold), var(--orange));
}

.seg {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

.seg-btn {
  min-height: 40px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--cream);
  border: 2px solid transparent;
  font-weight: 800;
  font-size: 0.82rem;
}

.seg-btn.is-on {
  color: #4a1408;
  background: var(--gold);
  border-color: #fff6e4;
}
