/* ===========================================
   Super Football Fan - Retro Sports Network
   Tecmo-inspired aesthetic meets modern UX
   =========================================== */

/* ---- CSS Variables ---- */
:root {
  /* Backgrounds */
  --bg-dark: #0a0a14;
  --bg-card: #14141f;
  --bg-card-hover: #1a1a28;
  
  /* Accent colors */
  --accent-red: #c41e3a;
  --accent-red-dark: #8b0000;
  --accent-red-glow: rgba(196, 30, 58, 0.3);
  --accent-gold: #ffd700;
  --accent-gold-dim: #b8860b;
  --accent-blue: #4a90d9;
  --accent-green: #2d8a4e;
  
  /* Text */
  --text-primary: #f0e6d3;
  --text-secondary: #8888aa;
  --text-dim: #555566;
  
  /* Borders */
  --border-color: #2a2a3a;
  --border-light: #3a3a4a;
  
  /* Fonts */
  --font-pixel: 'Press Start 2P', monospace;
  --font-display: 'Oswald', sans-serif;
  --font-body: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ---- Reset & Base ---- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---- Screen System ---- */
.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen.active {
  display: flex;
}

/* ===========================================
   HOME SCREEN
   =========================================== */
#screen-home {
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: var(--bg-dark);
}

.home-container {
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---- Logo ---- */
.logo-section {
  text-align: center;
  padding: 20px 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.logo-line-1 {
  font-family: var(--font-pixel);
  font-size: 32px;
  color: var(--accent-red);
  text-shadow: 
    3px 3px 0 var(--accent-red-dark),
    0 0 20px var(--accent-red-glow);
  letter-spacing: 8px;
}

.logo-line-2 {
  font-family: var(--font-pixel);
  font-size: 20px;
  color: var(--text-primary);
  text-shadow: 2px 2px 0 #333;
  letter-spacing: 4px;
}

.logo-line-3 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--accent-gold);
  letter-spacing: 12px;
  margin-top: 8px;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

/* ---- Cards ---- */
.game-status-card,
.quick-link-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.game-status-card:hover,
.quick-link-card:hover {
  border-color: var(--border-light);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  background: #1a1a2a;
  border-bottom: 2px solid var(--border-color);
}

.card-header.small {
  padding: 8px 12px;
}

.header-decoration {
  color: var(--text-dim);
  font-family: var(--font-body);
  letter-spacing: 2px;
}

.header-icon {
  font-size: 16px;
}

.header-text {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--text-primary);
}

.card-header.small .header-text {
  font-size: 12px;
  letter-spacing: 2px;
}

.card-content {
  padding: 20px;
}

/* ---- Game Status Content ---- */
#home-game-status {
  text-align: center;
}

.status-loading {
  color: var(--text-secondary);
  font-style: italic;
}

/* Live game display */
.game-live-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.teams-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  width: 100%;
}

.team-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
}

.team-box .name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.team-box .score {
  font-family: var(--font-pixel);
  font-size: 36px;
  color: var(--accent-gold);
  text-shadow: 2px 2px 0 #333;
}

.team-box.home .score {
  color: var(--accent-blue);
}

.team-box.away .score {
  color: var(--accent-red);
}

.vs-divider {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text-dim);
  font-weight: 600;
}

.game-details {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 14px;
}

.game-details .time-quarter {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text-primary);
  letter-spacing: 1px;
}

.game-details .down-distance {
  color: var(--accent-gold);
}

.game-details .fans {
  font-size: 13px;
  margin-top: 4px;
}

/* Waiting state */
.game-waiting-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
}

.waiting-message {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--text-primary);
  text-align: center;
}

.waiting-decoration {
  color: var(--accent-gold);
  letter-spacing: 2px;
}

.waiting-fans {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ---- Buttons ---- */
.retro-btn {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  padding: 14px 32px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
}

.retro-btn.primary {
  background: var(--accent-red);
  color: white;
  border: 3px solid var(--accent-red-dark);
  box-shadow: 4px 4px 0 var(--accent-red-dark);
}

.retro-btn.primary:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--accent-red-dark);
}

.retro-btn.primary:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--accent-red-dark);
}

.retro-btn.secondary {
  background: #2a2a4a;
  color: var(--text-primary);
  border: 2px solid var(--border-color);
  box-shadow: 3px 3px 0 #0a0a14;
  padding: 10px 20px;
  font-size: 12px;
}

.retro-btn.secondary:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #0a0a14;
}

.retro-btn.danger {
  background: #3a2020;
  color: #ff6666;
  border: 2px solid #4a2a2a;
  box-shadow: 2px 2px 0 #1a0a0a;
  padding: 8px 16px;
  font-size: 11px;
}

.retro-btn.danger:hover {
  border-color: #ff6666;
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 #1a0a0a;
}

