/* ==========================================================
   Empire Valley Mobile / Tablet Responsive Patch
   Ziel: Webseite auf Handy, Smartphone und Tablet sauber nutzbar machen
   ========================================================== */

*{box-sizing:border-box;}
html,body{max-width:100%;overflow-x:hidden;}
img,video,canvas,iframe{max-width:100%;height:auto;}

/* Desktop bleibt unverändert. Ab Tablet wird die Oberfläche gestapelt. */
@media (max-width: 1400px){
  :root{--ev-nav:92px;}
  .ev4-top-command{
    grid-template-columns:1fr;
    margin-right:calc(var(--ev-nav) + 20px);
    min-height:auto;
  }
  .ev4-header-metrics{grid-template-columns:repeat(4,minmax(130px,1fr));}
  .ev3-hero-main{grid-template-columns:1fr;gap:22px;}
  .ev3-hero-copy{text-align:center;align-items:center;}
  .ev3-live-card{max-width:100%;}
  .ev-control-panels,
  .ev3-command-grid,
  .ev3-ops-grid,
  .evtc-stat-grid,
  .evcc-stat-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
}

@media (max-width: 1024px){
  body{padding-bottom:92px;}

  main{
    width:100%!important;
    max-width:100%!important;
    padding:0 16px 40px!important;
  }
  .site-footer{
    padding:22px 16px 110px!important;
    text-align:center;
  }

  /* Header mobil/tablet */
  .ev4-top-command{
    margin:14px 14px 16px!important;
    padding:16px!important;
    border-radius:24px!important;
    grid-template-columns:1fr!important;
    gap:14px!important;
  }
  .ev4-brand-block{gap:12px!important;align-items:center!important;}
  .ev4-logo-frame{width:66px!important;height:66px!important;border-radius:20px!important;}
  .ev4-logo-frame img{width:52px!important;height:52px!important;}
  .ev4-brand-text span{font-size:.66rem!important;letter-spacing:.14em!important;}
  .ev4-brand-text h1{
    font-size:clamp(1.15rem,5vw,2rem)!important;
    white-space:normal!important;
    line-height:1.1!important;
  }
  .ev4-brand-text p{
    white-space:normal!important;
    max-width:100%!important;
    font-size:.9rem!important;
    line-height:1.25!important;
  }
  .ev4-header-metrics{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:10px!important;
  }
  .ev4-metric{min-height:76px!important;border-radius:18px!important;padding:11px!important;}
  .ev4-metric strong{font-size:.96rem!important;}
  .ev4-metric em{font-size:.68rem!important;}

  /* Rechte Navigation wird auf Handy zur unteren Command-Bar */
  .ev4-right-nav{
    left:10px!important;
    right:10px!important;
    bottom:10px!important;
    top:auto!important;
    width:auto!important;
    height:74px!important;
    border-radius:24px!important;
    flex-direction:row!important;
    justify-content:space-between!important;
    padding:8px 10px!important;
    z-index:999!important;
  }
  .ev4-side-brand{width:56px!important;min-height:56px!important;border-radius:18px!important;}
  .ev4-side-brand strong{font-size:1rem!important;}
  .ev4-side-brand span{font-size:.44rem!important;margin-top:-12px!important;}
  .ev4-nav-toggle{
    display:grid!important;
    place-items:center!important;
    width:54px!important;
    height:54px!important;
    border-radius:18px!important;
    border:1px solid rgba(88,244,255,.28)!important;
    background:linear-gradient(135deg,rgba(88,244,255,.18),rgba(155,92,255,.16))!important;
    color:#eaffff!important;
    font-size:1.25rem!important;
    font-weight:900!important;
  }
  .ev4-side-links{
    display:none!important;
    position:fixed!important;
    left:12px!important;
    right:12px!important;
    bottom:92px!important;
    width:auto!important;
    max-height:68vh!important;
    overflow:auto!important;
    padding:14px!important;
    border-radius:24px!important;
    border:1px solid rgba(88,244,255,.22)!important;
    background:linear-gradient(160deg,rgba(5,9,24,.98),rgba(18,9,42,.97))!important;
    box-shadow:0 24px 90px rgba(0,0,0,.58)!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:10px!important;
    align-items:stretch!important;
  }
  .ev4-side-links.open{display:grid!important;}
  .ev4-side-links a{
    width:100%!important;
    height:56px!important;
    display:flex!important;
    align-items:center!important;
    justify-content:flex-start!important;
    gap:10px!important;
    padding:0 12px!important;
    border-radius:16px!important;
    transform:none!important;
  }
  .ev4-side-links a i{width:26px;text-align:center;}
  .ev4-side-links a span{
    position:static!important;
    opacity:1!important;
    transform:none!important;
    padding:0!important;
    background:transparent!important;
    border:0!important;
    box-shadow:none!important;
    color:#fff!important;
    font-size:.86rem!important;
  }
  .ev4-side-actions{
    margin-top:0!important;
    flex-direction:row!important;
    width:auto!important;
  }
  .ev4-side-actions a{padding:10px 12px!important;font-size:.72rem!important;}

  /* Startseite / Command Center */
  .ev3-hero,
  .ev-control-runner,
  .ev-control-panels,
  .ev-section,
  .ev-live-dashboard,
  .ev3-control-ticker,
  .ev3-command-grid,
  .ev3-ops-row,
  .ev3-news-section,
  .ev3-join-panel{
    width:100%!important;
    margin-left:0!important;
    margin-right:0!important;
  }
  .ev3-hero{min-height:auto!important;border-radius:26px!important;}
  .ev3-hero-main{
    grid-template-columns:1fr!important;
    min-height:auto!important;
    padding:28px 18px!important;
  }
  .ev3-title,
  .ev3-hero-copy h1{
    font-size:clamp(2.2rem,12vw,5rem)!important;
    line-height:.96!important;
    text-align:center!important;
    word-break:break-word!important;
  }
  .ev3-outline{font-size:clamp(2rem,10vw,4.2rem)!important;}
  .ev3-hero-actions,
  .ev-join-actions{justify-content:center!important;}
  .ev3-live-card{width:100%!important;}
  .ev-radar-metrics{grid-template-columns:repeat(3,1fr)!important;}
  .ev-control-runner{border-radius:18px!important;}
  .ev-runner-track{font-size:.72rem!important;gap:22px!important;}
  .ev-control-panels,
  .ev3-command-grid,
  .ev3-ops-grid,
  .ev-faction-grid{
    display:grid!important;
    grid-template-columns:1fr 1fr!important;
    gap:12px!important;
  }
  .ev-control-tile,
  .ev3-command-card,
  .ev3-ops-card,
  .ev-faction-card{min-height:170px!important;border-radius:22px!important;padding:18px!important;}
  .ev-live-dashboard{border-radius:24px!important;padding:18px!important;}
  .ev-live-grid,
  .ev-live-cards{grid-template-columns:1fr 1fr!important;}

  /* Regelwerk */
  .rules-wrapper,
  .regelwerk-wrap,
  .ev-rules-shell{
    width:100%!important;
    max-width:100%!important;
    margin:0!important;
    padding:0!important;
  }
  .rules-layout,
  .ev-rules-layout{
    display:block!important;
  }
  .rules-toc,
  .ev-rules-toc{
    position:relative!important;
    top:auto!important;
    width:100%!important;
    max-height:none!important;
    margin:0 0 16px!important;
  }
  .rules-content,
  .ev-rules-content{
    width:100%!important;
    max-width:100%!important;
    padding:20px 16px!important;
    font-size:1rem!important;
  }
  .rules-content h1,.rules-content h2,.rules-content h3,
  .ev-rules-content h1,.ev-rules-content h2,.ev-rules-content h3{
    word-break:break-word!important;
  }

  /* Team Control / Spielerakte */
  .evtc-wrap,
  .team-player-wrap,
  .evcc-wrap{
    width:100%!important;
    max-width:100%!important;
    margin:16px 0 110px!important;
    padding:0!important;
  }
  .evtc-hero,
  .team-player-hero,
  .evcc-hero{
    flex-direction:column!important;
    align-items:flex-start!important;
    padding:22px!important;
    border-radius:22px!important;
  }
  .evtc-filter{
    grid-template-columns:1fr 1fr!important;
  }
  .evtc-layout,
  .team-player-layout,
  .evcc-layout{
    grid-template-columns:1fr!important;
  }
  .evtc-list{max-height:none!important;}
  .evtc-panel{min-height:auto!important;}
  .evtc-stat-grid,
  .team-player-stat-grid,
  .evcc-stat-grid{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
  .team-player-grid,
  .evcc-grid{
    grid-template-columns:1fr!important;
  }
  table{display:block;max-width:100%;overflow-x:auto;white-space:nowrap;}

  /* Profil / Formulare / Rechtstexte */
  .profile-card,.profile-box,.legal-grid,.legal-card,.legal-hero,.auth-box{
    max-width:100%!important;
  }
  .legal-grid{display:block!important;}
  .legal-toc{position:relative!important;top:auto!important;margin-bottom:16px!important;}
  input,select,textarea,button{max-width:100%;}
  .auth-popup{padding:12px!important;}
  .auth-box{max-height:90vh!important;overflow:auto!important;}

  .ts3-wrapper{display:none!important;}
}

@media (max-width: 640px){
  body{font-size:15px;}
  main{padding:0 10px 34px!important;}
  .ev4-top-command{margin:10px!important;padding:13px!important;border-radius:20px!important;}
  .ev4-brand-block{align-items:flex-start!important;}
  .ev4-logo-frame{width:58px!important;height:58px!important;}
  .ev4-logo-frame img{width:46px!important;height:46px!important;}
  .ev4-brand-text h1{font-size:1.25rem!important;}
  .ev4-brand-text p{font-size:.78rem!important;}
  .ev4-header-metrics{grid-template-columns:1fr 1fr!important;}
  .ev4-metric{min-height:68px!important;padding:9px!important;}
  .ev4-metric small{font-size:.58rem!important;}
  .ev4-metric strong{font-size:.78rem!important;}
  .ev4-metric em{display:none!important;}
  .ev4-auth-actions{gap:5px!important;margin-top:6px!important;}
  .ev4-auth-actions a{font-size:.65rem!important;padding:5px 7px!important;}

  .ev4-right-nav{height:68px!important;border-radius:20px!important;}
  .ev4-side-brand{width:50px!important;min-height:50px!important;}
  .ev4-nav-toggle{width:50px!important;height:50px!important;}
  .ev4-side-actions a{font-size:.65rem!important;padding:9px 9px!important;}
  .ev4-side-links{grid-template-columns:1fr!important;bottom:86px!important;}

  .ev3-hero-main{padding:22px 12px!important;}
  .ev3-title,.ev3-hero-copy h1{font-size:2.35rem!important;}
  .ev3-outline{font-size:2.15rem!important;}
  .ev3-hero-copy p{font-size:.9rem!important;line-height:1.45!important;}
  .ev3-hero-actions a,
  .ev-join-actions a{width:100%!important;text-align:center!important;}
  .ev-radar-metrics,
  .ev-live-grid,
  .ev-live-cards,
  .ev-control-panels,
  .ev3-command-grid,
  .ev3-ops-grid,
  .ev-faction-grid,
  .evtc-stat-grid,
  .team-player-stat-grid,
  .evcc-stat-grid{
    grid-template-columns:1fr!important;
  }
  .ev-live-head,
  .ev-join-command{flex-direction:column!important;align-items:flex-start!important;}
  .ev-live-head h2{font-size:1.55rem!important;}
  .ev-live-card strong,.ev-live-panel strong{font-size:2rem!important;}

  .evtc-filter{grid-template-columns:1fr!important;}
  .evtc-hero h1,.team-player-hero h1,.evcc-hero h1{font-size:1.8rem!important;line-height:1.08!important;}
  .evtc-ticket{padding:14px!important;}
  .evtc-chat-message{max-width:100%!important;}

  .rules-content,.ev-rules-content{padding:16px 12px!important;}
  .rules-content h1,.ev-rules-content h1{font-size:1.85rem!important;}
  .rules-content h2,.ev-rules-content h2{font-size:1.45rem!important;}

  .legal-hero h1{font-size:2rem!important;}
  .legal-card{padding:18px!important;}
}

@media (max-width: 390px){
  .ev4-header-metrics{grid-template-columns:1fr!important;}
  .ev4-side-actions{display:none!important;}
  .ev3-title,.ev3-hero-copy h1{font-size:2rem!important;}
}
