:root {
  --color-bg: #0e0d0c;
  --color-surface: #1a1816;
  --color-fg: #e6e1d8;
  --color-muted: #9a9288;
  --color-torch: #e08a3a;
  --color-blood: #8a3a32;
  --color-line: #3a342e;
  --color-skin-0: #f1d0b4;
  --color-skin-1: #d9aa84;
  --color-skin-2: #c0865c;
  --color-skin-3: #8a5538;
  --color-skin-4: #4a3024;
  --color-hair-0: #241812;
  --color-hair-1: #4a3020;
  --color-hair-2: #7a3e24;
  --color-hair-3: #a85a32;
  --color-hair-4: #c4964a;
  --color-hair-5: #e0c27a;
  --color-hair-6: #f0e2b8;
  --color-hair-7: #b9b6b0;
  --color-eye-0: #9ec4d8;
  --color-eye-1: #3f6f9e;
  --color-eye-2: #8a939c;
  --color-eye-3: #6e8f62;
  --color-eye-4: #8a7348;
  --color-eye-5: #c4843a;
  --font-display: "Outfit", system-ui, sans-serif;
  --font-sans: "Outfit", system-ui, sans-serif;
}

@layer base {
  button:not(:disabled),
  [role="button"]:not(:disabled) {
    cursor: pointer;
  }
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-sans);
}

.game-root {
  position: relative;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: var(--color-bg);
  touch-action: none;
  user-select: none;
}

.game-root canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 42%, rgb(8 7 6 / 0.55) 100%);
}

.hurt-flash,
.heave-flash {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgb(18 16 12 / 0.72) 100%);
  opacity: 0;
}

.exit {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 30;
  color: var(--color-muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
}

.exit:hover {
  color: var(--color-fg);
}

.hud,
.game-root > header {
  pointer-events: none;
  position: absolute;
  inset-inline: 0;
  top: 0;
  z-index: 10;
  padding: 1rem;
}

.game-root[data-phase="menu"] .hud {
  display: none;
}

.meter-block {
  max-width: 28rem;
  margin: 0 auto;
}

.meter-label {
  margin-bottom: 0.25rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.meter {
  height: 0.45rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--color-line);
}

.meter-fill {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(1);
  background: var(--color-torch);
}

.status {
  margin: 0.5rem 0 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.9rem;
  line-height: 1;
  color: var(--color-torch);
  min-height: 1.2em;
}

.overlay {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
}

.overlay[hidden] {
  display: none;
}

.menu-card {
  pointer-events: auto;
  width: min(28rem, 100%);
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
  border: 1px solid var(--color-line);
  border-radius: 0.75rem;
  padding: 1.5rem;
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.35);
}

.kicker {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-torch);
}

.menu-card h1 {
  margin: 0.25rem 0 0;
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--color-fg);
}

.blurb {
  margin: 0.75rem 0 0;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--color-muted);
}

.menu-card button {
  margin-top: 1.25rem;
  min-height: 2.75rem;
  border: 0;
  border-radius: 0.4rem;
  padding: 0.75rem 1.5rem;
  background: var(--color-torch);
  color: var(--color-bg);
  font-weight: 600;
}

.menu-card ul {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--color-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.creator {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 25;
  width: min(22rem, calc(100% - 1.5rem));
  max-height: calc(100% - 1.5rem);
  overflow: auto;
  padding: 1.1rem 1.1rem 1rem;
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  border: 1px solid var(--color-line);
  border-radius: 0.75rem;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.35);
}

.creator h1 {
  margin: 0.2rem 0 0.45rem;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.creator .blurb {
  margin: 0 0 0.9rem;
}

.field,
.field-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.75rem 0 0;
  color: var(--color-muted);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--color-torch);
  min-height: 2rem;
}

.field input[type="text"],
.field input:not([type]) {
  text-transform: none;
  letter-spacing: 0;
  font-size: 1rem;
  color: var(--color-fg);
  background: var(--color-bg);
  border: 1px solid var(--color-line);
  border-radius: 0.4rem;
  padding: 0.55rem 0.7rem;
  min-height: 2.75rem;
}

.tab-row,
.choices,
.cam-row,
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
}

