/* Global Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --sky: #d2e7ff;
  --cloud: #f7fbff;
  --ink: #1f2b38;
  --accent: #ff8a6c;
  --accent-2: #5cc8ff;
  --mint: #75d9b0;
  --gold: #ffce4d;
  --panel: rgba(255, 255, 255, 0.9);
  --line: #d9e3f5;
  --shadow: 0 10px 30px rgba(31, 43, 56, 0.18);
  --radius: 18px;
}

body {
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, #f8fbff 0%, #edf3ff 40%, #fef7ff 100%);
  min-height: 100vh;
  color: var(--ink);
  overflow-x: hidden;
  padding-top: 68px;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background: radial-gradient(
      700px 700px at 85% 10%,
      rgba(92, 200, 255, 0.25),
      transparent 65%
    ),
    radial-gradient(
      600px 600px at 15% 20%,
      rgba(255, 138, 108, 0.18),
      transparent 60%
    );
  z-index: 0;
}

body::after {
  background-image: radial-gradient(
    circle at 10px 10px,
    rgba(31, 43, 56, 0.05) 2px,
    transparent 0
  );
  background-size: 32px 32px;
  opacity: 0.6;
  z-index: 0;
}

.screen {
  display: none;
  min-height: 100vh;
  padding: 3rem 1.25rem 2rem;
  position: relative;
  z-index: 1;
}

.screen.active {
  display: block;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: linear-gradient(135deg, #ffffff, #eef4ff);
  border-bottom: 1px solid #dfe7f7;
  box-shadow: 0 6px 18px rgba(31, 43, 56, 0.08);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 5;
}

.header-title {
  font-family: "Baloo 2", "Nunito", system-ui, sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-logo {
  height: 40px;
  width: auto;
}

/* Use H logo on mobile for space savings */
@media (max-width: 768px) {
  .header-logo {
    content: url('./images/handyclicker_H.svg');
    height: 36px;
  }
}

.connection-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff6b6b;
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.6);
  transition: all 0.3s ease;
}

.connection-status.connected {
  background: var(--mint);
  box-shadow: 0 0 8px rgba(117, 217, 176, 0.6);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.auth-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.auth-user-label {
  font-size: 0.85rem;
  color: #7a8dad;
}

/* Hide auth label on mobile to save space */
@media (max-width: 768px) {
  .auth-user-label {
    display: none;
  }
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.75rem;
}

.auth-form .form-group {
  margin-bottom: 0;
}

.auth-form .form-group label {
  display: block;
  color: var(--ink);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #ffffff;
  border: 2px solid #d6def2;
  color: var(--ink);
  font-size: 1rem;
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: all 0.2s ease;
}

.auth-form input[type="email"]:focus,
.auth-form input[type="password"]:focus,
.auth-form input[type="text"]:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(92, 200, 255, 0.2);
}

.auth-form .btn-primary {
  margin-top: 0.5rem;
}

.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e6edf8;
}

.auth-switch p {
  color: #7a8dad;
  font-size: 0.95rem;
  margin: 0;
}

.auth-switch a {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 700;
  transition: all 0.2s ease;
}

.auth-switch a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.auth-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
}

.auth-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
}

.auth-actions .secondary {
  background: #eef2fb;
  color: var(--ink);
}

.btn-primary.secondary {
  background: #f5f8ff;
  color: var(--ink);
  border: 1px solid #dfe7f7;
}

.btn-primary.secondary:hover {
  background: #eef2fb;
}

.username-status {
  font-size: 0.85rem;
  margin-top: 0.5rem;
  min-height: 1.2rem;
  font-weight: 600;
}

.username-status.checking {
  color: #7a8dad;
}

.username-status.available {
  color: var(--mint);
}

.username-status.taken {
  color: var(--accent);
}

.connect-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 4;
  background: rgba(255, 255, 255, 0.85);
  padding-top: 64px;
}

.connect-card {
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #e6edf8;
  border-radius: 14px;
  padding: 1.4rem 1.6rem;
  box-shadow: 0 12px 24px rgba(31, 43, 56, 0.12);
  text-align: center;
  pointer-events: auto;
}

