/* Stellar Ricochet - Betclic-inspired vibrant styling & 100% Mobile Ergonomics */

:root {
  --primary: #FF2B44;         /* Energetic Betclic-styled signature red/crimson */
  --primary-glow: rgba(255, 43, 68, 0.45);
  --accent: #FFBE0B;          /* Vibrant warm gold / solar spark */
  --accent-cyan: #00F5D4;     /* Radiant plasma cyan */
  --bg-dark: #0D0E15;
  --panel-bg: rgba(20, 24, 38, 0.72);
  --panel-border: rgba(255, 255, 255, 0.12);
  --panel-border-bright: rgba(255, 43, 68, 0.35);
  --text-main: #FFFFFF;
  --text-dim: #94A3B8;
  --text-muted: #64748B;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.35);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-dark);
  font-family: var(--font-family);
  color: var(--text-main);
  overflow-x: hidden;
  touch-action: manipulation;
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  background: #0d0f17 url('bg.jpg') center top / cover no-repeat;
  box-shadow: 0 0 50px rgba(0,0,0,0.8);
  overflow-x: hidden;
}

/* Header */
.app-header {
  padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
  padding-left: 14px;
  padding-right: 14px;
  padding-bottom: 10px;
  z-index: 20;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.logo-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  object-fit: cover;
  box-shadow: 0 2px 10px var(--primary-glow);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.game-title {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #FFFFFF;
}

.game-subtitle {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--primary);
  text-shadow: 0 0 8px var(--primary-glow);
}

.stats-pills {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 10px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
}

.gems-pill .pill-val {
  color: var(--accent);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  color: #fff;
  cursor: pointer;
  transition: transform 0.1s, background-color 0.2s;
}

.icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 43, 68, 0.2);
}

/* Viewport for Screens */
.screens-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 68px);
}

.screen-view {
  display: none;
  flex-direction: column;
  width: 100%;
  padding: 0 14px 14px 14px;
  animation: fadeIn 0.22s ease-out;
}

.screen-view.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-header-bar {
  margin: 10px 0 14px;
}

.screen-header-bar h2 {
  font-size: 20px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.screen-header-bar .subhead {
  font-size: 12px;
  color: var(--text-dim);
}

/* In-game HUD */
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.level-badge {
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}

.par-badge {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 44%;
}

.target-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-cyan));
  border-radius: var(--radius-full);
  transition: width 0.25s ease;
}

.progress-text {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
}

.hud-mini-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 15px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hud-mini-btn:active {
  transform: scale(0.9);
}

/* Canvas Area */
.canvas-wrapper {
  position: relative;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(7, 10, 19, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  touch-action: none;
  aspect-ratio: 400 / 520;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.aim-hint-overlay {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0.9;
  transition: opacity 0.3s;
}

.hint-pulse {
  background: rgba(13, 14, 21, 0.85);
  border: 1px solid var(--accent-cyan);
  color: #fff;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(0, 245, 212, 0.4);
  white-space: nowrap;
}

/* In-game control strip */
.game-control-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-top: 8px;
}

.control-item {
  display: flex;
  flex-direction: column;
}

.control-item .label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.control-item .val {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}

.control-item .val.highlight {
  color: var(--accent-cyan);
}

.btn-chip {
  background: rgba(255, 43, 68, 0.2);
  border: 1px solid var(--primary);
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s;
}

.btn-chip:active {
  transform: scale(0.92);
}

.text-right {
  text-align: right;
  align-items: flex-end;
}

/* Bottom Navigation */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(env(safe-area-inset-bottom, 0px) + 60px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 4px);
  background: rgba(13, 15, 23, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 30;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  height: 50px;
  transition: transform 0.12s, color 0.15s;
}

.nav-item .nav-icon {
  font-size: 18px;
}

.nav-item .nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item:active {
  transform: scale(0.93);
}

/* Levels Grid Screen */
.levels-grid-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding-bottom: 20px;
}

.level-card {
  aspect-ratio: 1 / 1;
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s, border-color 0.2s, background-color 0.2s;
}

.level-card:active {
  transform: scale(0.92);
}

.level-card.locked {
  opacity: 0.45;
  filter: grayscale(0.8);
  cursor: not-allowed;
}

.level-card.cleared {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(255, 190, 11, 0.2);
}