.tab-row button,
.choices button,
.cam-row button,
.creator [data-start] {
  min-height: 2.75rem;
  border-radius: 0.4rem;
  border: 1px solid var(--color-line);
  background: transparent;
  color: var(--color-fg);
  padding: 0.4rem 0.75rem;
  font-weight: 600;
}

.tab-row button[aria-pressed="true"],
.choices button[aria-pressed="true"] {
  border-color: var(--color-torch);
  color: var(--color-bg);
  background: var(--color-torch);
}

.swatch {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  border: 2px solid var(--color-line);
  padding: 0;
}

.swatch[aria-pressed="true"] {
  outline: 2px solid var(--color-fg);
  outline-offset: 2px;
}

.swatch.skin-0 { background: var(--color-skin-0); }
.swatch.skin-1 { background: var(--color-skin-1); }
.swatch.skin-2 { background: var(--color-skin-2); }
.swatch.skin-3 { background: var(--color-skin-3); }
.swatch.skin-4 { background: var(--color-skin-4); }
.swatch.hair-0 { background: var(--color-hair-0); }
.swatch.hair-1 { background: var(--color-hair-1); }
.swatch.hair-2 { background: var(--color-hair-2); }
.swatch.hair-3 { background: var(--color-hair-3); }
.swatch.hair-4 { background: var(--color-hair-4); }
.swatch.hair-5 { background: var(--color-hair-5); }
.swatch.hair-6 { background: var(--color-hair-6); }
.swatch.hair-7 { background: var(--color-hair-7); }
.swatch.eye-0 { background: var(--color-eye-0); }
.swatch.eye-1 { background: var(--color-eye-1); }
.swatch.eye-2 { background: var(--color-eye-2); }
.swatch.eye-3 { background: var(--color-eye-3); }
.swatch.eye-4 { background: var(--color-eye-4); }
.swatch.eye-5 { background: var(--color-eye-5); }

.creator [data-start],
.creator [data-action] {
  width: 100%;
  margin-top: 0.6rem;
  background: var(--color-torch);
  color: var(--color-bg);
  border-color: transparent;
  min-height: 2.75rem;
  border-radius: 0.4rem;
  border: 0;
  font-weight: 600;
}

.fine {
  margin: 0.55rem 0 0;
  color: var(--color-muted);
  font-size: 0.85rem;
  line-height: 1.4;
  text-transform: none;
  letter-spacing: 0;
}

.nameplate {
  pointer-events: none;
  position: absolute;
  left: 50%;
  bottom: 1.25rem;
  z-index: 12;
  transform: translateX(-50%);
  color: var(--color-fg);
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 800px) {
  .creator {
    top: auto;
    bottom: 6.5rem;
    left: 0.5rem;
    width: calc(100% - 1rem);
    max-height: 46vh;
  }
  .nameplate {
    bottom: auto;
    top: 0.8rem;
  }
}

.key-hint[hidden] {
  display: none;
}

.touch-controls {
  display: none;
  pointer-events: none;
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 10;
  padding: 1rem 1rem 1.25rem;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.stick {
  pointer-events: auto;
  width: 7.5rem;
  height: 7.5rem;
  border-radius: 999px;
  border: 1px solid var(--color-line);
  background: color-mix(in srgb, var(--color-surface) 75%, transparent);
  position: relative;
  touch-action: none;
}

.nub {
  position: absolute;
  left: 2.35rem;
  top: 2.35rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  background: var(--color-torch);
}

.action-col {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.action-btn {
  min-width: 5.5rem;
  min-height: 3rem;
  border-radius: 0.6rem;
  border: 1px solid var(--color-line);
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
  color: var(--color-fg);
  font-size: 0.95rem;
  font-weight: 600;
  touch-action: none;
}

.action-btn.primary {
  background: var(--color-torch);
  color: var(--color-bg);
  border-color: transparent;
}

@media (min-width: 640px) {
  .overlay {
    align-items: center;
    justify-content: flex-start;
    padding: 2.5rem;
  }
}

@media (pointer: coarse), (max-width: 800px) {
  .game-root[data-phase="play"] .touch-controls {
    display: flex;
  }
  .key-hint {
    display: none;
  }
}