.connect-card h2 {
  font-size: 1.3rem;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.connect-card p {
  color: #7a8dad;
  font-size: 0.95rem;
}

.disconnected .game-content {
  pointer-events: none;
  filter: blur(1px);
  opacity: 0.55;
}

.stat-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 800;
  color: var(--ink);
  font-size: 1.05rem;
  padding: 0.25rem 0.55rem;
}

.stat-icon {
  width: 20px;
  height: 20px;
}

.multiplier-chip {
  height: 44px;
  padding: 0 1rem;
  border-radius: 22px;
  background: #fff6ed;
  border: 2px solid #ffdcca;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 800;
  color: var(--accent);
  box-shadow: 0 4px 10px rgba(31, 43, 56, 0.08);
  cursor: help;
  transition: all 0.2s ease;
}

.multiplier-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(31, 43, 56, 0.12);
}

.multiplier-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  opacity: 0.7;
}

.chip-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  background: #ffffff;
  color: var(--accent);
  font-weight: 800;
  border-radius: 12px;
  border: 1px solid #ffdcca;
  box-shadow: 0 4px 10px rgba(31, 43, 56, 0.06);
  cursor: pointer;
}

.chip-button.primary {
  background: linear-gradient(135deg, var(--accent-2), #64e4ff);
  color: #ffffff;
  border-color: transparent;
}

.chip-button.secondary {
  background: #f5f8ff;
  border-color: #dfe7f7;
  color: var(--ink);
}

.chip-button.btn-danger {
  background: linear-gradient(145deg, #ff6b6b, #ee5a52);
  color: #ffffff;
  border-color: #ee5a52;
}

.chip-button.btn-danger:hover {
  background: linear-gradient(145deg, #ff5252, #e04848);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(238, 90, 82, 0.3);
}

.container {
  max-width: 920px;
  margin: 0 auto;
}

/* Setup Typography */
h1.glitch {
  font-family: "Baloo 2", "Nunito", system-ui, sans-serif;
  font-size: 2.75rem;
  text-align: center;
  color: var(--ink);
  letter-spacing: 2px;
  margin-bottom: 1.5rem;
  position: relative;
  display: inline-block;
  padding: 0.4rem 1.2rem;
  background: linear-gradient(135deg, #ffffff, #e4ecff);
  border: 3px solid #cdd8f2;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

h2,
h3 {
  color: #657a99;
  text-align: center;
  margin: 0.75rem 0 1.25rem;
  letter-spacing: 1px;
  font-weight: 700;
}

/* Form Elements */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  color: #5a6b85;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  padding: 0.85rem 1rem;
  background: #ffffff;
  border: 2px solid #d6def2;
  color: var(--ink);
  font-size: 1rem;
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: all 0.2s ease;
}

input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(92, 200, 255, 0.2);
}

input[type="range"] {
  width: 100%;
  height: 8px;
  background: #e3e9f7;
  border-radius: 999px;
  outline: none;
  -webkit-appearance: none;
  position: relative;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, var(--accent-2), #7be2ff);
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(92, 200, 255, 0.4);
  cursor: pointer;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: #7487a2;
  margin-top: 0.35rem;
}

.error-message {
  color: #d9534f;
  font-size: 0.82rem;
  margin-top: 0.35rem;
  min-height: 1rem;
}

/* Buttons */
.btn-primary,
.btn-action,
.btn-lost {
  padding: 0.75rem 1.2rem;
  font-family: "Baloo 2", "Nunito", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  transition: transform 0.1s ease, box-shadow 0.2s ease, filter 0.15s ease;
  box-shadow: var(--shadow);
}

.btn-primary {
  width: 100%;
  margin-top: 1rem;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent-2), #64e4ff);
}

.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-action {
  position: relative;
  overflow: hidden;
  flex: 1;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 3px solid #e5ecfb;
  background: linear-gradient(160deg, #ffffff, #eef3ff);
}

.btn-action:hover:not(.on-cooldown) {
  transform: translateY(-2px);
  filter: brightness(1.02);
}

.btn-icon {
  width: 48px;
  height: 48px;
  opacity: 0.95;
  transition: transform 0.2s ease;
}

.btn-action:hover:not(.on-cooldown) .btn-icon {
  transform: translateY(-4px);
}

.burst-btn {
  color: #ffffff;
  background: linear-gradient(145deg, #5cc8ff, #4fb0ff);
  border-color: #cde6ff;
}

.burst-btn.on-cooldown {
  cursor: not-allowed;
  color: #9bb3cc;
  background: linear-gradient(145deg, #e5ecfb, #dbe4f8);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.8);
}

.edge-btn {
  color: #ffffff;
  background: linear-gradient(145deg, #ff9779, #ff7c6c);
  border-color: #ffd6c7;
}

.edge-btn.on-cooldown,
.tease-btn.on-cooldown {
  cursor: not-allowed;
  color: #9bb3cc;
  background: linear-gradient(145deg, #e5ecfb, #dbe4f8);
}

.btn-action.locked {
  cursor: not-allowed;
  opacity: 0.4;
  filter: grayscale(0.7);
  pointer-events: none;
}

.tease-btn {
  color: #ffffff;
  background: linear-gradient(145deg, #75d9b0, #5fc89e);
  border-color: #cff1df;
}

.mercy-btn {
  color: #ffffff;
  background: linear-gradient(145deg, #9d7fff, #8566ff);
  border-color: #ddd3ff;
}

.mercy-btn.on-cooldown {
  cursor: not-allowed;
  color: #9bb3cc;
  background: linear-gradient(145deg, #e5ecfb, #dbe4f8);
}

.btn-action .cost {
  font-size: 0.85rem;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.1);
  padding: 0.2rem 0.8rem;
  border-radius: 12px;
}

.cooldown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 0%;
  height: 100%;
  background: rgba(255, 255, 255, 0.35);
  transition: width linear;
  pointer-events: none;
}

.btn-lost {
  width: 100%;
  margin-top: 0.75rem;
  color: #ffffff;
  background: linear-gradient(145deg, #ff7c6c, #f25d6c);
  border: none;
}

.btn-lost:hover {
  transform: translateY(-1px);
}

/* Layout */
.game-content {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: opacity 0.3s ease;
}

.top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: stretch;
}

/* Stack top-row on mobile with score on top */
@media (max-width: 768px) {
  .top-row {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  .score-column {
    order: -1;
  }
}

.panel-block {
  background: #ffffff;
  border: 2px solid #e6edf8;
  border-radius: 16px;
  box-shadow: 0 12px 24px rgba(31, 43, 56, 0.08);
  padding: 1.1rem 1.25rem;
  height: 100%;
}

.score-column .panel-block {
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-dropdown {
  position: fixed;
  top: 64px;
  right: 1.5rem;
  z-index: 100;
}

.settings-panel {
  position: relative;
  min-width: 280px;
  background: #ffffff;
  border: 2px solid #e6edf8;
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(31, 43, 56, 0.12);
  padding: 0.85rem 0.95rem;
  z-index: 10;
}

.settings-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.settings-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  color: var(--ink);
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-text {
  font-size: 0.9rem;
  color: #7a8dad;
}

/* Menu Dropdown */
.menu-dropdown {
  position: relative;
}

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  background: #ffffff;
  border: 2px solid #e6edf8;
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(31, 43, 56, 0.12);
  padding: 0.5rem;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.menu-panel[hidden] {
  display: none;
}

.menu-item {
  background: transparent;
  border: none;
  padding: 0.75rem 1rem;
  text-align: left;
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.menu-item:hover {
  background: rgba(92, 200, 255, 0.1);
  color: var(--accent-2);
}

.controls-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
}

.status-message {
  text-align: center;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #f8fbff, #eef4ff);
  border: 2px solid #dbe4f8;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-2);
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(31, 43, 56, 0.06);
  transition: all 0.3s ease;
}

.status-message.prominent {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff4e6, #ffe7cc);
  border: 3px solid #ff9933;
  color: #d97706;
  box-shadow: 0 6px 20px rgba(255, 153, 51, 0.3),
    0 0 15px rgba(255, 153, 51, 0.2);
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: 0 6px 20px rgba(255, 153, 51, 0.3),
      0 0 15px rgba(255, 153, 51, 0.2);
  }
  50% {
    box-shadow: 0 6px 25px rgba(255, 153, 51, 0.4),
      0 0 20px rgba(255, 153, 51, 0.3);
  }
}

.score-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
  justify-content: flex-start;
  position: relative;
}

.score-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.multiplier-badge {
  background: #fff6ed;
  border: 2px solid #ffdcca;
  border-radius: 10px;
  padding: 0.35rem 0.65rem;
  font-weight: 800;
  color: var(--accent);
  font-size: 0.95rem;
  box-shadow: 0 2px 6px rgba(31, 43, 56, 0.06);
  cursor: help;
}

.timer-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: #ffffff;
  border: 2px solid #e6edf8;
  border-radius: 10px;
  padding: 0.35rem 0.65rem;
  font-weight: 800;
  color: var(--ink);
  font-size: 0.95rem;
  box-shadow: 0 2px 6px rgba(31, 43, 56, 0.06);
}

.timer-badge .stat-icon {
  width: 18px;
  height: 18px;
}

.card {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  margin-bottom: 0.75rem;
}

.card-heading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.card-sub {
  color: #7a8dad;
  font-size: 0.95rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.55rem;
  border-radius: 10px;
  background: #eef4ff;
  color: #6883b0;
  font-weight: 800;
  font-size: 0.82rem;
}

.distance-card {
  display: none;
  background: #ffffff;
  border: 1px solid #e6edf8;
  border-radius: var(--radius);
  box-shadow: 0 8px 18px rgba(31, 43, 56, 0.08);
  padding: 1rem 1.1rem;
}

.distance-card.is-open {
  display: block;
}

.distance-card .form-group {
  margin-bottom: 0;
}

.form-group.compact label {
  color: #5a6b85;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.form-group.compact .hint {
  color: #90a2be;
  font-size: 0.85rem;
  font-weight: 600;
}

/* PP Display */
.pp-display {
  text-align: center;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  border-radius: 0;
  box-shadow: none;
}

.pp-display.flat {
  text-align: center;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.pp-total {
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
}

.pp-icon {
  width: 76px;
  height: 76px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-8px);
  }
}

.pp-total .label {
  color: #70829c;
  font-size: 1.2rem;
}

.pp-total .value {
  color: var(--gold);
  font-size: 3.4rem;
  font-weight: 800;
  text-shadow: none;
  font-variant-numeric: tabular-nums;
  transition: color 0.15s ease;
}

.pp-rate {
  color: #7a8dad;
  font-size: 1.15rem;
  font-weight: 700;
}

.total-score {
  text-align: center;
  padding-top: 0.75rem;
  border-top: 1px solid #e6edf8;
  margin-top: 0.5rem;
}

.total-score-label {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  margin-right: 0.5rem;
}

.total-score-value {
  color: var(--accent-2);
  font-size: 1.1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 0.75rem;
  justify-content: center;
  flex-wrap: nowrap;
}

.action-buttons .btn-action {
  flex: 1;
  min-width: 0;
}

.actions-card .action-buttons {
  margin: 0;
}

/* Upgrades */
.upgrades-section {
  margin: 0.75rem 0 0;
  padding: 0.75rem;
  background: #ffffff;
  border-radius: 16px;
  border: 2px solid #e6edf8;
  box-shadow: 0 12px 24px rgba(31, 43, 56, 0.08);
}

.upgrades-section.panel-block {
  height: auto;
}

.upgrades-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.6rem;
}

.upgrade-item {
  padding: 0.75rem;
  border: 2px solid #e4ebfa;
  background: #ffffff;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease,
    border-color 0.16s ease, background 0.16s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  position: relative;
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(31, 43, 56, 0.08);
}

.upgrade-item:hover:not(.purchased):not(.locked) {
  transform: translateY(-3px);
  border-color: var(--accent-2);
  box-shadow: 0 12px 24px rgba(92, 200, 255, 0.16);
}

.upgrade-item:active:not(.purchased):not(.locked) {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(31, 43, 56, 0.12);
  border-color: var(--accent);
  background: radial-gradient(
    circle at top,
    rgba(255, 138, 108, 0.12),
    #ffffff 55%
  );
}

.upgrade-item.purchased {
  border-color: #cdebd9;
  background: linear-gradient(145deg, #f3fff8, #e8f8ef);
  opacity: 0.9;
  cursor: default;
}

.upgrade-item.locked {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: #d0d0d0;
  filter: grayscale(0.8);
  background: linear-gradient(145deg, #e8e8e8, #dcdcdc);
}

.upgrade-item.locked::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius);
  pointer-events: none;
}

.upgrade-lock-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  opacity: 0.9;
}

.upgrade-icon {
  width: 54px;
  height: 54px;
  transition: transform 0.2s ease;
}

.upgrade-item:hover:not(.purchased):not(.locked) .upgrade-icon {
  transform: translateY(-3px);
}

.upgrade-name {
  color: var(--ink);
  font-weight: 800;
  font-size: 0.95rem;
  text-align: center;
  line-height: 1.2;
}

.upgrade-cost {
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 800;
  text-align: center;
  padding: 0.15rem 0.6rem;
  background: rgba(255, 138, 108, 0.12);
  border-radius: 999px;
}

.upgrade-item.locked .upgrade-cost {
  color: #8fa1b8;
  background: #eef2fb;
}

.upgrade-item.purchased .upgrade-icon {
  filter: brightness(0.85);
}

.upgrade-item.locked .upgrade-icon {
  filter: grayscale(100%) opacity(0.7);
}

.upgrade-item.purchased::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 16px;
  background: radial-gradient(
    circle at top,
    rgba(117, 217, 176, 0.45),
    transparent 60%
  );
  opacity: 0;
  pointer-events: none;
  animation: upgradeFlash 0.45s ease-out;
}

@keyframes upgradeFlash {
  0% {
    opacity: 0.85;
    transform: scale(0.96);
  }
  100% {
    opacity: 0;
    transform: scale(1.02);
  }
}

/* Pattern Modals */
.pattern-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  pointer-events: auto;
  overflow-y: auto;
  padding: 2rem 1rem;
}

.pattern-modal-content {
  background: #ffffff;
  border: 3px solid #dbe4f8;
  padding: 2.4rem 3rem;
  text-align: center;
  box-shadow: var(--shadow);
  border-radius: 16px;
  max-height: 90vh;
  overflow-y: auto;
  margin: auto;
}

.pattern-modal-content h2 {
  color: var(--accent-2);
  margin-bottom: 1rem;
  font-size: 2rem;
}

.pattern-name-display {
  color: var(--ink);
  font-size: 2.8rem;
  font-weight: 800;
  margin: 1.5rem 0;
  letter-spacing: 2px;
}

.pattern-message {
  color: #7385a2;
  font-size: 1rem;
  margin-top: 1rem;
}

/* Confirmation Modal */
.confirm-modal-content {
  max-width: 480px;
  width: 90%;
}

.confirm-stats {
  background: linear-gradient(145deg, #f8fbff, #f0f5ff);
  border: 2px solid #dbe4f8;
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.confirm-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #e8eef7;
}

.confirm-stat-row:last-child {
  border-bottom: none;
}

.confirm-label {
  font-weight: 600;
  color: var(--ink);
  opacity: 0.8;
  font-size: 0.95rem;
}

.confirm-value {
  font-weight: 700;
  color: var(--accent-2);
  font-size: 1.1rem;
}

.confirm-message {
  color: #7385a2;
  font-size: 1rem;
  margin: 1rem 0 1.5rem;
  line-height: 1.5;
}

.confirm-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.confirm-buttons button {
  flex: 1;
  max-width: 200px;
}

.btn-danger {
  background: linear-gradient(145deg, #ff6b6b, #ee5a52) !important;
  border-color: #ee5a52 !important;
}

.btn-danger:hover {
  background: linear-gradient(145deg, #ff5252, #e04848) !important;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(238, 90, 82, 0.3) !important;
}

/* End Screen */
.final-stats {
  margin: 2rem 0;
  padding: 1.8rem;
  border: 3px solid #e0e8fa;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px dashed #d7deef;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row .label {
  color: #6c7d98;
  font-weight: 700;
}

.stat-row .value {
  color: var(--ink);
  font-weight: 800;
}

.stat-row.final-score {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px solid #ffd6c7;
  font-size: 1.45rem;
}

.stat-row.final-score .label {
  color: var(--accent);
}

.stat-row.final-score .value {
  color: var(--accent);
  font-weight: 900;
}

/* Leaderboard */
#leaderboard-section {
  margin: 1.75rem 0;
}

.leaderboard-list {
  margin-top: 0.85rem;
  padding: 1rem;
  border: 2px solid #e0e8fa;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-height: 360px;
  overflow-y: auto;
}

.leaderboard-entry {
  display: flex;
  justify-content: space-between;
  padding: 0.55rem 0.35rem;
  border-bottom: 1px dashed #d7deef;
}

.leaderboard-entry:last-child {
  border-bottom: none;
}

.leaderboard-rank {
  color: var(--accent-2);
  font-weight: 800;
  min-width: 50px;
}

.leaderboard-score {
  color: var(--ink);
  font-weight: 800;
}

.end-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  pointer-events: auto;
  overflow-y: auto;
  padding: 2rem 1rem;
}

.end-modal-content {
  background: #ffffff;
  padding: 1.8rem 2rem;
  border-radius: 16px;
  border: 2px solid #e6edf8;
  box-shadow: 0 14px 30px rgba(31, 43, 56, 0.18);
  width: min(480px, 90vw);
  text-align: center;
  max-height: 90vh;
  overflow-y: auto;
  margin: auto;
}

.end-modal-content h2 {
  font-size: 1.6rem;
  margin-bottom: 1rem;
  color: var(--ink);
}

/* Toast Notifications */
.toast {
  min-width: 280px;
  padding: 1rem 1.25rem;
  background: #ffffff;
  border: 2px solid #e6edf8;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(31, 43, 56, 0.15);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-left: 4px solid var(--mint);
}

.toast.error {
  border-left: 4px solid var(--accent);
}

.toast.info {
  border-left: 4px solid var(--accent-2);
}

.toast-icon {
  font-size: 1.5rem;
}

.toast-message {
  flex: 1;
  color: var(--ink);
  font-weight: 600;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

/* Responsive */
@media (max-width: 720px) {
  h1.glitch {
    font-size: 2.1rem;
  }

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

  /* Keep action buttons in a row on mobile - they fit in 2x2 grid */
  .action-buttons {
    flex-wrap: wrap;
  }

  .btn-action {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }

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

  .screen {
    padding: 2.2rem 1rem;
  }
}

/* Footer */
.app-footer {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 1rem 1.5rem 1rem;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.5));
}

.app-footer p {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  color: var(--ink);
  opacity: 0.8;
}

.app-footer a {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
}

.app-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-disclaimer {
  font-size: 0.8rem !important;
  opacity: 0.6 !important;
  margin-top: 0.25rem !important;
}

/* Donation Section */
.donation-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.donate-link {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.donate-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.donate-link:active {
  transform: translateY(0);
}

.end-donation-prompt {
  margin: 1.5rem 0;
  padding: 1rem;
  background: rgba(102, 126, 234, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(102, 126, 234, 0.2);
}

.donate-link-small {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.donate-link-small:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Crypto Wallet Styles */
.crypto-wallets {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.wallet-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 1rem;
}

.wallet-header {
  margin-bottom: 0.75rem;
}

.wallet-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent-2);
}

.wallet-address-container {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.wallet-address {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 0.75rem;
  color: var(--ink);
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
  word-break: break-all;
}

.copy-btn {
  background: var(--accent-2);
  color: white;
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.copy-btn:hover {
  background: var(--accent);
  transform: translateY(-1px);
}

.copy-btn:active {
  transform: translateY(0);
}

/* Feedback Form Styles */
.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.feedback-form textarea {
  resize: vertical;
  min-height: 120px;
  font-family: "Nunito", system-ui, sans-serif;
}

.feedback-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.feedback-actions button {
  flex: 1;
}

.success-message {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
  border-radius: 6px;
  padding: 0.75rem;
  margin: 0.5rem 0;
  font-size: 0.9rem;
  text-align: center;
}

/* Welcome Screen Styles */
.welcome-content {
  text-align: center;
}

.welcome-info {
  text-align: left;
  margin: 1.5rem 0;
}

.welcome-notice {
  background: rgba(92, 200, 255, 0.1);
  border: 2px solid rgba(92, 200, 255, 0.3);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
}

.welcome-notice p {
  margin: 0 0 0.5rem 0;
  font-weight: 600;
  color: var(--accent);
}

.welcome-notice ul {
  line-height: 1.8;
}

.welcome-notice li {
  margin: 0.25rem 0;
}

.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.5rem 0 1rem;
}

.welcome-skip {
  background: transparent;
  border: none;
  color: #999;
  font-size: 0.9rem;
  padding: 0.5rem;
  cursor: pointer;
  transition: color 0.2s ease;
}

.welcome-skip:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

/* Demo End Message */
.demo-end-message {
  margin: 1.5rem 0;
  padding: 1.5rem;
  background: rgba(92, 200, 255, 0.05);
  border: 2px solid rgba(92, 200, 255, 0.3);
  border-radius: 12px;
  text-align: center;
}

.demo-end-message ul {
  list-style: none;
  padding: 0;
}

.demo-end-message li {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
  position: relative;
}

.demo-end-message li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--mint);
  font-weight: bold;
}

/* Leaderboard Styles */
.leaderboard-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #e6edf8;
}

.leaderboard-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0.75rem 1rem;
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: #7a8dad;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
}

