@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;900&display=swap');

:root {
  /* Vibrant Bubbly Theme Palette */
  --bg-top: #00f2fe;
  --bg-bottom: #4facfe;
  --panel-bg: rgba(255, 255, 255, 0.25);
  --panel-border: rgba(255, 255, 255, 0.5);
  
  --text-dark: #1e3a8a;
  --text-light: #ffffff;
  
  --btn-blue: linear-gradient(to bottom, #7dd3fc 0%, #0ea5e9 100%);
  --btn-blue-shadow: #0284c7;
  
  --btn-yellow: linear-gradient(to bottom, #fde047 0%, #eab308 100%);
  --btn-yellow-shadow: #ca8a04;
  
  --btn-pink: linear-gradient(to bottom, #f9a8d4 0%, #db2777 100%);
  --btn-pink-shadow: #be185d;
  
  --btn-green: linear-gradient(to bottom, #a7f3d0 0%, #10b981 100%);
  --btn-green-shadow: #059669;
  
  --gold-bg: #fef08a;
  --gold-accent: #eab308;

  /* Typography */
  --font-doodle: 'Nunito', 'Segoe UI', 'Comic Sans MS', sans-serif;
  --font-body: 'Nunito', 'Segoe UI', sans-serif;
  --font-mono: 'Nunito', monospace;

  /* Geometry */
  --hud-height: 80px;
}

/* Reset & Global Viewport */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #061527;
  font-family: var(--font-doodle);
  color: var(--text-light);
  touch-action: none;
}

#game-wrapper {
  width: 100vw;
  height: 100vh;
  width: 100dvw;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  background: #061527;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
}

#game-canvas, #game-canvas-3d, #bg-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#bg-canvas {
  z-index: 1;
}

#game-canvas-3d {
  z-index: 2;
  pointer-events: none;
}

#game-canvas {
  z-index: 3;
  image-rendering: auto;
  cursor: crosshair;
}

/* Top Shop Ribbon HUD (Mobile Game Style) */
#shop-hud {
  position: absolute;
  top: clamp(8px, 2vh, 20px);
  left: clamp(8px, 2vw, 25px);
  right: clamp(8px, 2vw, 25px);
  height: auto;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 10;
  pointer-events: auto;
}

/* Coin / Location Badges */
.hud-badges-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 1;
  min-width: 0;
}

#hud-coin-badge, .hud-coin-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(4, 18, 38, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 40px;
  padding: 5px 14px 5px 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  white-space: nowrap;
}

.coin-icon {
  font-size: 22px;
  display: flex;
  align-items: center;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

#location-name {
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#coin-counter, #hud-shells {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Shop Ribbon Slot Buttons */
#shop-ribbon {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.shop-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--btn-blue);
  border: 2.5px solid #fff;
  border-radius: 18px;
  padding: 6px 12px;
  min-width: 60px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--btn-blue-shadow), 0 8px 12px rgba(0,0,0,0.3);
  transition: all 0.1s ease;
  font-family: var(--font-doodle);
  color: #fff;
  white-space: nowrap;
}

.shop-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.shop-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 0px 0 var(--btn-blue-shadow), 0 2px 4px rgba(0,0,0,0.3);
}

.shop-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(1);
  box-shadow: 0 4px 0 #666;
}

.slot-icon {
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.3));
  display: flex;
  align-items: center;
}

.slot-price {
  font-size: 13px;
  font-weight: 900;
  margin-top: 2px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* General Action Buttons */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  background: var(--btn-pink);
  border: 3px solid #fff;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--btn-pink-shadow), 0 10px 15px rgba(0,0,0,0.3);
  transition: transform 0.1s ease;
  color: white;
}

.icon-btn:hover {
  transform: translateY(-3px) scale(1.05);
}

.icon-btn:active {
  transform: translateY(6px);
  box-shadow: 0 0px 0 var(--btn-pink-shadow), 0 4px 5px rgba(0,0,0,0.3);
}

/* Modals */
#modal-layer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(3, 14, 28, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 24px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y !important;
  box-sizing: border-box;
}

#modal-layer > * {
  margin: auto;
}

.modal-layer-hidden {
  display: none !important;
}

