*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text);
  background-color: var(--felt-900);
  background-image:
    var(--noise),
    radial-gradient(120% 80% at 50% 38%, var(--felt-lamp) 0%, var(--felt-700) 38%, var(--felt-900) 72%, var(--felt-950) 100%);
  background-blend-mode: soft-light, normal;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

.app {
  height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

:focus-visible {
  outline: 2px solid var(--brass-soft);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- 按钮 ---------- */
.btn {
  --btn-bg: rgba(8, 29, 24, 0.6);
  --btn-fg: var(--text);
  --btn-line: var(--brass-dim);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-5);
  border: 1px solid var(--btn-line);
  border-radius: var(--radius-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: transform var(--duration-fast) var(--ease-out-expo), background var(--duration-fast), border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.btn:hover:not(:disabled) {
  border-color: var(--brass);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.btn:disabled {
  opacity: 0.38;
}

.btn-primary {
  --btn-bg: linear-gradient(180deg, var(--lacquer-bright), var(--lacquer) 55%, var(--lacquer-deep));
  --btn-fg: var(--brass-soft);
  --btn-line: rgba(240, 211, 141, 0.55);
  box-shadow: 0 1px 0 rgba(255, 220, 160, 0.35) inset, 0 8px 18px rgba(122, 22, 16, 0.45);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 1px 0 rgba(255, 220, 160, 0.45) inset, 0 12px 24px rgba(122, 22, 16, 0.55);
}

.btn-brass {
  --btn-bg: linear-gradient(180deg, #f3d999, var(--brass) 60%, #a77a26);
  --btn-fg: #2b1d05;
  --btn-line: rgba(255, 240, 200, 0.7);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-line: var(--line);
  min-height: 36px;
  padding: 0 var(--space-4);
  font-weight: 500;
}

.btn-coin {
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.btn-small {
  min-height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}

/* ---------- 输入框 ---------- */
.field {
  display: grid;
  gap: var(--space-2);
}

.field-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.input {
  min-height: 48px;
  padding: 0 var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(4, 16, 13, 0.55);
  color: var(--text);
  font-size: 1.05rem;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.input:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(214, 164, 65, 0.2);
}

.input::placeholder {
  color: var(--text-faint);
}

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: max(16px, env(safe-area-inset-top));
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--brass-dim);
  border-radius: var(--radius-pill);
  background: var(--surface-strong);
  box-shadow: var(--shadow-float);
  color: var(--brass-soft);
  font-weight: 600;
  transform: translateX(-50%);
  animation: toast-in var(--duration-normal) var(--ease-out-expo);
}

.toast.is-error {
  color: #ffd2c8;
  border-color: rgba(214, 58, 44, 0.6);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -12px);
  }
}

/* ---------- 弹出面板 ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: rgba(3, 12, 10, 0.6);
  backdrop-filter: blur(3px);
  animation: fade-in var(--duration-normal) ease;
}

.sheet {
  width: min(560px, 100%);
  max-height: min(80dvh, 720px);
  overflow: auto;
  padding: var(--space-5);
  border: 1px solid var(--brass-dim);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--felt-800), var(--felt-900));
  box-shadow: var(--shadow-float);
  animation: rise-in var(--duration-normal) var(--ease-out-expo);
}

.sheet h2 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-display);
  color: var(--brass-soft);
}

.sheet h3 {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--text-base);
  color: var(--brass);
}

.sheet p,
.sheet li {
  color: var(--text-muted);
  line-height: 1.7;
}

.sheet ul {
  margin: 0;
  padding-left: 1.2em;
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-5);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
