/* Reset and base styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', 'Arial', sans-serif;
  background: linear-gradient(135deg, #f9f9f9 0%, #ffe066 100%);
  color: #222;
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Banner (MOTD) */
.motd-banner {
  width: 100%;
  background: #ffef7f;
  color: #222;
  font-weight: bold;
  text-align: center;
  padding: 0.75em 1em;
  font-size: 1.1em;
  border-bottom: 2px solid #ffd700;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  position: sticky;
  top: 0;
  z-index: 100;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Navigation Bar */
.menu-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  width: 100%;
  background: linear-gradient(90deg, #ffefc1 0%, #ffe066 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  z-index: 1000;
  padding: 0.5em 1em;
  font-family: 'Orbitron', 'Comic Neue', cursive, sans-serif;
  font-size: 1.2rem;
  transition: all 0.2s;
}

.menu-bar a {
  color: #ffe066;
  text-decoration: none;
  margin: 0 1em;
  font-size: 1.1em;
  font-weight: 600;
  transition: color 0.2s, transform 0.2s;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu-bar a:hover,
.menu-bar a.active {
  color: #fff;
  text-shadow: 0 0 8px #ffe066;
  transform: scale(1.08) rotate(-2deg);
}

.menu-bar__logo {
  flex: 1 1 120px;
  min-width: 80px;
  max-width: 200px;
  font-size: 1.5em;
  text-align: left;
}

.menu-bar__links {
  display: flex;
  flex: 2 1 300px;
  flex-wrap: wrap;
  gap: 1em;
  justify-content: flex-end;
  align-items: center;
}

.menu-bar__link {
  padding: 0.5em 1em;
  border-radius: 20px;
  background: #fffbe6;
  color: #222;
  text-decoration: none;
  font-weight: bold;
  transition: background 0.2s, color 0.2s, transform 0.2s;
  font-size: 1em;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.menu-bar__link:hover,
.menu-bar__link:focus {
  background: #ffe066;
  color: #d35400;
  transform: scale(1.08) rotate(-2deg);
  outline: none;
}

/* Responsive Layout */
.container {
  max-width: 900px;
  margin: 2em auto;
  padding: 1em;
  background: rgba(255,255,255,0.95);
  border-radius: 1em;
  box-shadow: 0 4px 24px rgba(0,0,0,0.07);
}

/* Mobile-first responsive design */
@media (max-width: 1200px) {
  .container {
    max-width: 95%;
    margin: 1.5em auto;
  }
}

@media (max-width: 768px) {
  html { 
    font-size: 14px; 
  }
  
  .container {
    margin: 1em 0.5em;
    padding: 0.75em;
    border-radius: 0.75em;
  }
  
  .menu-bar {
    flex-direction: column;
    padding: 0.75em 0.5em;
    gap: 0.5em;
  }
  
  .menu-bar__logo {
    text-align: center;
    font-size: 1.3em;
    margin-bottom: 0.5em;
    flex: none;
  }
  
  .menu-bar__links {
    flex-direction: column;
    gap: 0.5em;
    justify-content: center;
    align-items: stretch;
    width: 100%;
  }
  
  .menu-bar__link {
    width: 100%;
    text-align: center;
    font-size: 1em;
    padding: 0.8em 0.5em;
    min-height: 48px;
    border-radius: 12px;
  }
  
  .motd-banner {
    font-size: 0.95em;
    padding: 0.6em 0.5em;
    line-height: 1.4;
  }
}

@media (max-width: 480px) {
  html { 
    font-size: 13px; 
  }
  
  .container {
    margin: 0.5em 0.25em;
    padding: 0.5em;
    border-radius: 0.5em;
  }
  
  .menu-bar {
    font-size: 0.9em;
    padding: 0.5em 0.25em;
  }
  
  .menu-bar__logo {
    font-size: 1.1em;
  }
  
  .menu-bar__link {
    font-size: 0.95em;
    padding: 0.7em 0.4em;
    min-height: 44px;
  }
  
  .motd-banner {
    font-size: 0.9em;
    padding: 0.5em 0.4em;
  }
}

/* Extra small screens */
@media (max-width: 360px) {
  html { 
    font-size: 12px; 
  }
  
  .menu-bar {
    font-size: 0.85em;
    padding: 0.4em 0.2em;
  }
  
  .menu-bar__logo {
    font-size: 1em;
  }
  
  .menu-bar__link {
    font-size: 0.9em;
    padding: 0.6em 0.3em;
    min-height: 40px;
  }
}

/* Headings and text */
h1, h2, h3, h4 {
  font-family: 'Bangers', 'Arial Black', cursive;
  color: #222;
  margin-bottom: 0.5em;
  text-shadow: 0 2px 8px #ffe06644;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

h1 {
  font-size: clamp(1.8em, 5vw, 2.2em);
  letter-spacing: 0.03em;
  line-height: 1.2;
}

h2 {
  font-size: clamp(1.3em, 4vw, 1.5em);
  line-height: 1.3;
}

h3 {
  font-size: clamp(1.1em, 3.5vw, 1.3em);
  line-height: 1.4;
}

h4 {
  font-size: clamp(1em, 3vw, 1.1em);
  line-height: 1.4;
}

p, li, label {
  font-size: clamp(0.95em, 2.5vw, 1.1em);
  margin-bottom: 0.5em;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Forms */
form {
  display: flex;
  flex-direction: column;
  gap: 1em;
  margin: 1em 0;
}

input, select, textarea {
  padding: 0.8em 1em;
  border: 2px solid #ffe066;
  border-radius: 0.5em;
  font-size: 1em;
  background: #fffbe6;
  transition: border-color 0.2s;
  min-height: 44px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: #ffd700;
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.2);
}

/* Mobile form improvements */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.9em 1em;
    min-height: 48px;
  }
  
  textarea {
    min-height: 80px;
    resize: vertical;
  }
}

/* Buttons */
button, .btn {
  background: linear-gradient(90deg, #ffe066 60%, #ffd700 100%);
  color: #222;
  border: none;
  border-radius: 0.5em;
  padding: 0.8em 1.5em;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 8px #ffd70033;
  transition: background 0.2s, transform 0.2s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:hover, .btn:hover {
  background: linear-gradient(90deg, #ffd700 60%, #ffe066 100%);
  transform: scale(1.05) rotate(-2deg);
}

button:active, .btn:active {
  transform: scale(0.98);
}

/* Mobile button improvements */
@media (max-width: 768px) {
  button, .btn {
    font-size: 1em;
    padding: 0.9em 1.2em;
    min-height: 48px;
    border-radius: 12px;
  }
}

/* Popups and modals */
.popup, .modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  padding: 2em;
  border-radius: 1em;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  z-index: 10000;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.popup-overlay, .modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  backdrop-filter: blur(4px);
}

/* Mobile popup improvements */
@media (max-width: 768px) {
  .popup, .modal {
    padding: 1.5em;
    margin: 1em;
    max-width: calc(100vw - 2em);
    max-height: calc(100vh - 2em);
    border-radius: 0.75em;
  }
}

/* Game canvas responsive */
#game-canvas, canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  border-radius: 1em;
  touch-action: manipulation;
}

@media (max-width: 768px) {
  #game-canvas, canvas {
    max-width: 95vw;
    max-height: 60vh;
    border-radius: 0.75em;
  }
}

@media (max-width: 480px) {
  #game-canvas, canvas {
    max-width: 98vw;
    max-height: 50vh;
    border-radius: 0.5em;
  }
}

/* Animations */
.animated {
  transition: all 0.3s ease;
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Utility classes */
.hide { display: none !important; }
.show { display: block !important; }
.center { text-align: center; }
.bold { font-weight: bold; }
.mt-2 { margin-top: 2em; }
.mb-2 { margin-bottom: 2em; }
.p-1 { padding: 1em; }
.rounded { border-radius: 1em; }

/* Corn styling */
.corn {
  font-size: 2em;
  animation: bounce 2s infinite;
  display: inline-block;
}

@media (max-width: 768px) {
  .corn {
    font-size: 1.5em;
  }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

/* Tesla mode */
.tesla-mode {
  background: linear-gradient(135deg, #000 0%, #333 100%);
  color: #00ff00;
  font-family: 'Courier New', monospace;
}

/* Footer */
footer {
  background: rgba(44, 62, 80, 0.95);
  color: #fff;
  text-align: center;
  padding: 2rem 1rem;
  margin-top: 4rem;
  font-size: 1.1em;
  border-top: 4px solid #ff00cc;
  box-shadow: 0 -8px 32px #ff00cc88;
  position: relative;
  z-index: 2;
}

@media (max-width: 768px) {
  footer {
    padding: 1.5rem 0.75rem;
    margin-top: 2rem;
    font-size: 1em;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-thumb {
  background: #ffe066;
  border-radius: 4px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

/* Focus styles for accessibility */
:focus-visible {
  outline: 3px solid #ffe066;
  outline-offset: 2px;
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .menu-bar a:hover,
  .menu-bar a.active,
  .menu-bar__link:hover,
  .menu-bar__link:focus,
  button:hover,
  .btn:hover {
    transform: none;
  }
  
  /* Increase touch targets */
  .menu-bar a,
  .menu-bar__link,
  button,
  .btn {
    min-height: 48px;
  }
  
  /* Improve scrolling */
  * {
    -webkit-overflow-scrolling: touch;
  }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
  .menu-bar {
    padding: 0.3em 0.5em;
  }
  
  .menu-bar__logo {
    font-size: 1em;
    margin-bottom: 0.2em;
  }
  
  .menu-bar__link {
    padding: 0.4em 0.5em;
    min-height: 36px;
  }
  
  .container {
    margin: 0.5em auto;
    padding: 0.5em;
  }
  
  h1 {
    font-size: 1.5em;
  }
  
  h2 {
    font-size: 1.2em;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .menu-bar,
  .container,
  button,
  .btn {
    border-width: 0.5px;
  }
}

/* Print styles */
@media print {
  .menu-bar,
  .motd-banner,
  button,
  .btn {
    display: none !important;
  }
  
  .container {
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  body {
    background: white !important;
    color: black !important;
  }
}