/* ============================================
   OTD GAMES — SCREEN LAYOUTS
   ============================================ */

/* === APP SHELL === */
.app {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* === LOADING SCREEN === */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.5s var(--ease-out), visibility 0.5s;
}

.loading-screen.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loading-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}

.loading-logo-icon svg {
  width: 120px;
  height: 120px;
}

.loading-circle {
  animation: loadingCircle 2s var(--ease-in-out) infinite;
}

.loading-tagline {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.loading-bar {
  width: 200px;
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  background: var(--accent-gradient-h);
  border-radius: var(--radius-full);
  animation: loadingBar 2s var(--ease-in-out) forwards;
}

/* === HEADER === */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--space-md);
  padding-top: var(--safe-top);
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: var(--border-subtle);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-btn {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--duration-fast);
}

.header-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.brand-logo {
  font-family: var(--font-mono);
  font-weight: var(--weight-black);
  font-size: var(--text-lg);
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-dot { color: var(--text-tertiary); font-size: var(--text-xs); }

.brand-sub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: var(--weight-medium);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header-streak {
  display: flex;
  align-items: center;
  gap: var(--space-xxs);
  padding: var(--space-xxs) var(--space-xs);
  background: rgba(255, 109, 0, 0.1);
  border: 1px solid rgba(255, 109, 0, 0.2);
  border-radius: var(--radius-full);
}

.streak-fire { font-size: 14px; }
.streak-count {
  font-family: var(--font-mono);
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  color: var(--streak-color);
}

.header-xp {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.xp-value {
  font-family: var(--font-mono);
  font-weight: var(--weight-bold);
  font-size: var(--text-base);
  color: var(--xp-color);
}

.xp-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: var(--weight-semibold);
}

/* === BOTTOM NAV === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--nav-height);
  padding-bottom: var(--safe-bottom);
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: var(--border-subtle);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-xs) var(--space-sm);
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  transition: all var(--duration-fast);
  border-radius: var(--radius-md);
  min-width: 64px;
  position: relative;
}

.nav-item svg {
  width: 22px; height: 22px;
  transition: all var(--duration-fast);
}

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

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  width: 20px;
  height: 2px;
  background: var(--accent-primary);
  border-radius: 0 0 2px 2px;
}

/* === SCREEN CONTAINER === */
.screen-container {
  flex: 1;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen {
  padding: var(--space-md);
  animation: screenIn var(--duration-slow) var(--ease-out);
  min-height: calc(100vh - var(--header-height) - var(--nav-height));
  min-height: calc(100dvh - var(--header-height) - var(--nav-height));
}

.screen-exit {
  animation: screenOut var(--duration-normal) var(--ease-out) forwards;
}

/* === DASHBOARD === */
.dash-greeting {
  margin-bottom: var(--space-lg);
}

.dash-greeting h1 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-black);
  margin-bottom: var(--space-xxs);
}

.dash-greeting p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.dash-scores {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.dash-score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xxs);
  padding: var(--space-sm) var(--space-xxs);
  background: var(--bg-card);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
}

.dash-score-val {
  font-family: var(--font-mono);
  font-weight: var(--weight-bold);
  font-size: var(--text-lg);
}

.dash-score-lbl {
  font-size: 9px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}

.dash-level {
  background: var(--bg-card);
  border: var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
}

.dash-level-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.dash-level-title {
  font-weight: var(--weight-bold);
  font-size: var(--text-base);
}

.dash-level-next {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.dash-section {
  margin-bottom: var(--space-lg);
}

.dash-section-title {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.dash-quick-play {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.quick-play-card {
  background: var(--bg-card);
  border: var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  text-align: center;
  transition: all var(--duration-normal) var(--ease-out);
}

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

.quick-play-icon { font-size: 32px; margin-bottom: var(--space-xs); }
.quick-play-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.quick-play-skill {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* === GAME HUB === */
.game-hub-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* === GAME PLAY SCREEN === */
.game-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  animation: screenIn var(--duration-slow) var(--ease-out);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  padding-top: calc(var(--safe-top) + var(--space-md));
}

.game-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.game-timer {
  font-family: var(--font-mono);
  font-weight: var(--weight-bold);
  font-size: var(--text-xl);
  color: var(--accent-primary);
}

.game-timer.warning { color: var(--color-warning); }
.game-timer.danger { color: var(--color-danger); animation: pulse 0.5s infinite; }

.game-close {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
}

.game-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  gap: var(--space-lg);
  overflow: hidden;
}

.game-canvas-wrap {
  width: 100%;
  max-width: 400px;
  aspect-ratio: 4/3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: var(--border-subtle);
  background: var(--bg-secondary);
}

.game-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.game-actions {
  display: flex;
  gap: var(--space-sm);
  width: 100%;
  max-width: 400px;
}

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

.game-score-display {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: var(--weight-black);
  text-align: center;
}

.game-instruction {
  text-align: center;
  font-size: var(--text-lg);
  color: var(--text-secondary);
  max-width: 300px;
}

/* === RESULT SCREEN === */
.result-screen {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: screenIn var(--duration-slow) var(--ease-out);
}

.result-header {
  padding: var(--space-xl) var(--space-lg);
  padding-top: calc(var(--safe-top) + var(--space-xl));
  text-align: center;
}

.result-emoji { font-size: 64px; margin-bottom: var(--space-md); }
.result-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-black);
  margin-bottom: var(--space-xs);
}
.result-subtitle {
  color: var(--text-secondary);
  font-size: var(--text-base);
}

