:root {
  color-scheme: dark;
  --ink: #1b0d20;
  --wine: #5c132d;
  --blood: #b62535;
  --red: #ed3e46;
  --cream: #ffefc2;
  --gold: #f7bd45;
  --apple: #d94238;
  --green: #8dbb4a;
  --ash: #bca9a2;
  --panel: rgba(27, 13, 32, 0.95);
  --line: rgba(255, 239, 194, 0.25);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  background: #09040d;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 20%, #3c1226 0, #150817 45%, #070309 100%);
}

body {
  display: grid;
  place-items: center;
  color: var(--cream);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.025) 4px),
    radial-gradient(circle at 20% 15%, rgba(255, 98, 62, 0.18), transparent 28%);
  mix-blend-mode: screen;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  padding: 0.7rem 1.05rem;
  border: 2px solid var(--cream);
  border-radius: 6px;
  color: var(--cream);
  background: #391428;
  box-shadow: 0 5px 0 #140813;
  letter-spacing: 0.07em;
  cursor: pointer;
  transition:
    transform 100ms ease,
    background 100ms ease,
    box-shadow 100ms ease;
}

button:hover:not(:disabled),
button:focus-visible {
  background: #5c1933;
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #140813;
}

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

button.primary {
  color: #2a0b17;
  border-color: #fff2c6;
  background: linear-gradient(#ffc952, #e9892d);
  box-shadow: 0 6px 0 #8b321e;
}

button.primary:hover:not(:disabled),
button.primary:focus-visible {
  background: linear-gradient(#ffe184, #f39a37);
}

kbd,
.keycap {
  display: inline-grid;
  min-width: 1.8em;
  min-height: 1.8em;
  padding: 0 0.35em;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 4px;
  color: #2a0b17;
  background: var(--cream);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  font-family: Arial, sans-serif;
  font-size: 0.78em;
  font-weight: 900;
}

#game-shell {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: clamp(2px, 0.5vmin, 7px) solid #6f263a;
  border-radius: 8px;
  background: #140914;
  box-shadow:
    0 0 0 2px #1a0712,
    0 2.5vmin 8vmin #000;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  image-rendering: auto;
  cursor: crosshair;
}

.screen {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 3vmin, 32px);
  background: rgba(10, 3, 12, 0.68);
  backdrop-filter: blur(3px);
}

.screen.active {
  display: flex;
  animation: screen-in 250ms ease-out;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: scale(1.012);
  }
}

#title-screen {
  justify-content: space-between;
  padding: 6% 7%;
  background:
    linear-gradient(90deg, rgba(15, 4, 15, 0.2), rgba(15, 4, 15, 0.75)),
    radial-gradient(circle at 25% 50%, transparent 0 25%, rgba(15, 4, 15, 0.85) 72%);
}

.title-lockup {
  width: 53%;
  transform: rotate(-2deg);
  text-shadow:
    0 4px 0 #3e1023,
    0 10px 20px #000;
}

.eyebrow {
  margin: 0 0 0.45em;
  color: var(--gold);
  font-family: Arial, sans-serif;
  font-size: clamp(9px, 1.3vw, 16px);
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0.1em;
  font-size: clamp(42px, 7.7vw, 102px);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 0.78;
}

h1 span,
h1 strong {
  display: block;
}

h1 span {
  color: var(--red);
  font-size: 0.64em;
  -webkit-text-stroke: 1px var(--cream);
}

h1 strong {
  color: var(--cream);
  white-space: nowrap;
  -webkit-text-stroke: 2px #57162a;
}

.tagline {
  margin: 1em 0 0;
  color: #ffae45;
  font-size: clamp(13px, 2vw, 25px);
  letter-spacing: 0.22em;
}

.menu-card,
.stage-card,
.modal-card,
.summary-card,
.wide-panel {
  border: 2px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.035), transparent 40%),
    var(--panel);
  box-shadow:
    inset 0 0 30px rgba(255, 97, 61, 0.05),
    0 18px 50px rgba(0, 0, 0, 0.55);
}

.menu-card {
  width: 34%;
  min-width: 240px;
  padding: 2.3%;
}

