/* ==========================================================================
   Linus LetterPro - Main Theme & Typography
   Optimized for iPad Pro 1 Safari OS 17 (and cross-browser Chrome, Safari, Edge)
   ========================================================================== */

:root {
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --secondary: #8B5CF6;
  --accent: #F59E0B;
  --success: #10B981;
  --danger: #EF4444;
  --bg-dark: #0F172A;
  --bg-card: #1E293B;
  --bg-card-hover: #334155;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --border-color: rgba(255, 255, 255, 0.12);
  --shadow-3d: 0 6px 0 rgba(0, 0, 0, 0.35), 0 10px 20px rgba(0, 0, 0, 0.25);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  touch-action: none;
  -webkit-font-smoothing: antialiased;
}

#app-container {
  width: 100vw;
  height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* Screen Management */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.screen.active {
  display: flex;
  opacity: 1;
  transform: scale(1);
}

/* ==========================================================================
   Top Header Bar
   ========================================================================== */

.app-header {
  height: 64px;
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 50;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  font-size: 28px;
  animation: gentleBounce 2s infinite ease-in-out;
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, #60A5FA, #C084FC);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Tactile 3D Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

.btn-primary {
  background: linear-gradient(180deg, #3B82F6 0%, #1D4ED8 100%);
  color: white;
}

.btn-secondary {
  background: linear-gradient(180deg, #64748B 0%, #475569 100%);
  color: white;
}

.btn-gold {
  background: linear-gradient(180deg, #FBBF24 0%, #D97706 100%);
  color: #78350F;
  box-shadow: 0 4px 0 #92400E;
}

.btn-outline {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-main);
}

.btn-icon-only {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  font-size: 20px;
}

/* ==========================================================================
   Home Screen Layout
   ========================================================================== */

.home-scroll-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.home-hero-card {
  width: 100%;
  max-width: 960px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.25), rgba(147, 51, 234, 0.25));
  border: 2px solid rgba(96, 165, 250, 0.35);
  border-radius: 24px;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-3d);
}

.hero-info h1 {
  font-size: 32px;
  font-weight: 900;
  margin-bottom: 6px;
}

.hero-subtitle {
  font-size: 16px;
  color: var(--text-muted);
}

.mastery-progress-bar {
  width: 240px;
  height: 16px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.mastery-fill {
  height: 100%;
  background: linear-gradient(90deg, #10B981, #3B82F6);
  border-radius: 10px;
  width: 0%;
  transition: width 0.5s ease;
}

/* Game Mode Cards Grid */
.modes-grid {
  width: 100%;
  max-width: 960px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.mode-card {
  position: relative;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--shadow-3d);
  transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.mode-card:hover {
  background-color: var(--bg-card-hover);
  border-color: rgba(96, 165, 250, 0.5);
  transform: translateY(-4px);
}

.mode-card:active {
  transform: translateY(2px);
}

.mode-icon-circle {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}

.mode-title {
  font-size: 20px;
  font-weight: 800;
}

.mode-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.4;
}

.badge-timer {
  background: #DC2626;
  color: white;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
}

.badge-endless {
  background: #7C3AED;
  color: white;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
}

/* Modals Base */
.modal-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: none;
  z-index: 100;
}

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

.modal-backdrop {
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 24px;
  padding: 24px;
  max-width: 600px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  animation: popIn 0.25s ease-out;
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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