/* ---- Quick Links ---- */
.quick-links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.quick-link-card .card-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.quick-link-preview {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

/* ---- News Ticker ---- */
.news-ticker {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 10px 12px;
  overflow: hidden;
}

.ticker-label {
  flex-shrink: 0;
  margin-right: 12px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--accent-gold);
  padding: 4px 8px;
  background: var(--border-color);
  border-radius: 2px;
}

.ticker-content {
  flex: 1;
  overflow: hidden;
  mask-image: linear-gradient(90deg, black 90%, transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, black 90%, transparent 100%);
}

.ticker-text {
  display: inline-block;
  white-space: nowrap;
  animation: ticker-scroll 30s linear infinite;
  font-size: 12px;
  color: var(--text-secondary);
}

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ---- Debug Toggle ---- */
.debug-toggle-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.debug-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 4px;
  transition: background 0.2s;
}

.debug-toggle-label:hover {
  background: rgba(255, 255, 255, 0.05);
}

.debug-toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent-gold);
}

.debug-toggle-text {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-body);
}

.debug-toggle-label:hover .debug-toggle-text {
  color: var(--text-secondary);
}

/* ---- Fidelity Selector ---- */
.fidelity-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.fidelity-selector label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.fidelity-selector select {
  background: var(--bg-dark);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font-body);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.fidelity-selector select:hover {
  border-color: var(--accent-gold-dim);
}

.fidelity-selector select:focus {
  border-color: var(--accent-gold);
}

.fidelity-selector select option {
  background: var(--bg-dark);
  color: var(--text-primary);
}

/* ---- Reset Button Container ---- */
.reset-container {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

/* ===========================================
   GAME SCREEN
   =========================================== */
#screen-game {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
}

#game-container {
  display: flex;
  flex-direction: column;
  background: #0f0f1a;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  max-width: 100%;
  max-height: 100%;
  position: relative;
}

.back-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 20;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.back-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

/* ---- Scoreboard ---- */
#scoreboard {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  background: #16161f;
  padding: 12px 20px;
  border-bottom: 2px solid var(--border-color);
  flex-shrink: 0;
}

.team {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
}

.team-name {
  font-family: var(--font-display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-secondary);
}

.team .score {
  font-family: var(--font-pixel);
  font-size: 28px;
  line-height: 1;
  margin-top: 4px;
}

.team.home .score {
  color: var(--accent-blue);
}

.team.away .score {
  color: var(--accent-red);
}

.game-info {
  text-align: center;
  padding: 0 20px;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  min-width: 120px;
}

.game-info-top {
  display: flex;
  justify-content: center;
  gap: 12px;
  align-items: baseline;
}

#quarter {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text-secondary);
}

#time {
  font-family: var(--font-pixel);
  font-size: 18px;
  color: var(--text-primary);
}

#down-distance {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--accent-gold);
  margin-top: 2px;
  letter-spacing: 1px;
}

/* ---- Field Container ---- */
#field-container {
  position: relative;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
  overflow: hidden;
  background: #080810;
}

#game-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---- Notifications ---- */
#notifications {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
  pointer-events: none;
}

.notification {
  background: rgba(0, 0, 0, 0.9);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  animation: notificationSlide 0.3s ease-out;
  max-width: 200px;
  pointer-events: auto;
  border-left: 3px solid var(--border-color);
}

.notification.success {
  border-left-color: var(--accent-green);
}

.notification.error {
  border-left-color: var(--accent-red);
}

.notification.info {
  border-left-color: var(--accent-blue);
}

@keyframes notificationSlide {
  from { transform: translateX(-10px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- Active Effects ---- */
#active-effects {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
  pointer-events: none;
}

.active-effect {
  background: rgba(0, 0, 0, 0.9);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  border-left: 3px solid var(--accent-blue);
  animation: effectPulse 2s infinite;
  white-space: nowrap;
}

@keyframes effectPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ---- Ability Panel ---- */
#ability-panel {
  background: #16161f;
  padding: 10px 12px;
  border-top: 2px solid var(--border-color);
  flex-shrink: 0;
}

#ability-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ability-btn {
  position: relative;
  background: #252538;
  border: 2px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  min-width: 90px;
  transition: all 0.15s;
  overflow: hidden;
}

.ability-btn:hover:not(:disabled) {
  border-color: var(--accent-gold);
  transform: translateY(-1px);
}

.ability-btn:active:not(:disabled) {
  transform: translateY(0);
}

.ability-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ability-btn.on-cooldown {
  background: #151520;
}

.ability-btn .cooldown-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent-gold);
  border-radius: 0 0 2px 2px;
  transition: width 0.1s linear;
}

.ability-btn .ability-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 1px;
}

.ability-btn .ability-key {
  font-size: 9px;
  opacity: 0.5;
  margin-top: 2px;
}

/* ===========================================
   PLACEHOLDER SCREENS
   =========================================== */
#screen-abilities,
#screen-records {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
  padding: 20px;
}

