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

html {
  min-height: 100%;
  background: var(--color-page);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--color-text);
  background:
    radial-gradient(circle at 50% -20%, #5f3c21 0, transparent 46%),
    var(--color-page);
  font-family: var(--font-body);
  line-height: 1.5;
}

button,
select,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgb(242 197 92 / 72%);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.35);
  opacity: 0.45;
}

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

.page-backdrop {
  position: fixed;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.backdrop-orb {
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.14;
}

.backdrop-orb--one {
  top: -180px;
  left: -140px;
  background: var(--color-sand);
}

.backdrop-orb--two {
  right: -180px;
  bottom: -220px;
  background: var(--color-red);
}

.game-shell {
  width: 100%;
  min-height: 100vh;
}

#game {
  position: relative;
  width: min(100%, var(--game-max-width));
  min-height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--color-panel-strong);
  box-shadow: 0 0 80px rgb(0 0 0 / 52%);
}

.scene {
  position: relative;
  min-height: 100vh;
  padding: var(--scene-padding);
}

.scene[hidden] {
  display: none !important;
}

.scene-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.scene-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scene-header--overlay {
  position: relative;
  z-index: 4;
  padding: 2px 0;
  color: rgb(255 246 223 / 78%);
  font-size: 0.82rem;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--color-gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.button,
.icon-button {
  appearance: none;
  border: 0;
  transition:
    transform var(--transition-fast),
    filter var(--transition-fast),
    background var(--transition-fast);
}

.button:not(:disabled):active,
.icon-button:not(:disabled):active {
  transform: translateY(2px) scale(0.99);
}

.button {
  min-height: 48px;
  padding: 12px 20px;
  border-radius: var(--radius-medium);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.button--primary {
  color: #281609;
  background: linear-gradient(180deg, #f8d478 0%, var(--color-sand) 100%);
  box-shadow:
    inset 0 1px rgb(255 255 255 / 45%),
    0 8px 22px rgb(196 138 64 / 28%);
}

.button--secondary {
  border: 1px solid rgb(242 197 92 / 42%);
  background: linear-gradient(180deg, #47311e, #302116);
}

.button--ghost {
  border: 1px solid var(--color-line);
  color: var(--color-muted);
  background: rgb(255 255 255 / 4%);
}

.button--danger {
  color: #fff3e9;
  background: linear-gradient(180deg, var(--color-red), var(--color-red-dark));
}

.button--ultimate {
  color: #30192d;
  background: linear-gradient(180deg, #e7b5dd, #aa6aa1);
}

.button--compact {
  min-height: 40px;
  padding: 9px 14px;
  border-radius: var(--radius-small);
  font-size: 0.82rem;
}

.icon-button {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-pill);
  color: var(--color-muted);
  background: rgb(0 0 0 / 18%);
  font-size: 0.72rem;
}

.placeholder-art {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 1px dashed rgb(255 240 204 / 28%);
  color: var(--color-muted);
  background:
    linear-gradient(135deg, rgb(255 255 255 / 3%), transparent 45%),
    rgb(0 0 0 / 14%);
  text-align: center;
}

.placeholder-art.has-art {
  overflow: hidden;
  border-style: solid;
  border-color: rgb(255 231 170 / 28%);
}

.placeholder-art.has-art .placeholder-art__label {
  position: absolute;
  right: 10px;
  bottom: 9px;
  left: 10px;
  z-index: 2;
  width: max-content;
  max-width: calc(100% - 20px);
  margin: auto;
  padding: 4px 10px;
  overflow: hidden;
  border: 1px solid rgb(255 236 194 / 24%);
  border-radius: var(--radius-pill);
  background: rgb(26 17 13 / 72%);
  box-shadow: 0 4px 12px rgb(0 0 0 / 24%);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px #000;
  white-space: nowrap;
  backdrop-filter: blur(7px);
}

.placeholder-art__label {
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
}

.placeholder-art__note {
  color: var(--color-faint);
  font-size: 0.7rem;
}

.simple-scene {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 0, rgb(196 138 64 / 18%), transparent 42%),
    var(--color-panel-strong);
}

.simple-scene h2 {
  margin-bottom: 10px;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 7vw, 2.6rem);
}

.simple-scene__home {
  position: absolute;
  top: max(var(--scene-padding), env(safe-area-inset-top));
  left: var(--scene-padding);
}

.scene-description {
  margin-bottom: 24px;
  color: var(--color-muted);
}

.settings-dialog {
  width: min(calc(100% - 32px), 460px);
  padding: 0;
  border: 1px solid rgb(242 197 92 / 28%);
  border-radius: var(--radius-large);
  color: var(--color-text);
  background: var(--color-panel);
  box-shadow: var(--shadow-soft);
}

.settings-dialog::backdrop {
  background: rgb(10 7 5 / 74%);
  backdrop-filter: blur(8px);
}

.settings-form {
  display: grid;
  gap: 20px;
  padding: 22px;
}

.settings-form__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.settings-form h2 {
  margin-bottom: 0;
}

.toast-root {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(calc(100% - 32px), 440px);
  padding: 12px 16px;
  border: 1px solid rgb(242 197 92 / 30%);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  background: rgb(25 18 14 / 94%);
  box-shadow: var(--shadow-soft);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition:
    opacity var(--transition-normal),
    transform var(--transition-normal);
}

.toast-root.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 700px) {
  body {
    padding: 18px 0;
  }

  #game {
    min-height: calc(100vh - 36px);
    border: 1px solid rgb(255 240 204 / 10%);
    border-radius: 28px;
  }

  .scene {
    min-height: calc(100vh - 38px);
  }
}

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