.sketch-modal-card {
  position: relative;
  width: 92%;
  max-width: 500px;
  max-height: min(92vh, 760px);
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  background: linear-gradient(180deg, #ffffff 0%, #e0f2fe 100%);
  border: 5px solid #fff;
  border-radius: 36px;
  padding: 36px 26px 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  font-family: var(--font-doodle);
  color: var(--text-dark);
  text-align: center;
  animation: modalPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  touch-action: pan-y !important;
  overscroll-behavior: contain;
}

/* ========================================================
   DEDICATED SHOP MODAL STYLES
   ======================================================== */
.shop-modal-card {
  max-width: 680px !important;
  max-height: min(85vh, 640px) !important;
  padding: 22px 20px 18px !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  border-radius: 32px !important;
  box-shadow: 0 24px 60px rgba(0, 20, 50, 0.6) !important;
  pointer-events: auto !important;
  overscroll-behavior: contain !important;
}

.modal-corner-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 36px;
  height: 36px;
  background: rgba(3, 105, 161, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  color: #0369a1;
  font-size: 16px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 20;
}
.modal-corner-close-btn:hover {
  background: #ef4444;
  color: #fff;
  transform: scale(1.08);
}

.shop-header {
  margin-bottom: 12px;
  text-align: center;
  flex-shrink: 0;
}

.shop-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.shop-header-icon {
  font-size: 28px;
}

.shop-title {
  font-size: 26px;
  font-weight: 900;
  color: #0c4a6e;
  margin: 0;
  letter-spacing: -0.5px;
}

.shop-balance-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #fff;
  padding: 6px 18px;
  border-radius: 20px;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.25);
  margin-top: 8px;
  font-size: 14px;
  font-weight: 700;
}

.shop-balance-pill b {
  font-size: 18px;
  color: #fef08a;
  letter-spacing: 0.5px;
}

.shop-scroll-area {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y !important;
  pointer-events: auto !important;
  padding: 8px 6px 12px;
  margin: 4px -4px;
  overscroll-behavior: contain;
}

.shop-scroll-area::-webkit-scrollbar {
  width: 8px;
}
.shop-scroll-area::-webkit-scrollbar-track {
  background: rgba(3, 105, 161, 0.06);
  border-radius: 10px;
}
.shop-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(2, 132, 199, 0.35);
  border-radius: 10px;
}
.shop-scroll-area::-webkit-scrollbar-thumb:hover {
  background: rgba(2, 132, 199, 0.6);
}

.shop-items-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (max-width: 520px) {
  .shop-items-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .shop-modal-card {
    padding: 20px 14px 16px !important;
  }
}

.shop-item-card {
  background: #ffffff;
  border: 2px solid #bae6fd;
  border-radius: 20px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(3, 105, 161, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
  text-align: left;
}

.shop-item-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(3, 105, 161, 0.16);
  border-color: #38bdf8;
}

.shop-item-card.locked {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.shop-item-card.unlocked {
  border-color: #facc15;
}

/* Прогресс трофеев в модалке достижений (переведено из инлайн-стилей
   js/ui/ModalManager.js, п.21 аудита). Ширина и цвет заливки динамические —
   их ModalManager выставляет через style.setProperty (CSSOM, CSP разрешает). */
.ach-progress-block {
  margin-top: 8px;
}
.ach-progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.85;
  margin-bottom: 4px;
}
.ach-progress-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  overflow: hidden;
}
.ach-progress-fill {
  height: 100%;
  width: var(--ach-w, 0%);
  background: var(--ach-color, #38bdf8);
  border-radius: 6px;
  transition: width .3s;
}

.shop-item-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.shop-item-icon {
  font-size: 28px;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f9ff;
  border-radius: 14px;
  border: 2px solid #e0f2fe;
  flex-shrink: 0;
}

.shop-item-title-box {
  flex: 1;
  min-width: 0;
}

.shop-item-name {
  font-size: 16px;
  font-weight: 900;
  color: #0c4a6e;
  line-height: 1.2;
}

.shop-item-badge {
  font-size: 11px;
  font-weight: 700;
  color: #0284c7;
  display: block;
  margin-top: 2px;
}

.shop-item-desc {
  font-size: 12px;
  color: #64748b;
  line-height: 1.35;
  margin: 0 0 10px;
  flex-grow: 1;
}

.shop-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

.shop-item-price {
  font-size: 15px;
  font-weight: 900;
  color: #0369a1;
  display: flex;
  align-items: center;
  gap: 4px;
}

.shop-buy-btn {
  background: var(--btn-green);
  box-shadow: 0 4px 0 var(--btn-green-shadow);
  color: #fff;
  border: 2px solid #fff;
  border-radius: 14px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.1s;
  font-family: var(--font-doodle);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.shop-buy-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--btn-green-shadow);
}

