:root {
  --bg: #12100e;
  --panel: #201b17;
  --panel-2: #2b241e;
  --ink: #f7e7bd;
  --muted: #b99d72;
  --gold: #f6b93b;
  --amber: #d77f16;
  --green: #58d68d;
  --red: #ff5f56;
  --blue: #57c7ff;
  --line: #4c392b;
  --shadow: rgba(0, 0, 0, 0.35);
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  height: 100%;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    radial-gradient(circle at top left, rgba(246, 185, 59, 0.18), transparent 32rem),
    var(--bg);
  background-size: 18px 18px, 18px 18px, auto, auto;
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.game-shell {
  width: min(1280px, calc(100% - 16px));
  height: 100vh;
  margin: 0 auto;
  padding: 10px 0;
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  gap: 10px;
}

.hero-panel,
.game-panel,
.stat-card {
  border: 2px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: 0 8px 0 var(--shadow);
}

.hero-panel {
  min-height: 0;
  height: 100%;
  padding: 12px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  position: sticky;
  top: 10px;
  overflow: hidden;
}

.brand-row,
.panel-heading,
.legacy-panel,
.controls-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pixel-sign {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  color: #111;
  background: var(--green);
  border: 2px solid #111;
  box-shadow: 4px 4px 0 #000;
  font-weight: 900;
}

.sign-dot {
  width: 8px;
  height: 8px;
  background: #111;
  box-shadow: 12px 0 0 #111;
}

.save-status,
.panel-heading span,
.stat-label,
.upgrade-meta,
.milestone-card p,
.legacy-panel p {
  color: var(--muted);
}

.save-status {
  min-height: 1.25rem;
  text-align: right;
  font-size: 0.82rem;
}

.kicker {
  margin: 0 0 6px;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.84rem;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(2.1rem, 4vw, 3.8rem);
  line-height: 0.9;
  letter-spacing: 0;
  text-shadow: 4px 4px 0 #000;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  color: var(--gold);
}

.tagline {
  margin-bottom: 0;
  color: #dfc99d;
  line-height: 1.35;
  font-size: 0.88rem;
}

.beer-stage {
  min-height: 0;
  display: grid;
  place-items: end center;
  position: relative;
  border: 2px dashed rgba(247, 231, 189, 0.16);
  background:
    linear-gradient(transparent 68%, rgba(0, 0, 0, 0.28) 68%),
    rgba(0, 0, 0, 0.13);
  overflow: hidden;
}

.tap-house {
  position: absolute;
  top: 12px;
  left: 50%;
  width: 108px;
  height: 138px;
  transform: translateX(-50%);
}

.tap-top {
  width: 86px;
  height: 24px;
  margin: 0 auto;
  background: var(--red);
  border: 4px solid #111;
}

.tap-neck {
  width: 24px;
  height: 78px;
  margin: 0 auto;
  background: #c6c0ad;
  border-left: 4px solid #111;
  border-right: 4px solid #111;
}

.tap-spout {
  width: 72px;
  height: 26px;
  margin-left: 54px;
  margin-top: -12px;
  background: #c6c0ad;
  border: 4px solid #111;
}

.foam-stream {
  position: absolute;
  top: 108px;
  left: 69px;
  width: 12px;
  height: 0;
  background: #fff1b7;
  box-shadow: 0 0 18px rgba(255, 241, 183, 0.55);
  transition: height 120ms ease;
}

.foam-stream.active {
  height: 110px;
}

.mug {
  width: 118px;
  height: 138px;
  margin-bottom: 18px;
  position: relative;
  border: 6px solid #f4e9cf;
  border-top: 0;
  background: rgba(255, 255, 255, 0.13);
  box-shadow: 0 12px 0 #000;
}

.mug.bump {
  animation: bump 180ms ease;
}

.beer-fill {
  position: absolute;
  inset: 28px 0 0;
  background: linear-gradient(180deg, #ffcf50, #d97912);
}

.foam {
  position: absolute;
  z-index: 2;
  top: -20px;
  left: -6px;
  right: -6px;
  height: 40px;
  background: #fff1b7;
  border: 6px solid #f4e9cf;
  border-bottom: 4px solid #111;
}

.foam span {
  position: absolute;
  bottom: -14px;
  width: 18px;
  height: 18px;
  background: #fff1b7;
  border: 4px solid #111;
}

.foam span:nth-child(1) {
  left: 18px;
}

.foam span:nth-child(2) {
  left: 48px;
}

.foam span:nth-child(3) {
  right: 16px;
}

.glass-shine {
  position: absolute;
  top: 24px;
  left: 18px;
  width: 12px;
  height: 78px;
  background: rgba(255, 255, 255, 0.34);
}

.handle {
  position: absolute;
  right: -44px;
  top: 32px;
  width: 44px;
  height: 68px;
  border: 6px solid #f4e9cf;
  border-left: 0;
}

.bubble-field span {
  position: absolute;
  bottom: 30px;
  width: 8px;
  height: 8px;
  background: rgba(255, 241, 183, 0.8);
  animation: bubble 2.8s linear infinite;
}

.bubble-field span:nth-child(1) {
  left: 18%;
  animation-delay: 0s;
}

.bubble-field span:nth-child(2) {
  left: 32%;
  animation-delay: 0.4s;
}

.bubble-field span:nth-child(3) {
  left: 48%;
  animation-delay: 1.1s;
}

.bubble-field span:nth-child(4) {
  left: 61%;
  animation-delay: 0.8s;
}

.bubble-field span:nth-child(5) {
  left: 76%;
  animation-delay: 1.6s;
}

.bubble-field span:nth-child(6) {
  left: 86%;
  animation-delay: 2.1s;
}

.serve-button,
.secondary-button,
.danger-button,
.upgrade-button {
  min-height: 46px;
  padding: 9px 11px;
  color: #15110e;
  background: var(--gold);
  border: 2px solid #111;
  box-shadow: 5px 5px 0 #000;
  font-weight: 900;
}

.serve-button {
  width: 100%;
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.1rem;
}

.serve-button:active,
.secondary-button:active,
.danger-button:active,
.upgrade-button:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 #000;
}

.serve-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--gold);
  background: #15110e;
}