.result-body {
  flex: 1;
  padding: 0 var(--space-lg) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.result-stat {
  background: var(--bg-card);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
}

.result-stat-val {
  font-family: var(--font-mono);
  font-weight: var(--weight-bold);
  font-size: var(--text-xl);
  margin-bottom: var(--space-xxs);
}

.result-stat-lbl {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.result-xp {
  text-align: center;
  padding: var(--space-lg);
  background: linear-gradient(135deg, rgba(0, 230, 118, 0.08), rgba(0, 212, 255, 0.08));
  border: 1px solid rgba(0, 230, 118, 0.2);
  border-radius: var(--radius-lg);
}

.result-xp-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.result-xp-value {
  font-family: var(--font-mono);
  font-size: var(--text-4xl);
  font-weight: var(--weight-black);
  background: var(--xp-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding-bottom: calc(var(--safe-bottom) + var(--space-lg));
}

/* === PROFILE === */
.profile-header {
  text-align: center;
  padding: var(--space-lg) 0;
}

.profile-avatar {
  width: 80px; height: 80px;
  margin: 0 auto var(--space-md);
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xl);
  font-weight: var(--weight-black);
  box-shadow: 0 0 30px rgba(var(--accent-primary-rgb), 0.3);
}

.profile-name {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-xxs);
}

.profile-title-badge {
  display: inline-flex;
  padding: var(--space-xxs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin: var(--space-lg) 0;
}

.profile-stat {
  text-align: center;
  padding: var(--space-md);
  background: var(--bg-card);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
}

.profile-section {
  margin-bottom: var(--space-lg);
}

.profile-section-title {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-md);
}

/* === LEADERBOARD === */
.lb-header {
  margin-bottom: var(--space-lg);
}

.lb-header h2 {
  font-size: var(--text-xl);
  font-weight: var(--weight-black);
  margin-bottom: var(--space-xs);
}

.lb-subtitle {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.lb-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.lb-user-row {
  background: rgba(var(--accent-primary-rgb), 0.08);
  border: 1px solid rgba(var(--accent-primary-rgb), 0.2);
  border-radius: var(--radius-md);
}

/* === SETTINGS === */
.settings-group {
  margin-bottom: var(--space-lg);
}

.settings-group-title {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--space-sm);
  padding-left: var(--space-xs);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: var(--bg-card);
  border: var(--border-subtle);
  margin-bottom: 1px;
}

.settings-row:first-of-type { border-radius: var(--radius-md) var(--radius-md) 0 0; }
.settings-row:last-of-type { border-radius: 0 0 var(--radius-md) var(--radius-md); margin-bottom: 0; }
.settings-row:only-of-type { border-radius: var(--radius-md); }

.settings-label { font-size: var(--text-base); font-weight: var(--weight-medium); }
.settings-desc { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 2px; }

/* Toggle Switch */
.toggle {
  position: relative;
  width: 48px; height: 28px;
}

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

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 14px;
  transition: all var(--duration-normal);
  cursor: pointer;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: all var(--duration-normal) var(--ease-spring);
}

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

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

/* === FULL SCREEN GAME HIDE NAV === */
body.game-active .app-header,
body.game-active .bottom-nav {
  display: none;
}

body.game-active .screen-container {
  padding-bottom: 0;
}

/* === RESPONSIVE === */
@media (min-width: 480px) {
  .dash-scores { grid-template-columns: repeat(5, 1fr); gap: var(--space-sm); }
  .dash-quick-play { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
  .screen { max-width: 480px; margin: 0 auto; }
  .game-hub-grid { max-width: 480px; margin: 0 auto; }
}