.leaderboard-tab:hover {
  color: var(--accent-2);
}

.leaderboard-tab.active {
  color: var(--accent-2);
  border-bottom-color: var(--accent-2);
}

.leaderboard-container {
  max-height: 400px;
  overflow-y: auto;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.leaderboard-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid #e6edf8;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.leaderboard-entry:hover {
  background: rgba(92, 200, 255, 0.05);
}

.leaderboard-entry.current-user {
  background: rgba(92, 200, 255, 0.1);
  border-color: var(--accent-2);
}

.leaderboard-rank {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-2);
  min-width: 32px;
  text-align: center;
  flex-shrink: 0;
}

.leaderboard-name {
  flex: 1;
  font-weight: 600;
  color: var(--ink);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-stat {
  font-size: 0.85rem;
  color: #7a8dad;
  min-width: 60px;
  text-align: right;
  flex-shrink: 0;
}

.leaderboard-score {
  font-weight: 700;
  color: var(--accent-2);
  font-size: 0.95rem;
  min-width: 70px;
  text-align: right;
  flex-shrink: 0;
}

/* Mobile leaderboard simplification */
@media (max-width: 768px) {
  /* Make leaderboard modal full width on mobile */
  #leaderboard-modal .pattern-modal-content {
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 1rem 0.5rem;
    border-radius: 0;
    max-height: 100vh;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  #leaderboard-modal h2 {
    font-size: 1.4rem;
    padding: 0 0.5rem;
  }

  .leaderboard-tabs {
    padding: 0 0.5rem;
    margin-bottom: 0.75rem;
    gap: 0.25rem;
  }

  .leaderboard-tab {
    padding: 0.5rem 0.25rem;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .leaderboard-container {
    padding: 0;
  }

  .leaderboard-list {
    padding: 0 0.5rem;
    border: none;
    background: transparent;
  }

  .leaderboard-entry {
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
  }

  .leaderboard-rank {
    font-size: 0.95rem;
    min-width: 30px;
  }

  .leaderboard-name {
    font-size: 0.9rem;
  }

  /* Hide the stat column on mobile - only show rank, name, score */
  .leaderboard-stat {
    display: none;
  }

  .leaderboard-score {
    font-size: 0.9rem;
    min-width: auto;
  }

  /* Close button */
  #leaderboard-modal .btn-primary {
    margin: 0.5rem;
    width: calc(100% - 1rem);
    box-sizing: border-box;
  }
}

/* Account Management Styles */
.account-info {
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.account-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.account-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #7a8dad;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.account-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid #e6edf8;
  border-radius: 8px;
}

.account-danger-zone {
  margin-top: 2rem;
  padding: 1.5rem;
  background: rgba(255, 138, 108, 0.05);
  border: 2px solid rgba(255, 138, 108, 0.3);
  border-radius: 12px;
}

.btn-danger {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger:hover {
  background: #e85d4a;
  transform: translateY(-1px);
}

.btn-danger:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}