.shop-buy-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--btn-green-shadow);
}

.shop-buy-btn:disabled {
  background: #cbd5e1;
  box-shadow: 0 3px 0 #94a3b8;
  color: #64748b;
  cursor: not-allowed;
  opacity: 0.85;
}

.shop-footer {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(3, 105, 161, 0.1);
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

.shop-close-btn {
  font-size: 16px !important;
  padding: 10px 32px !important;
  box-shadow: 0 5px 0 var(--btn-blue-shadow) !important;
}

.sketch-modal-card::-webkit-scrollbar {
  width: 6px;
}
.sketch-modal-card::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
}
.sketch-modal-card::-webkit-scrollbar-thumb {
  background: rgba(2, 132, 199, 0.3);
  border-radius: 10px;
}

.modal-tape {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--btn-yellow);
  border: 3px solid #fff;
  color: #713f12;
  padding: 8px 30px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-radius: 30px;
  box-shadow: 0 5px 0 var(--btn-yellow-shadow), 0 10px 15px rgba(0,0,0,0.3);
}

.modal-tape.danger-tape {
  background: var(--btn-pink);
  box-shadow: 0 5px 0 var(--btn-pink-shadow);
  color: #fff;
}

.modal-tape.success-tape {
  background: var(--btn-green);
  box-shadow: 0 5px 0 var(--btn-green-shadow);
  color: #fff;
}

.modal-title {
  font-size: 34px;
  font-weight: 900;
  margin-top: 10px;
  margin-bottom: 10px;
  color: var(--text-dark);
}

.modal-subtitle {
  font-size: 18px;
  font-weight: 700;
  opacity: 0.8;
  margin-bottom: 25px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 30px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.6);
  border: 3px solid #fff;
  border-radius: 20px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 8px 15px rgba(0,0,0,0.1);
  transition: transform 0.1s;
}
.stat-card:active {
  transform: scale(0.95);
}

.stat-card.full-width {
  grid-column: span 2;
}

.stat-label {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-dark);
}

.stat-value {
  font-size: 26px;
  font-weight: 900;
  color: #0369a1;
  margin-top: 5px;
}

/* Action Buttons */
.modal-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

.sketch-btn {
  font-size: 20px;
  font-weight: 900;
  padding: 12px 30px;
  border-radius: 30px;
  border: 3px solid #fff;
  cursor: pointer;
  color: #fff;
  text-transform: uppercase;
  transition: all 0.1s;
  font-family: var(--font-doodle);
}

.btn-primary { background: var(--btn-blue); box-shadow: 0 6px 0 var(--btn-blue-shadow); }
.btn-primary:active { transform: translateY(6px); box-shadow: 0 0 0 var(--btn-blue-shadow); }

.btn-success { background: var(--btn-green); box-shadow: 0 6px 0 var(--btn-green-shadow); }
.btn-success:active { transform: translateY(6px); box-shadow: 0 0 0 var(--btn-green-shadow); }

.btn-danger { background: var(--btn-pink); box-shadow: 0 6px 0 var(--btn-pink-shadow); }
.btn-danger:active { transform: translateY(6px); box-shadow: 0 0 0 var(--btn-pink-shadow); }

.btn-secondary { background: linear-gradient(to bottom, #d1d5db, #9ca3af); box-shadow: 0 6px 0 #6b7280; }
.btn-secondary:active { transform: translateY(6px); box-shadow: 0 0 0 #6b7280; }

@keyframes modalPopIn {
  0% { opacity: 0; transform: scale(0.8); }
  70% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 1; transform: scale(1); }
}

/* ========================================================
   CAPTURE & CONNECT MODAL (POPUP)
   ======================================================== */
#capture-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 14, 28, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 16px;
  overflow-y: auto;
  box-sizing: border-box;
}

.capture-overlay-hidden { display: none !important; }

.capture-card {
  position: relative;
  width: min(480px, 94vw);
  max-height: min(90vh, 760px);
  background: linear-gradient(165deg, #ffffff 0%, #f0fdf4 100%);
  border: 4px solid #ffffff;
  border-radius: 32px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.08);
  padding: 24px 20px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  animation: modalPopIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Custom sleek scrollbar for modal */
.capture-card::-webkit-scrollbar {
  width: 6px;
}
.capture-card::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
}
.capture-card::-webkit-scrollbar-thumb {
  background: rgba(2, 132, 199, 0.3);
  border-radius: 10px;
}
.capture-card::-webkit-scrollbar-thumb:hover {
  background: rgba(2, 132, 199, 0.6);
}

.capture-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  width: 36px;
  height: 36px;
  font-size: 20px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  background: var(--btn-pink);
  border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 3px 0 var(--btn-pink-shadow), 0 4px 10px rgba(0,0,0,0.2);
  transition: transform 0.1s ease;
}
.capture-close-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--btn-pink-shadow);
}

