* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #005F99;
  color: #003A5E;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
}

.app-shell {
  width: 100%;
  max-width: 440px;
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  background: #FFFADC;
  box-shadow: 0 12px 48px rgba(0, 42, 72, 0.28);
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* ==================== HOME SCREEN (VIRAL RUN PALETTE) ==================== */
.home-screen {
  padding: 16px 16px 18px;
  overflow: hidden;
  /* #FFFADC background with subtle #FFF5B7 sunburst light rays matching the Viral Run logo */
  background-color: #FFFADC;
  background-image: repeating-conic-gradient(
    from -8deg at 50% 42%,
    #FFF5B7 0deg 15deg,
    #FFFADC 15deg 30deg
  );
  gap: 12px;
}

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

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  object-fit: cover;
  border: 2.5px solid #005F99;
  box-shadow: 0 4px 12px rgba(0, 95, 153, 0.22);
  flex-shrink: 0;
}

.brand-title {
  font-size: 23px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #005F99;
  margin: 0;
}

.brand-sub {
  font-size: 12px;
  font-weight: 700;
  color: #004A78;
  margin: 2px 0 0;
}

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

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 2px solid #005F99;
  color: #005F99;
  font-size: 18px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:active {
  transform: scale(0.95);
}

.stage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 188px;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 2px 8px;
  align-content: start;
}