.level-card.current {
  border-color: var(--primary);
  box-shadow: 0 0 14px var(--primary-glow);
  background: rgba(255, 43, 68, 0.15);
}

.level-num {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}

.level-stars {
  font-size: 9px;
  color: var(--accent);
  letter-spacing: 1px;
  margin-top: 2px;
}

/* Shop Grid Screen */
.shop-grid-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding-bottom: 20px;
}

.shop-card {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: border-color 0.2s, transform 0.12s;
}

.shop-card:active {
  transform: scale(0.97);
}

.shop-card.equipped {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(0, 245, 212, 0.25);
}

.skin-preview-orb {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-full);
  margin-bottom: 10px;
  box-shadow: 0 0 18px currentColor;
}

.skin-name {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 3px;
}

.skin-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
  min-height: 28px;
}

.skin-action-btn {
  width: 100%;
  padding: 9px 0;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 12px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.skin-action-btn:active {
  transform: scale(0.94);
}

.btn-equip {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-equipped {
  background: var(--accent-cyan);
  color: #000;
  cursor: default;
}

.btn-buy {
  background: linear-gradient(135deg, var(--primary), #FF5400);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* Achievements Screen */
.achievements-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 20px;
}

.achievement-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px;
}

.achievement-card.completed {
  border-color: rgba(255, 190, 11, 0.4);
}

.achieve-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.achieve-info {
  flex: 1;
}

.achieve-title {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 2px;
}

.achieve-desc {
  font-size: 11px;
  color: var(--text-dim);
}

.achieve-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.achievement-card.completed .achieve-badge {
  background: rgba(255, 190, 11, 0.2);
  color: var(--accent);
  border: 1px solid var(--accent);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.active {
  display: flex;
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: #141724;
  border-top: 1px solid var(--panel-border-bright);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 16px 18px calc(env(safe-area-inset-bottom, 0px) + 20px);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-full);
  margin: 0 auto 12px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sheet-header h3 {
  font-size: 17px;
  font-weight: 800;
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  cursor: pointer;
}

/* Tabs */
.sheet-tabs {
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.card-panel {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
}

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

.info-label {
  color: var(--text-dim);
}

.info-val {
  font-weight: 700;
}

.badge-pill {
  background: rgba(255, 43, 68, 0.2);
  color: var(--primary);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
}

.action-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px;
  color: #fff;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: background-color 0.15s, transform 0.1s;
}

.action-btn:active {
  transform: scale(0.98);
  background: rgba(255, 255, 255, 0.1);
}

.action-icon {
  font-size: 20px;
}

.action-meta {
  display: flex;
  flex-direction: column;
}

.action-title {
  font-size: 13px;
  font-weight: 700;
}

.action-desc {
  font-size: 11px;
  color: var(--text-dim);
}

.legal-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 10px;
}

.legal-box h4 {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 6px;
}

.legal-text {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.toggle-title {
  font-size: 13px;
  font-weight: 700;
  display: block;
}

.toggle-desc {
  font-size: 11px;
  color: var(--text-dim);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: 0.2s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.danger-zone {
  margin-top: 16px;
}

.btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: transform 0.1s, opacity 0.2s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #FF5400);
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: rgba(255, 43, 68, 0.15);
  border: 1px solid var(--primary);
  color: var(--primary);
}

/* Victory / Game Over Modal */
.end-sheet {
  text-align: center;
}

.stars-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 38px;
  margin-bottom: 8px;
}

.star-slot {
  color: rgba(255, 255, 255, 0.15);
  transition: color 0.3s, transform 0.3s;
}

.star-slot.active {
  color: var(--accent);
  text-shadow: 0 0 16px rgba(255, 190, 11, 0.6);
  transform: scale(1.1);
}

.end-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.end-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.end-stats-card {
  display: flex;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 18px;
}

.end-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-name {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
}

.stat-value {
  font-size: 16px;
  font-weight: 800;
}

.stat-value.highlight {
  color: var(--accent);
}

.end-actions {
  display: flex;
  gap: 10px;
}

.end-actions .btn {
  flex: 1;
}

/* Toast */
.toast-box {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 70px);
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(20, 24, 38, 0.95);
  border: 1px solid var(--accent-cyan);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 200;
  white-space: nowrap;
}

.toast-box.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