.dashboard {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  align-content: start;
  min-height: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat-card {
  min-height: 76px;
  padding: 10px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.05rem, 2vw, 1.55rem);
  line-height: 1;
  color: #fff4cf;
  overflow-wrap: anywhere;
}

.panel-row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 10px;
  min-height: 0;
}

.game-panel {
  min-height: 0;
  padding: 8px;
  overflow: hidden;
}

.panel-heading {
  margin-bottom: 6px;
}

.panel-heading.flat {
  margin-bottom: 6px;
}

.upgrade-list,
.milestone-list {
  display: grid;
  gap: 4px;
}

.upgrade-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.upgrade-card,
.milestone-card {
  display: grid;
  gap: 2px;
  padding: 5px 7px;
  border: 2px solid rgba(247, 231, 189, 0.18);
  background: rgba(0, 0, 0, 0.16);
}

.upgrade-card {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.upgrade-name {
  display: block;
  margin-bottom: 2px;
  color: #fff4cf;
  font-weight: 900;
}

.upgrade-meta {
  display: block;
  font-size: 0.72rem;
  line-height: 1.12;
}

.upgrade-effect {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upgrade-description,
.milestone-flavor {
  display: none;
}

.upgrade-button {
  min-width: 88px;
  min-height: 32px;
  padding: 6px 8px;
  background: var(--green);
  font-size: 0.78rem;
  white-space: nowrap;
}

.milestone-card.locked {
  opacity: 0.5;
}

.milestone-card strong {
  color: #fff4cf;
  font-size: 0.8rem;
}

.milestone-card p,
.legacy-panel p {
  margin-bottom: 0;
  line-height: 1.18;
}

.legacy-panel {
  align-items: stretch;
}

.legacy-panel > div {
  min-width: 0;
}

.secondary-button {
  background: var(--blue);
}

.danger-button {
  background: var(--red);
}

.controls-panel {
  display: grid;
  grid-template-columns: auto auto auto minmax(180px, 1fr);
  align-items: center;
  flex-wrap: nowrap;
}

.controls-panel textarea {
  flex-basis: auto;
  min-height: 38px;
  max-height: 38px;
  resize: none;
  padding: 8px;
  color: var(--ink);
  background: #100d0b;
  border: 2px solid var(--line);
}

dialog {
  max-width: 420px;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--gold);
  box-shadow: 8px 8px 0 #000;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

dialog form {
  display: grid;
  gap: 12px;
}

.compact {
  min-height: 46px;
}

@keyframes bubble {
  from {
    transform: translateY(0) scale(1);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  to {
    transform: translateY(-210px) scale(0.3);
    opacity: 0;
  }
}

@keyframes bump {
  50% {
    transform: translateY(-8px);
  }
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .game-shell {
    height: auto;
    grid-template-columns: 1fr;
  }

  .upgrade-description,
  .milestone-flavor {
    display: block;
  }

  .upgrade-list {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    min-height: auto;
    position: relative;
    top: auto;
  }

  .stats-grid,
  .panel-row {
    grid-template-columns: 1fr 1fr;
  }

  .panel-row {
    display: grid;
  }
}

@media (max-width: 640px) {
  .game-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

  .brand-row,
  .legacy-panel,
  .upgrade-card {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-grid,
  .panel-row {
    grid-template-columns: 1fr;
  }

  .upgrade-card {
    display: grid;
    grid-template-columns: 1fr;
  }

  .upgrade-button,
  .secondary-button,
  .danger-button {
    width: 100%;
  }

  .controls-panel {
    display: flex;
    flex-wrap: wrap;
  }

  .controls-panel textarea {
    flex-basis: 100%;
    min-height: 88px;
    max-height: none;
    resize: vertical;
  }

  .beer-stage {
    min-height: 240px;
  }
}