.stage-tile {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 2.5px solid rgba(0, 95, 153, 0.25);
  background: #FFFFFF;
  padding: 0;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  height: 188px;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.stage-tile.selected {
  border-color: #005F99;
  box-shadow: 0 0 0 3px rgba(0, 95, 153, 0.24), 0 8px 18px rgba(0, 95, 153, 0.22);
  transform: translateY(-2px);
}

.tile-art {
  width: 100%;
  flex: 1;
  position: relative;
  overflow: hidden;
}

.tile-art svg,
.tile-canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.tile-badge-top {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 9.5px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 999px;
  background: #005F99;
  color: #FFFFFF;
  letter-spacing: 0.04em;
}

.tile-badge-weekly {
  background: #FF449F;
  color: #FFFFFF;
}

.tile-badge-heard {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 9.5px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 999px;
  background: #FF449F;
  color: #FFFFFF;
}

.tile-banner {
  padding: 8px 10px;
  background: #FFFFFF;
  border-top: 2px solid rgba(0, 95, 153, 0.14);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tile-topic {
  font-size: 12.5px;
  font-weight: 900;
  color: #003A5E;
  line-height: 1.2;
}

.tile-meta {
  font-size: 10.5px;
  font-weight: 700;
  color: #005F99;
}

.weekly-meter-bar {
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid #00EAD3;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.weekly-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 900;
  color: #003A5E;
}

.weekly-pct {
  color: #FF449F;
}

.community-bar-bg {
  height: 8px;
  border-radius: 999px;
  background: rgba(0, 95, 153, 0.14);
  overflow: hidden;
}

.community-bar-fill {
  height: 100%;
  background: #FF449F;
  border-radius: 999px;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: #005F99;
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(0, 95, 153, 0.32);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 2px solid #005F99;
  background: #FFFFFF;
  color: #005F99;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.btn-accent {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: #FF449F;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.btn-ghost {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: #6B5B5E;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

/* ==================== PLAY SCREEN & PAUSE ==================== */
.play-screen {
  width: 100%;
  height: 100%;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud-top {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-top-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.hud-card {
  flex: 1;
  background: rgba(255, 253, 247, 0.92);
  border: 1.5px solid #E5D7C1;
  border-radius: 14px;
  padding: 8px 12px;
  color: #48242C;
  box-shadow: 0 4px 12px rgba(72, 36, 44, 0.08);
}

.pause-btn {
  pointer-events: auto;
  width: 48px;
  border-radius: 14px;
  background: rgba(255, 253, 247, 0.94);
  border: 1.5px solid #E5D7C1;
  color: #48242C;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(72, 36, 44, 0.08);
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  font-weight: 800;
}

.hud-voices {
  font-size: 16px;
  font-weight: 900;
  color: #2D8982;
}

.hud-bar-bg {
  height: 8px;
  border-radius: 999px;
  background: #EAE0CF;
  margin: 5px 0;
  overflow: hidden;
}

.hud-bar-fill {
  height: 100%;
  width: 0%;
  background: #F3AA4E;
  border-radius: 999px;
  transition: width 0.12s linear;
}

.hud-buffs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.buff-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
}

.buff-chant {
  background: #F3AA4E;
  color: #48242C;
}

.buff-viral {
  background: #2D8982;
  color: #FFFFFF;
}

.swipe-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  font-size: 11px;
  font-weight: 800;
  color: #48242C;
  background: rgba(255, 253, 247, 0.85);
  border: 1px solid #E5D7C1;
  padding: 5px 14px;
  border-radius: 999px;
  white-space: nowrap;
}

.pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(72, 36, 44, 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.pause-modal {
  width: 100%;
  max-width: 320px;
  background: #FFFDF7;
  border: 2px solid #E5D7C1;
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 18px 40px rgba(72, 36, 44, 0.25);
  text-align: center;
}

.pause-title {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  color: #48242C;
}

.pause-sub {
  margin: 4px 0 16px;
  font-size: 12.5px;
  font-weight: 700;
  color: #6B5B5E;
}

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

.pause-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ==================== SETTINGS & GUIDE SUB-SCREENS ==================== */
.sub-screen {
  padding: 16px;
  overflow-y: auto;
  background-color: #FFFADC;
  background-image: repeating-conic-gradient(
    from -8deg at 50% 42%,
    #FFF5B7 0deg 15deg,
    #FFFADC 15deg 30deg
  );
  gap: 14px;
  z-index: 30;
}

.sub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-btn {
  background: #FFFFFF;
  border: 2px solid #005F99;
  color: #005F99;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
}

.sub-title {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  color: #005F99;
}

.settings-card {
  background: #FFFFFF;
  border: 2px solid rgba(0, 95, 153, 0.2);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.field-label {
  font-size: 13px;
  font-weight: 800;
  color: #003A5E;
}

.field-hint {
  font-size: 11.5px;
  color: #3B5978;
  margin: 0;
}

.text-input {
  background: #FFFDF0;
  border: 2px solid rgba(0, 95, 153, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  color: #003A5E;
  font-size: 14px;
  font-weight: 700;
  outline: none;
}

.text-input:focus {
  border-color: #005F99;
  background: #FFFFFF;
}

.toggle-pill {
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  background: #005F99;
  color: #FFFFFF;
  font-size: 12.5px;
  font-weight: 900;
  cursor: pointer;
}

.toggle-pill.muted {
  background: #E2E8F0;
  color: #003A5E;
}

.supporter-card {
  background: #FFFFFF;
  border: 2px solid #00EAD3;
}

.supporter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.supporter-badge {
  font-size: 11px;
  font-weight: 900;
  padding: 3px 9px;
  border-radius: 999px;
  background: #FF449F;
  color: #FFFFFF;
  letter-spacing: 0.04em;
}

.supporter-status {
  font-size: 11px;
  font-weight: 900;
  color: #005F99;
}

.guide-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guide-item {
  background: #FFFFFF;
  border: 1.5px solid #EAE0CF;
  border-radius: 16px;
  padding: 12px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.guide-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 19px;
  flex-shrink: 0;
}

.guide-heading {
  font-size: 13.5px;
  font-weight: 900;
  color: #48242C;
}

.guide-text {
  font-size: 12px;
  color: #5A474C;
  margin: 3px 0 0;
  line-height: 1.4;
}

/* ==================== GAME OVER / 3D POP-UP GREETING CARD ==================== */
.over-screen {
  padding: 12px 14px 16px;
  background-color: #FFFADC;
  background-image: repeating-conic-gradient(
    from -8deg at 50% 42%,
    #FFF5B7 0deg 15deg,
    #FFFADC 15deg 30deg
  );
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  overflow: hidden;
  perspective: 1000px;
}

.over-card-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes popCardUnfold {
  0% {
    opacity: 0;
    transform: rotateX(22deg) scale(0.92) translateY(16px);
  }
  100% {
    opacity: 1;
    transform: rotateX(0deg) scale(1) translateY(0);
  }
}

#share-canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0, 58, 94, 0.22);
  transform-origin: center bottom;
  animation: popCardUnfold 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.share-actions-2 {
  width: 100%;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 10px;
  flex-shrink: 0;
}

.share-feedback {
  font-size: 12px;
  color: #2D8982;
  font-weight: 700;
  min-height: 16px;
  text-align: center;
  flex-shrink: 0;
}
