/* Cloak Quest — UI поверх canvas, безопасно для Base App iframe */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  width: 100%;
  height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  background: #0a0a0f;
  color: #eee;
  -webkit-tap-highlight-color: transparent;
}

#gameCanvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
}

#ui-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: auto;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background: linear-gradient(180deg, #0a0a0f 0%, #1a1a2e 100%);
}

.screen.hidden { display: none; }
.screen.overlay { background: rgba(10, 10, 15, 0.92); }

.screen h1 { font-size: clamp(1.5rem, 5vw, 2.5rem); margin: 0; text-shadow: 0 0 20px rgba(100, 200, 255, 0.4); }
.screen h2 { font-size: clamp(1.2rem, 4vw, 1.8rem); margin: 0 0 0.5rem 0; }
.screen .subtitle { margin: 0 0 1.5rem 0; opacity: 0.85; }

.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.screen button {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
  border: 2px solid #4a9eff;
  background: transparent;
  color: #eee;
  border-radius: 8px;
  transition: background 0.15s, transform 0.1s;
  min-width: 120px;
}

.screen button:hover { background: rgba(74, 158, 255, 0.25); border-color: #6ab0ff; }
.screen button:active { transform: scale(0.97); background: rgba(74, 158, 255, 0.4); }
.screen button:focus { outline: 2px solid #4a9eff; outline-offset: 2px; }
.screen button.hidden { display: none; }

#btn-connect-wallet {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: #10b981;
  display: flex;
  align-items: center;
  justify-content: center;
}

#btn-connect-wallet:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  border-color: #059669;
}

#btn-connect-wallet:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#screen-menu .button-row { justify-content: center; gap: 1.25rem; }
#screen-menu button { min-width: 160px; padding: 1rem 1.75rem; font-size: 1.05rem; }

.settings-row { display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.settings-row span { min-width: 60px; text-align: right; }
.settings-row button { min-width: 80px; }

#screen-leaderboard ol { list-style: none; padding: 0; margin: 0 0 1rem 0; max-height: 50vh; overflow-y: auto; width: 100%; max-width: 320px; }
#screen-leaderboard li { padding: 0.5rem 1rem; margin: 0.25rem 0; background: rgba(255,255,255,0.06); border-radius: 6px; display: flex; justify-content: space-between; gap: 1rem; }

#screen-hud { justify-content: flex-start; align-items: stretch; background: transparent; padding: 0.75rem 1rem; }
#screen-hud.hidden { display: none; }
#hud-stats { display: flex; flex-wrap: wrap; gap: 1.25rem; font-size: 0.95rem; margin-bottom: 0.25rem; }
#controls-hint { font-size: 0.75rem; opacity: 0.7; margin-bottom: 0.5rem; color: #aaa; }
.hud-actions { justify-content: flex-end; margin-top: 0; }
#screen-hud button { min-width: 90px; }

#screen-level-end p, #screen-gameover p { margin: 0 0 0.5rem 0; opacity: 0.9; }
#gameover-name { padding: 0.5rem 0.75rem; font-size: 1rem; background: #1a1a2e; border: 2px solid #4a9eff; color: #eee; border-radius: 6px; width: 200px; max-width: 90vw; }
#screen-gameover label { margin-bottom: 0.25rem; font-size: 0.9rem; opacity: 0.9; }

/* Мобильное управление для iOS и Android — красивые кнопки */
.mobile-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  padding: 1.5rem;
  pointer-events: none;
  z-index: 20;
  gap: 1rem;
}

.mobile-controls.hidden { display: none; }

.mobile-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #4a9eff 0%, #6366f1 100%);
  color: #fff;
  font-size: 1.8rem;
  font-weight: bold;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(74, 158, 255, 0.4), 
              0 2px 4px rgba(0, 0, 0, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.mobile-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.15s;
}

.mobile-btn:active {
  transform: scale(0.85);
  box-shadow: 0 2px 6px rgba(74, 158, 255, 0.3), 
              0 1px 2px rgba(0, 0, 0, 0.2),
              inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mobile-btn:active::before {
  opacity: 1;
}

.mobile-left {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4), 
              0 2px 4px rgba(0, 0, 0, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.mobile-left:active {
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3), 
              0 1px 2px rgba(0, 0, 0, 0.2),
              inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mobile-right {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4), 
              0 2px 4px rgba(0, 0, 0, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.mobile-right:active {
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3), 
              0 1px 2px rgba(0, 0, 0, 0.2),
              inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mobile-jump {
  margin-left: auto;
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.5), 
              0 2px 4px rgba(0, 0, 0, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.3);
  font-size: 2rem;
}

.mobile-jump:active {
  box-shadow: 0 3px 8px rgba(16, 185, 129, 0.4), 
              0 1px 2px rgba(0, 0, 0, 0.2),
              inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mobile-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(74, 158, 255, 0.5), 
              0 2px 4px rgba(0, 0, 0, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

@media (min-width: 768px) {
  .mobile-controls { display: none !important; }
}

@media (max-width: 480px) {
  .mobile-btn {
    width: 65px;
    height: 65px;
    font-size: 1.6rem;
  }
  .mobile-jump {
    width: 75px;
    height: 75px;
    font-size: 1.8rem;
  }
  .mobile-controls {
    padding: 1.25rem;
  }
}

/* Статус кошелька */
.wallet-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.wallet-status.hidden { display: none; }

.wallet-status svg {
  color: #10b981;
  flex-shrink: 0;
}

.wallet-status span {
  font-family: 'Courier New', monospace;
  color: #10b981;
  word-break: break-all;
  flex: 1;
  text-align: center;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  min-width: auto;
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-small:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}
