@font-face {
  font-family: Fredoka;
  src: url("../fonts/fredoka-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Nunito;
  src: url("../fonts/nunito-latin-800-normal.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }

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

body {
  font-family: Nunito, Inter, "Trebuchet MS", sans-serif;
  font-weight: 800;
  color: #1b2430;
  background: linear-gradient(180deg, #8fd4ff 0%, #ffe7a8 48%, #ffd27a 100%);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
}

.topbar, .footer {
  flex: 0 0 auto;
  background: #fff7e8;
  border: 3px solid #1b2430;
  border-radius: 14px;
  box-shadow: 4px 4px 0 #1b2430;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 8px 6px 12px;
}

.brand {
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 18px;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.credit {
  margin-left: auto;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

#btn-mute {
  border: 3px solid #1b2430;
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  box-shadow: 2px 2px 0 #1b2430;
  cursor: pointer;
  white-space: nowrap;
}

#btn-mute[aria-pressed="true"] { background: #ffd0d6; }

#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border: 3px solid #1b2430;
  border-radius: 18px;
  overflow: hidden;
  background: #87d4ff;
  box-shadow: 4px 4px 0 #1b2430;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  min-height: 0;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  pointer-events: none;
}

.chip, .bossbar, .card, .btn, .level-btn, #btn-mute {
  pointer-events: auto;
}

.chip {
  background: #fff7e8;
  border: 3px solid #1b2430;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  box-shadow: 2px 2px 0 #1b2430;
}

.bossbar {
  position: relative;
  height: 22px;
  border: 3px solid #1b2430;
  border-radius: 999px;
  background: #2a1d28;
  overflow: hidden;
  flex: 0 0 auto;
}

.bossbar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ff5a6a, #ffd23f);
}

.bossbar span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 0 #1b2430;
}

.screen {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.card {
  pointer-events: auto;
  width: min(460px, 100%);
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  background: #fffaf0;
  border: 3px solid #1b2430;
  border-radius: 18px;
  box-shadow: 4px 4px 0 #1b2430;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

h1, h2, h3, p { margin: 0; }

h1, h2, .brand, .payout {
  font-family: Fredoka, Nunito, sans-serif;
  font-weight: 700;
  letter-spacing: -0.03em;
}

h1 { font-size: clamp(36px, 10vw, 52px); line-height: 0.95; }
h2 { font-size: 28px; line-height: 1; }
.eyebrow { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.tag, .help p, .upgrade p { font-size: 14px; line-height: 1.35; }

.coins-row, .payout {
  align-self: flex-start;
  background: #ffd23f;
  border: 3px solid #1b2430;
  border-radius: 999px;
  padding: 4px 12px;
}

.payout {
  align-self: stretch;
  text-align: center;
  font-size: 28px;
  border-radius: 14px;
  padding: 8px 12px;
}

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

.level-btn, .btn {
  border: 3px solid #1b2430;
  border-radius: 12px;
  background: #fff;
  box-shadow: 3px 3px 0 #1b2430;
  cursor: pointer;
  min-height: 44px;
}

.level-btn { font-size: 16px; }
.level-btn[aria-pressed="true"] { background: #2ed3c7; }
.level-btn:disabled {
  background: #efe8da;
  color: #6a6156;
  box-shadow: none;
  cursor: default;
}

.actions { display: flex; flex-direction: column; gap: 8px; }

.btn {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
}

.btn.primary { background: linear-gradient(#ffe58a, #ffc53d); }
.btn.teal { background: linear-gradient(#7af0e4, #2ed3c7); }
.btn.coral { background: linear-gradient(#ffb199, #ff7a5c); }
.btn.small { width: auto; min-height: 40px; white-space: nowrap; }
.btn:disabled { background: #efe8da; color: #6a6156; box-shadow: none; cursor: default; }
.btn:active:not(:disabled), #btn-mute:active, .level-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.upgrades { display: flex; flex-direction: column; gap: 8px; }

.upgrade {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 3px solid #1b2430;
  border-radius: 14px;
  padding: 8px;
  background: #fff;
}

.upgrade h3 { font-size: 16px; }

.footer {
  text-align: center;
  padding: 6px 10px 8px;
}

.footer p {
  font-size: 12px;
  line-height: 1.35;
}

:focus-visible {
  outline: 3px solid #3d7eff;
  outline-offset: 2px;
}

@media (max-width: 420px) {
  .brand { font-size: 16px; }
  .credit, #btn-mute { font-size: 12px; }
  h2 { font-size: 24px; }
}

[hidden] { display: none !important; }