.capture-header {
  text-align: center;
  margin-bottom: 14px;
  padding: 0 20px;
}
.capture-title {
  font-family: var(--font-doodle, sans-serif);
  font-weight: 900;
  font-size: clamp(20px, 3.5vw, 26px);
  color: var(--text-dark, #0f2b5c);
  margin: 0 0 4px;
}
.capture-subtitle {
  font-family: var(--font-body, sans-serif);
  font-size: clamp(13px, 2vw, 15px);
  color: #64748b;
  margin: 0;
  line-height: 1.4;
}

.capture-body {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* QR Code Section */
.qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
#qr-code-container {
  background: #fff;
  padding: 10px;
  border-radius: 20px;
  border: 2px solid #e2e8f0;
  box-shadow: 0 8px 24px rgba(15, 43, 92, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 160px;
  min-height: 160px;
}
#qr-code-img {
  display: block;
  width: clamp(140px, 25vh, 180px);
  height: clamp(140px, 25vh, 180px);
  object-fit: contain;
  border-radius: 8px;
}
#qr-loading {
  font-size: 14px;
  font-weight: 700;
  color: #64748b;
}
.qr-caption {
  font-size: 13px;
  font-weight: 800;
  color: #0284c7;
}

/* Divider */
.modal-divider {
  width: 80%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 2px 0;
  position: relative;
}
.modal-divider::before {
  content: "";
  position: absolute;
  left: 0; right: 0; height: 1px;
  background: #cbd5e1;
}
.modal-divider span {
  position: relative;
  background: #f8fafc;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 900;
  color: #94a3b8;
  letter-spacing: 1px;
}

/* Room Code Card */
.code-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.modal-code-card {
  background: #0f2b5c;
  border: 3px solid #38bdf8;
  border-radius: 18px;
  padding: 8px 24px;
  text-align: center;
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 180px;
}
.modal-code-label {
  font-size: 11px;
  font-weight: 900;
  color: #38bdf8;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.modal-code-digits {
  font-family: 'Space Mono', monospace;
  font-size: clamp(26px, 5vw, 34px);
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 4px;
  line-height: 1.1;
  text-shadow: 0 2px 8px rgba(56, 189, 248, 0.5);
}

.manual-url-box {
  text-align: center;
  font-size: 13px;
  color: #475569;
}
.url-hint {
  display: block;
  font-size: 12px;
  color: #64748b;
  margin-bottom: 2px;
}
#connect-url-text {
  font-family: 'Space Mono', monospace;
  font-size: clamp(12px, 2.2vw, 14px);
  font-weight: 700;
  color: #0284c7;
  background: rgba(2, 132, 199, 0.08);
  padding: 4px 10px;
  border-radius: 8px;
  display: inline-block;
  word-break: break-all;
}

.modal-footer {
  margin-top: 10px;
  width: 100%;
  display: flex;
  justify-content: center;
}
.connection-status-pill {
  font-size: 12px;
  font-weight: 800;
  color: #059669;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 20px;
  padding: 4px 14px;
  margin: 0;
  text-align: center;
}

/* TV Mode */
html.tv-mode #shop-hud { display: none !important; } 
html.tv-mode #game-canvas { cursor: none; } 
html.tv-mode::after { 
  content: "Код: " attr(data-room-code); 
  position: absolute; bottom: 20px; right: 20px; 
  background: rgba(0,0,0,0.6); color: white; 
  padding: 10px 20px; border-radius: 20px; 
  font-family: var(--font-doodle); font-weight: 900; font-size: 24px; 
  border: 3px solid #fff;
  z-index: 100; display: none; 
} 
html.tv-mode[data-room-code]::after { display: block; }

/* SVG Definitions Container */
.svg-defs {
  width: 0;
  height: 0;
  position: absolute;
  z-index: -1;
}

/* Game Wrapper with Water Ripple Filter */
#game-wrapper {
  filter: url(#water-ripple);
}

/* Remote Badge Button */
#remote-badge {
  display: inline-flex;
}

