*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #0a1628;
  color: #eef4ff;
}

#game-root {
  position: relative;
  width: 100%;
  height: 100%;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  transition: opacity 0.35s ease;
}

.screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.screen.overlay-dim {
  background: rgba(8, 16, 32, 0.55);
}

#screen-hud {
  align-items: flex-start;
  justify-content: center;
  pointer-events: none;
}

#screen-hud.active {
  pointer-events: none;
}

.screen-card {
  max-width: 34rem;
  width: 100%;
  padding: 2rem;
  border-radius: 1.25rem;
  background: rgba(12, 24, 48, 0.88);
  border: 1px solid rgba(140, 190, 255, 0.18);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  text-align: center;
}

.screen-card.compact {
  max-width: 26rem;
  padding: 1.5rem;
}

.screen-card h1,
.screen-card h2 {
  margin-bottom: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.screen-card p {
  margin-bottom: 1rem;
  line-height: 1.55;
  color: rgba(230, 240, 255, 0.88);
}

.screen-card .hint,
.cta-text {
  font-size: 0.95rem;
  color: rgba(190, 210, 240, 0.75);
}

.btn-primary {
  pointer-events: auto;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: #0a1628;
  background: linear-gradient(135deg, #9ed4ff, #6bb8ff);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(110, 180, 255, 0.35);
}

.btn-primary:active {
  transform: translateY(0);
}

.hud-top {
  position: absolute;
  top: 0.65rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1.25rem;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.1rem;
  border-radius: 999px;
  background: rgba(12, 24, 48, 0.72);
  border: 1px solid rgba(140, 190, 255, 0.16);
  backdrop-filter: blur(10px);
  pointer-events: none;
  width: max-content;
  max-width: calc(100% - 1.5rem);
}

.hud-stat {
  display: grid;
  grid-template-rows: 0.9rem 1.15rem;
  row-gap: 0.12rem;
  align-items: center;
  justify-items: center;
  min-width: 4rem;
}

.hud-stat .label {
  font-size: 0.72rem;
  line-height: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(190, 210, 240, 0.65);
}

.hud-stat span:last-child,
.hud-stat .meter-track {
  font-size: 1rem;
  font-weight: 600;
}

.calm-meter {
  min-width: 5.5rem;
}

.meter-track {
  width: 5.25rem;
  height: 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 100%;
  min-width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd08a, #9ed4ff);
  transition: width 0.25s ease;
}

.meter-fill.has-progress {
  min-width: 0.35rem;
}

.powerup-bar {
  position: absolute;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100% - 2rem);
  pointer-events: auto;
}

.powerup-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 4.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(140, 190, 255, 0.25);
  background: rgba(12, 24, 48, 0.78);
  color: #eef4ff;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.15s ease;
}

.powerup-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.powerup-btn:not(:disabled):hover {
  transform: translateY(-2px);
}

.powerup-btn .icon {
  font-size: 1.1rem;
}

.powerup-btn .name {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.powerup-btn .status {
  font-size: 0.62rem;
  color: rgba(190, 210, 240, 0.7);
}

.powerup-btn.active {
  border-color: rgba(158, 212, 255, 0.95);
  box-shadow: 0 0 22px rgba(110, 180, 255, 0.55);
  background: rgba(30, 60, 100, 0.92);
  animation: powerup-pulse 1s ease-in-out infinite;
}

@keyframes powerup-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.powerup-toast {
  position: absolute;
  left: 50%;
  bottom: 7rem;
  transform: translateX(-50%);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  background: rgba(20, 45, 80, 0.92);
  border: 1px solid rgba(158, 212, 255, 0.45);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  pointer-events: none;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  transition: opacity 0.25s ease;
}

.powerup-toast.hidden {
  opacity: 0;
  visibility: hidden;
}

.upgrade-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  margin-top: 0.5rem;
}

@media (min-width: 540px) {
  .upgrade-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.upgrade-card {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  padding: 1rem 1.1rem;
  border-radius: 1rem;
  border: 1px solid rgba(140, 190, 255, 0.22);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.upgrade-card:hover {
  border-color: rgba(158, 212, 255, 0.65);
  transform: translateY(-2px);
}

.upgrade-card h3 {
  margin-bottom: 0.35rem;
  font-size: 1rem;
  line-height: 1.25;
}

.upgrade-card p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  flex: 1;
}

.upgrade-card .tag {
  display: inline-block;
  align-self: flex-start;
  margin-top: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(110, 180, 255, 0.18);
}

.flick-hint {
  position: absolute;
  left: 50%;
  top: calc(50% + 5.5rem);
  transform: translateX(-50%);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: rgba(12, 24, 48, 0.72);
  border: 1px solid rgba(140, 190, 255, 0.2);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.65s ease, transform 0.65s ease;
}

.flick-hint.fade-out {
  opacity: 0;
  transform: translate(-50%, -0.75rem);
}

@media (max-width: 480px) {
  .screen-card {
    padding: 1.35rem;
  }

  .hud-top {
    gap: 0.75rem;
    padding: 0.55rem 0.85rem;
  }

  .hud-stat {
    min-width: 3.25rem;
  }

  .calm-meter {
    min-width: 5.5rem;
  }

  .hud-stat .label {
    font-size: 0.65rem;
  }

  .hud-stat span:last-child {
    font-size: 0.92rem;
  }
}

/* Greyscale blockout pass: keep layout, remove visual direction bias. */
html,
body {
  background: #e7e7e7;
  color: #f2f2f2;
}

.screen-card,
.hud-top,
.powerup-btn,
.powerup-toast,
.flick-hint {
  background: rgba(48, 48, 48, 0.88);
  border-color: rgba(210, 210, 210, 0.22);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.24);
}

.screen-card p,
.screen-card .hint,
.cta-text,
.hud-stat .label,
.powerup-btn .status {
  color: rgba(230, 230, 230, 0.72);
}

.btn-primary {
  color: #202020;
  background: #cfcfcf;
}

.btn-primary:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.meter-track {
  background: rgba(255, 255, 255, 0.16);
}

.meter-fill {
  background: #b8b8b8;
}

.powerup-btn {
  color: #f1f1f1;
}

.powerup-btn .icon {
  color: #d0d0d0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-weight: 700;
}

.powerup-btn.active {
  border-color: rgba(245, 245, 245, 0.75);
  background: rgba(70, 70, 70, 0.94);
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.24);
}

.upgrade-card {
  border-color: rgba(210, 210, 210, 0.24);
  background: rgba(255, 255, 255, 0.05);
}

.upgrade-card:hover {
  border-color: rgba(245, 245, 245, 0.65);
}

.upgrade-card .tag {
  background: rgba(230, 230, 230, 0.16);
}
