/* =======================================================
   ⚽ Gambetas Coach's Virtual Field Styles
   ======================================================= */

/* --- Root Variables --- */
:root {
  --neon:#8FD400;
  --bg:#000;
  --panel:#111;
  --ink:#fff;
  --teamA:#000;
  --teamB:#FF2800; /* Ferrari Red */
}

/* --- Global Reset --- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Header --- */
#hdr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: #0f0f0f;
  border-bottom: 1px solid #222;
}

#hdr .title {
  color: var(--neon);
  font-weight: 700;
  margin-right: auto;
}

.btn,
select,
input[type="color"],
input[type="range"],
input[type="number"] {
  height: 36px;
  border: 1px solid #333;
  border-radius: 6px;
  background: #151515;
  color: #fff;
  cursor: pointer;
  padding: 0 10px;
}

.btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
}

label.inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

input[type="color"] {
  width: 46px;
  padding: 0;
}

input[type="range"] {
  width: 140px;
  accent-color: var(--neon);
}

/* --- Layout --- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: 10px;
  padding: 10px;
  min-height: 0;
}

/* --- Panels (Roster/Bench) --- */
.panel {
  background: var(--panel);
  border: 1px solid #222;
  border-radius: 12px;
  padding: 10px;
  overflow: auto;
}

.panel h3 {
  margin: 0 0 8px;
  color: var(--neon);
}

/* --- Field Board --- */
.board {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #0b2a10;
  border: 1px solid #153a10;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.pitch-wrap {
  position: relative;
  width: 100%;
  max-width: 1600px;
  aspect-ratio: 3/2;
}

#pitch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

#draw {
  position: absolute;
  inset: 0;
  z-index: 2;
}

#players {
  position: absolute;
  inset: 0;
  z-index: 3;
}

/* --- Player Markers --- */
.player {
  position: absolute;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  transform: translate(-50%, -50%);
  cursor: grab;
  user-select: none;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}

.black { background: var(--teamA); }
.red   { background: var(--teamB); }

/* --- Roster/Bench Lists --- */
.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #222;
  border-radius: 8px;
  padding: 6px;
}

.name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.acts {
  display: flex;
  gap: 6px;
  align-items: center;
}

.act {
  background: none;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 2px 8px;
  color: var(--neon);
  cursor: pointer;
}

.act.del { color: #c00; }

.toggleTeam {
  border-color: #444;
  color: #fff;
  font-weight: 700;
}

/* --- Bottom Bar --- */
.bottom {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  background: #111;
  border-top: 1px solid #222;
  padding: 8px;
}

#tips { color: var(--neon); font-size: .85rem; }
#shortcuts { font-size: .85rem; }
#help { cursor: pointer; color: var(--neon); }

/* --- Popup (Instructions/Edit/Actions) --- */
#popupMask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: none;
  z-index: 98;
}

#popup {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
  z-index: 99;
  background: #000;
  color: #fff;
  border: 2px solid var(--neon);
  box-shadow: 0 0 14px var(--neon);
  padding: 16px;
  border-radius: 14px;
  max-width: 560px;
  width: min(92vw,560px);
  text-align: center;
  display: none;
}

#popup h4 { margin: 0 0 8px; color: var(--neon); }
#popup .msg { margin: 6px 0 12px; }

#popup .row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin: 6px 0;
}

#popup input {
  height: 36px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #111;
  color: #fff;
  padding: 0 10px;
}

#popup .btnrow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}

#popup .btnrow .btn { min-width: 140px; }

/* --- Fullscreen Exit Button --- */
#fsExit {
  position: fixed;
  right: 12px;
  top: 10px;
  z-index: 100;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  display: none;
}
.show-x #fsExit { display: block; }

/* =======================================================
   📱 Responsive Fixes
   ======================================================= */

/* Phones */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  #hdr {
    flex-wrap: nowrap;
    overflow-x: auto;
    font-size: 0.85rem;
  }
  .btn, select, input {
    flex: none;
    font-size: 0.8rem;
    height: 30px;
  }
  .pitch-wrap {
    width: 100%;
    max-width: none;
    aspect-ratio: 3/2;
  }

  /* Landscape prompt overlay */
  body::after {
    content: "📱 Please rotate your phone for a better experience (Landscape Mode)";
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.8);
    color: var(--neon);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    display: none;
    z-index: 2000;
  }
  @media screen and (orientation: portrait) {
    body::after { display: block; }
  }
}

/* Tablets */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 200px 1fr 200px;
  }
}

/* =======================================================
   🔧 Fix: Hide only the Virtual Field header
   ======================================================= */
body.hide-header #hdr {
  display: none;
}

/* --- Home Button (Virtual Field only) --- */
.home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px; /* matches other .btn height */
  padding: 0 14px;
  margin-left: 10px; /* space after title */
  background: #fff;
  color: #000;
  font-weight: bold;
  border-radius: 6px;
  border: 1px solid #ccc;
  text-decoration: none;
  box-shadow: 0 2px 4px rgba(0,0,0,.3);
  flex-shrink: 0; /* prevents squishing in flex wrap */
}

.home-btn:hover {
  background: #ddd;
}

/* --- Header Alignment --- */
#hdr {
  justify-content: flex-start; /* normal layout */
}

.show-x #hdr {
  justify-content: center;     /* center all buttons when FS */
  margin-right: 60px;          /* leave gap for the X */
}