/* Focus Visible Styles for Accessibility */
button:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.3);
}

#location-name:focus-visible {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Loading Screen Overlay */
#game-loading-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, #0e3a6c 0%, #061527 100%);
  color: #ffffff;
  padding: 24px;
}

#game-loading-screen .loading-title {
  font-family: var(--font-doodle);
  font-weight: 900;
  font-size: 40px;
  color: #ffffff;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  margin-bottom: 16px;
  letter-spacing: 1px;
}

#loading-text {
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 700;
  color: #7dd3fc;
  margin-bottom: 24px;
  text-align: center;
  max-width: 480px;
}

#loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255, 255, 255, 0.15);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: loadingSpin 0.9s linear infinite;
  margin-bottom: 24px;
}

@keyframes loadingSpin {
  to { transform: rotate(360deg); }
}

#btn-start-game {
  display: none;
  font-size: 22px;
  font-weight: 900;
  padding: 16px 44px;
  border-radius: 40px;
  background: var(--btn-green);
  box-shadow: 0 6px 0 var(--btn-green-shadow);
  color: #fff;
  border: 3px solid #fff;
  cursor: pointer;
  text-transform: uppercase;
  font-family: var(--font-doodle);
  transition: transform 0.1s, box-shadow 0.1s;
}
#btn-start-game:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 var(--btn-green-shadow);
}
#btn-start-game:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--btn-green-shadow);
}

/* Loading screen error state */
#game-loading-screen.error {
  border: 4px solid #ef4444;
}
#game-loading-screen.error #loading-text {
  color: #f87171;
  font-weight: 700;
}
#btn-loading-retry {
  display: none;
  margin: 14px auto 0;
}
#game-loading-screen.error #btn-loading-retry {
  display: block;
}



/* ========================================================
   RESPONSIVE DESIGN: MOBILE, TABLET, PC, AND TV MODES
   ======================================================== */

/* Mobile Responsive HUD (< 768px) */
@media (max-width: 768px) {
  #shop-hud {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 6px;
  }
  
  .hud-badges-group {
    gap: 6px;
  }

  .hud-coin-badge {
    padding: 4px 10px 4px 8px;
    gap: 5px;
    border-width: 2px;
  }
  
  .coin-icon { font-size: 18px; }
  .coin-icon svg { width: 18px; height: 18px; }
  #location-name { font-size: 13px; max-width: 85px; }
  #hud-shells { font-size: 15px; }
  
  #shop-ribbon {
    gap: 6px;
  }
  
  .shop-btn {
    min-width: 42px;
    min-height: 42px;
    padding: 6px 8px;
    border-radius: 14px;
    border-width: 2px;
    box-shadow: 0 3px 0 var(--btn-blue-shadow);
  }
  
  .slot-icon { font-size: 18px; }
  .slot-icon svg { width: 18px; height: 18px; }
  
  /* On mobile phones, hide verbose button labels and leave clean touch icons */
  #btn-print .slot-price,
  #btn-shop .slot-price {
    display: none;
  }
  
  #remote-badge .slot-price {
    font-size: 10px;
    max-width: 55px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Modals on mobile */
  .capture-card {
    width: min(94vw, 420px);
    border-radius: 28px;
  }
}

/* Ultra-Compact Mobile (< 420px) */
@media (max-width: 420px) {
  #location-name { display: none; }
  #remote-badge .slot-price { display: none; }
  .shop-btn { min-width: 38px; padding: 5px 6px; }
}

/* Mobile Screen Rotation Banner */
#rotate-hint {
  display: none;
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  background: rgba(6, 21, 39, 0.90);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(56, 189, 248, 0.7);
  border-radius: 30px;
  padding: 8px 18px;
  color: #fff;
  font-family: var(--font-doodle, sans-serif);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  animation: pulseRotate 2.5s infinite ease-in-out;
  pointer-events: auto;
}

@keyframes pulseRotate {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.03); border-color: rgba(56, 189, 248, 1); }
}

#rotate-hint .rotate-icon { font-size: 18px; }
#rotate-hint #btn-dismiss-rotate {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

@media (max-width: 768px) and (orientation: portrait) {
  #rotate-hint {
    display: flex;
  }
}