.big-button {
  width: 100%;
  min-height: clamp(48px, 7vmin, 68px);
  font-size: clamp(13px, 1.8vw, 21px);
}

.big-button kbd {
  float: right;
}

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.button-row > * {
  flex: 1;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 16px 0;
  border-block: 1px solid var(--line);
}

.stats-strip > div {
  padding: 10px 3px;
  text-align: center;
}

.stats-strip strong,
.stats-strip span {
  display: block;
}

.stats-strip strong {
  color: var(--gold);
  font-size: clamp(14px, 1.8vw, 22px);
}

.stats-strip span {
  color: var(--ash);
  font-family: Arial, sans-serif;
  font-size: clamp(7px, 0.9vw, 11px);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.quick-settings {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.icon-button {
  min-height: 34px;
  padding: 6px 9px;
  border-width: 1px;
  font-size: clamp(8px, 0.9vw, 11px);
  box-shadow: 0 3px 0 #140813;
}

.footer-note {
  position: absolute;
  right: 7%;
  bottom: 2.5%;
  margin: 0;
  color: var(--ash);
  font-family: Arial, sans-serif;
  font-size: clamp(8px, 1vw, 12px);
}

.stage-card {
  width: min(620px, 75%);
  padding: 4% 5%;
  text-align: center;
}

.stage-card h2,
.modal-card h2,
.summary-card h2,
.wide-panel h2 {
  margin-bottom: 0.25em;
  color: var(--cream);
  font-size: clamp(26px, 5vw, 58px);
  line-height: 0.9;
  text-transform: uppercase;
}

#intro-art {
  width: 100%;
  height: clamp(40px, 10vmin, 90px);
  margin: 0.6rem 0;
  background:
    radial-gradient(ellipse at center, rgba(244, 188, 68, 0.27), transparent 65%),
    repeating-linear-gradient(125deg, transparent 0 15px, rgba(255, 255, 255, 0.025) 16px);
}

#intro-copy {
  max-width: 500px;
  margin: 0 auto 1rem;
  color: #ead5ba;
  font-family: Arial, sans-serif;
  font-size: clamp(11px, 1.5vw, 17px);
  line-height: 1.45;
}

.control-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 1rem;
}

.control-chips span {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.04);
  font-family: Arial, sans-serif;
  font-size: clamp(8px, 1vw, 12px);
}

.wide-panel {
  width: min(880px, 96%);
  max-height: 94%;
  padding: 2.5%;
  overflow: auto;
}

.panel-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 15px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  font-size: clamp(24px, 4vw, 44px);
}

.currency-wallet {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 4px 13px;
  margin-bottom: 0.5rem;
  color: var(--gold);
  font-family: Arial, sans-serif;
  font-size: clamp(8px, 1.05vw, 13px);
  font-weight: 800;
  white-space: nowrap;
}

.currency-wallet strong {
  color: var(--cream);
}

.upgrade-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 13px;
}

.upgrade-tab {
  min-height: 38px;
  padding: 7px 8px;
  border-width: 1px;
  color: var(--ash);
  font-size: clamp(9px, 1.15vw, 13px);
}

.upgrade-tab.active {
  color: #2a0b17;
  border-color: var(--cream);
  background: linear-gradient(#ffc952, #e9892d);
  box-shadow: 0 4px 0 #8b321e;
}

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.loot-earned {
  display: block;
  margin-top: 4px;
  color: var(--cream);
  font-family: Arial, sans-serif;
  font-size: 0.45em;
  letter-spacing: 0.08em;
}

.upgrade {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px;
  min-height: 92px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
}

.upgrade:hover:not(:disabled) {
  border-color: var(--gold);
}

.upgrade:disabled {
  opacity: 0.68;
}

.upgrade-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: #2d0c18;
  background: var(--gold);
  font-size: 20px;
}

.upgrade strong,
.upgrade small,
.upgrade em {
  display: block;
}

.upgrade strong {
  color: var(--cream);
  font-size: clamp(11px, 1.25vw, 15px);
}

.upgrade small {
  margin: 3px 0 8px;
  color: var(--ash);
  font-family: Arial, sans-serif;
  font-size: clamp(8px, 0.9vw, 11px);
  line-height: 1.2;
}