.screen-container {
  text-align: center;
  max-width: 600px;
}

.screen-title {
  font-family: var(--font-pixel);
  font-size: 24px;
  color: var(--accent-gold);
  margin-bottom: 30px;
  text-shadow: 2px 2px 0 #333;
}

.coming-soon {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 40px;
}

.coming-soon p {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text-primary);
  letter-spacing: 1px;
}

.coming-soon .subtext {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 12px;
}

/* ===========================================
   OVERLAYS
   =========================================== */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  padding: 30px 40px;
  border-radius: 8px;
  text-align: center;
}

.overlay-content h2 {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text-primary);
  letter-spacing: 2px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 20px auto 0;
}

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

/* ===========================================
   UTILITY
   =========================================== */
.hidden {
  display: none !important;
}

/* ===========================================
   RESPONSIVE BREAKPOINTS
   =========================================== */

/* Tablet */
@media (max-width: 1024px) {
  .logo-line-1 { font-size: 28px; }
  .logo-line-2 { font-size: 18px; }
  .logo-line-3 { font-size: 20px; }
  
  .teams-display { gap: 16px; }
  .team-box .score { font-size: 28px; }
  
  #scoreboard { gap: 12px; padding: 10px 16px; }
  .team .score { font-size: 24px; }
}

/* Mobile landscape */
@media (max-width: 768px) and (orientation: landscape) {
  #screen-home { padding: 10px; }
  
  .home-container { gap: 12px; }
  
  .logo-section { padding: 10px 0; }
  .logo-line-1 { font-size: 20px; letter-spacing: 4px; }
  .logo-line-2 { font-size: 14px; }
  .logo-line-3 { font-size: 16px; margin-top: 4px; }
  
  .game-status-card .card-content { padding: 12px; }
  .teams-display { gap: 12px; }
  .team-box .score { font-size: 24px; }
  
  .quick-links { gap: 10px; }
  .quick-link-card .card-content { padding: 10px; }
  
  .news-ticker { padding: 6px 10px; }
  .ticker-text { font-size: 11px; }
  
  /* Game screen */
  #scoreboard { padding: 6px 12px; gap: 10px; }
  .team .score { font-size: 20px; }
  #time { font-size: 16px; }
  
  #ability-panel { padding: 6px 8px; }
  .ability-btn { min-width: 70px; padding: 5px 6px; }
  .ability-btn .ability-name { font-size: 9px; }
}

/* Mobile portrait */
@media (max-width: 600px) {
  #screen-home { padding: 16px; }
  
  .home-container { gap: 16px; }
  
  .logo-section { padding: 16px 0; }
  .logo-line-1 { font-size: 22px; letter-spacing: 4px; }
  .logo-line-2 { font-size: 14px; letter-spacing: 2px; }
  .logo-line-3 { font-size: 16px; letter-spacing: 6px; }
  
  .card-header { padding: 8px 12px; }
  .header-text { font-size: 12px; letter-spacing: 2px; }
  .header-decoration { display: none; }
  
  .game-status-card .card-content { padding: 16px; }
  
  .teams-display { gap: 12px; }
  .team-box { min-width: 80px; }
  .team-box .name { font-size: 12px; }
  .team-box .score { font-size: 28px; }
  .vs-divider { font-size: 14px; }
  
  .game-details { font-size: 13px; }
  .game-details .time-quarter { font-size: 14px; }
  
  .retro-btn.primary { padding: 12px 24px; font-size: 12px; }
  
  .quick-links { grid-template-columns: 1fr; gap: 12px; }
  
  .news-ticker { padding: 8px 10px; }
  .ticker-text { font-size: 11px; }
  
  /* Game screen */
  #scoreboard { padding: 8px 12px; gap: 8px; }
  .team { min-width: 55px; }
  .team .score { font-size: 22px; }
  .team-name { font-size: 10px; }
  .game-info { min-width: 90px; padding: 0 12px; }
  #time { font-size: 16px; }
  #down-distance { font-size: 12px; }
  
  #ability-panel { padding: 10px; }
  #ability-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    max-width: 320px;
    margin: 0 auto;
  }
  .ability-btn { min-width: unset; width: 100%; padding: 10px 6px; }
  .ability-btn .ability-key { display: none; }
  
  .back-btn { top: auto; bottom: 8px; left: 8px; }
  
  /* Placeholder screens */
  .screen-title { font-size: 18px; }
  .coming-soon { padding: 30px 20px; }
  .coming-soon p { font-size: 16px; }
}

/* Very small mobile */
@media (max-width: 360px) {
  .logo-line-1 { font-size: 18px; }
  .logo-line-2 { font-size: 12px; }
  .logo-line-3 { font-size: 14px; }
  
  .team-box .score { font-size: 24px; }
  
  #ability-buttons { gap: 4px; }
  .ability-btn { padding: 8px 4px; }
  .ability-btn .ability-name { font-size: 8px; }
}