/* TV & 10-Foot UI Optimizations (> 1400px or TV Viewport) */
@media (min-width: 1400px) {
  #shop-hud {
    top: 30px;
    left: 40px;
    right: 40px;
  }
  .hud-coin-badge {
    padding: 8px 22px;
    border-width: 3px;
  }
  #location-name { font-size: 20px; max-width: 260px; }
  .coin-icon { font-size: 32px; }
  #hud-shells { font-size: 24px; }
  .shop-btn {
    min-width: 90px;
    padding: 10px 20px;
    border-radius: 22px;
    border-width: 3px;
  }
  .slot-icon { font-size: 26px; }
  .slot-price { font-size: 16px; }
  
  .capture-card {
    width: min(560px, 90vw);
    padding: 28px 24px 22px;
  }
}

/* TV Remote & Gamepad Focus Glow */
button:focus-visible,
[role="button"]:focus-visible,
.shop-btn:focus-visible {
  outline: 4px solid #38bdf8 !important;
  outline-offset: 4px;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.9) !important;
  transform: scale(1.08) !important;
}

/* Клавиатурный фокус: видимая обводка (доступность) */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible, label:focus-visible {
  outline: 3px solid #38bdf8; outline-offset: 2px;
}

/* «Чистый режим» для трансляции на большой экран (аудит, п.64).
   В полноэкранном режиме HUD плавно убирается — остаётся только аквариум.
   Прячем всё, кроме канвасов: панель, полосу чистоты, подсказки, статус джойстика,
   онбординг и пустые подсказки (клики при этом проходят на канвас — рыб можно гладить). */
#game-container.hud-hidden > *:not(canvas) {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.45s ease;
}
#game-container > *:not(canvas) {
  transition: opacity 0.45s ease;
}

/* Мобильный оверлей выбора (переведено из инлайн-стилей js/boot.js, п.21 аудита) */
#mobile-choice-overlay {
  position: fixed;
  inset: 0;
  z-index: 10010;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  background: rgba(4, 14, 28, 0.94);
  color: #eaf6ff;
  font: 16px/1.4 Nunito, sans-serif;
  padding: 24px;
  text-align: center;
}
#mobile-choice-overlay .mobile-choice-title {
  font-weight: 900;
  font-size: 26px;
}
#mobile-choice-overlay .mobile-choice-text {
  max-width: 420px;
}
#mobile-choice-overlay .mobile-choice-btn {
  min-width: 260px;
  border: 0;
  border-radius: 16px;
  padding: 14px 20px;
  font-weight: 900;
  font-size: 17px;
  cursor: pointer;
  background: #38bdf8;
  color: #08243f;
}
#mobile-choice-overlay .mobile-choice-btn.secondary {
  padding: 12px 20px;
  font-weight: 800;
  font-size: 16px;
  background: rgba(56, 189, 248, 0.12);
  color: #eaf6ff;
  border: 2px solid #38bdf8;
}

/* HUD-элементы аквариума (переведено из инлайн-стилей js/main.js, п.21 аудита).
   Динамические состояния (фон статуса, показ/скрытие) JS выставляет через
   element.style — это CSSOM и CSP разрешает. */
#joy-conn-status {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 9999;
  font-size: 12px;
  font-weight: bold;
  padding: 4px 10px;
  border-radius: 999px;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}
#empty-aquarium-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  pointer-events: none;
  text-align: center;
  font-family: var(--font-doodle, inherit);
  font-size: 22px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  padding: 16px 24px;
}
.ozh-onboarding {
  position: absolute;
  left: 16px;
  bottom: 52px;
  z-index: 60;
  max-width: 340px;
  background: rgba(8, 24, 44, 0.92);
  border: 2px solid #38bdf8;
  border-radius: 18px;
  padding: 14px 16px;
  color: #eaf6ff;
  font: 14px/1.45 'Nunito', sans-serif;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.ozh-onboarding b {
  font-size: 15px;
}
.ozh-onboarding > div:first-of-type {
  margin-top: 6px;
}
.ozh-onboarding button {
  margin-top: 10px;
  background: #38bdf8;
  color: #08243f;
  border: 0;
  border-radius: 12px;
  padding: 7px 16px;
  font-weight: 800;
  cursor: pointer;
}

/* Debug-оверлей для поддержки (переведено из инлайн-стилей js/ui/DebugOverlay.js, п.21) */
#debug-overlay {
  position: fixed;
  left: 10px;
  top: 10px;
  z-index: 100000;
  max-width: min(560px, 92vw);
  background: rgba(2, 10, 20, 0.88);
  color: #7dd3fc;
  border: 1px solid #38bdf8;
  border-radius: 10px;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: pointer;
}