.upgrade em {
  color: var(--gold);
  font-size: clamp(9px, 1vw, 12px);
  font-style: normal;
}

.level-pips {
  display: flex;
  gap: 3px;
  margin-top: 5px;
}

.level-pips i {
  width: 13px;
  height: 4px;
  border-radius: 2px;
  background: #392030;
}

.level-pips i.filled {
  background: var(--red);
}

.back-button {
  min-height: 38px;
  padding: 7px 14px;
}

.modal-card,
.summary-card {
  width: min(580px, 80%);
  max-height: 92%;
  padding: 2.2%;
  overflow: auto;
  text-align: center;
}

#modal-body {
  color: #ead5ba;
  font-family: Arial, sans-serif;
  font-size: clamp(9px, 1.15vw, 13px);
  line-height: 1.35;
  text-align: left;
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin: 12px 0;
}

.how-grid article {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
}

.how-grid h3 {
  margin: 0 0 5px;
  color: var(--gold);
  font-family: Impact, sans-serif;
  font-size: 1em;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.how-grid p {
  margin: 0;
}

.settings-panel {
  margin-top: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-family: Arial, sans-serif;
  font-size: clamp(9px, 1.2vw, 13px);
  text-align: left;
}

.settings-panel label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 25px;
}

.settings-panel input[type="range"] {
  width: 50%;
  accent-color: var(--red);
}

.toggle-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
}

.summary-copy {
  color: #ead5ba;
  font-family: Arial, sans-serif;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 18px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--line);
}

.summary-stats div {
  padding: 10px 4px;
  background: #241020;
}

.summary-stats strong,
.summary-stats span {
  display: block;
}

.summary-stats strong {
  color: var(--cream);
  font-size: clamp(16px, 2.5vw, 28px);
}

.summary-stats span {
  color: var(--ash);
  font-family: Arial, sans-serif;
  font-size: clamp(7px, 0.85vw, 10px);
  text-transform: uppercase;
}

.reward-banner {
  margin: 10px 0;
  padding: 11px;
  border: 2px solid var(--gold);
  border-radius: 7px;
  color: #32111d;
  background: linear-gradient(100deg, #e99b35, #ffd16a);
  font-size: clamp(15px, 2.4vw, 26px);
}

.text-button {
  min-height: auto;
  margin-top: 12px;
  padding: 5px 8px;
  border: 0;
  color: var(--ash);
  background: transparent;
  box-shadow: none;
  font-family: Arial, sans-serif;
  font-size: 12px;
  text-decoration: underline;
}

#toast {
  position: absolute;
  z-index: 30;
  top: 12%;
  left: 50%;
  max-width: 72%;
  padding: 9px 16px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  color: #2b0c18;
  background: var(--cream);
  box-shadow: 0 7px 25px #000;
  font-family: Arial, sans-serif;
  font-size: clamp(9px, 1.2vw, 13px);
  font-weight: 900;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -15px);
  transition: 180ms ease;
}

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

#canvas-prompt {
  position: absolute;
  z-index: 5;
  right: 1.5%;
  bottom: 2.2%;
  padding: 6px 10px;
  border: 1px solid rgba(255, 239, 194, 0.3);
  border-radius: 5px;
  color: var(--cream);
  background: rgba(23, 8, 20, 0.82);
  font-family: Arial, sans-serif;
  font-size: clamp(8px, 1vw, 12px);
  pointer-events: none;
}

@media (max-aspect-ratio: 4/3) {
  #title-screen {
    padding-inline: 4%;
  }

  .title-lockup {
    width: 52%;
  }

  .menu-card {
    width: 42%;
    min-width: 0;
  }
}

@media (max-width: 700px), (max-height: 520px) {
  .upgrade-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin: 8px 0;
  }

  .upgrade {
    min-height: 68px;
    padding: 7px;
  }

  .upgrade-icon {
    width: 25px;
    height: 25px;
    font-size: 14px;
  }

  .how-grid {
    gap: 5px;
  }

  .settings-panel {
    margin-top: 7px;
    padding: 5px 10px;
  }
}

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