/* ========================================
   MANCHESTER UNITED SQUAD 2025/26 STYLES
   ======================================== */

/* CSS Variables */
:root {
  --mu-red: #d00000;
  --mu-dark: #0b0b0b;
  --border: 2px;
}

/* Base Styles */
body {
  background: #f6f7f9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ========================================
   HEADER
   ======================================== */
header {
  background: linear-gradient(135deg, #d00000 0%, #a00000 100%);
  color: #fff;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 4px 16px rgba(208, 0, 0, 0.3);
}

header img {
  height: 70px;
  width: auto;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: 0.5px;
}

/* ========================================
   TOP CONTENT
   ======================================== */
.top-content {
  padding: 2rem;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  margin-top: 1.5rem;
  border-top: 4px solid var(--mu-red);
}

/* ========================================
   SECTION TITLE
   ======================================== */
.section-title {
  color: var(--mu-red);
  font-weight: 800;
  font-size: 1.5rem;
  margin: 2.5rem 0 1.2rem;
  border-left: 6px solid var(--mu-red);
  padding-left: 0.8rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ========================================
   SEARCH WRAPPER
   ======================================== */
.search-wrapper {
  margin-bottom: 1.5rem;
}

.search-wrapper input {
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.search-wrapper input:focus {
  border-color: var(--mu-red);
  outline: none;
  box-shadow: 0 0 0 3px rgba(208, 0, 0, 0.1);
}

/* ========================================
   PLAYER CARDS
   ======================================== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 2rem;
}

.player-card {
  position: relative;
  height: 380px;
  perspective: 1000px;
  cursor: pointer;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.player-card:hover .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.card-front {
  background: #fff;
}

.card-back {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  color: #fff;
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  text-align: center;
}

.card-back .player-name {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  color: var(--mu-red);
}

.card-back .player-info {
  width: 100%;
  margin-bottom: 0.8rem;
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 45px;
}

.card-back .info-label {
  font-size: 0.75rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  min-width: 60px;
}

.card-back .info-value {
  font-size: 1rem;
  font-weight: 700;
  text-align: right;
  flex: 1;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Card Front Elements */
.frame {
  position: relative;
  aspect-ratio: 3/4;
  border: 3px solid var(--mu-red);
  border-radius: 12px;
  margin: 16px;
  overflow: hidden;
}

.img-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(135deg, #fff 0%, #f5f5f5 100%);
}

.img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  color: #495057;
  font-weight: 800;
  font-size: 2.5rem;
  letter-spacing: 2px;
}

.namebar {
  padding: 12px 16px;
  border-top: 2px solid #f0f0f0;
  font-weight: 700;
  letter-spacing: 0.3px;
  font-size: 0.95rem;
  background: #fafafa;
}

.squad-badge {
  position: absolute;
  top: 20px;
  right: 20px;
  background: #fff;
  border: 3px solid var(--mu-red);
  color: var(--mu-dark);
  font-weight: 900;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ========================================
   MATCH CARDS
   ======================================== */
.match-card {
  background: rgba(255, 255, 255, 0.9);
  color: #111;
  border-radius: 14px;
  padding: 20px 24px;
  border: 2px solid rgba(208, 0, 0, 0.15);
  box-shadow: 0 6px 18px rgba(208, 0, 0, 0.06);
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
}

.match-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(208, 0, 0, 0.1);
  border-color: rgba(208, 0, 0, 0.35);
}

.match-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 0.75rem;
  gap: 1rem;
}

.match-card .score {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--mu-red);
  line-height: 1;
}

.match-card .subtitle {
  color: #666;
  font-size: 0.9rem;
  margin-top: 0.35rem;
}

.team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.team.text-start {
  align-items: flex-start;
}

.team.text-end {
  align-items: flex-end;
}

.team img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.12));
}

.team small {
  font-size: 0.82rem;
  font-weight: 600;
  color: #0b0b0b;
}

/* ========================================
   FORMATION
   ======================================== */
.formation {
  background: linear-gradient(180deg, #1e5f1e 0%, #0d3f0d 100%);
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  margin-top: 3rem;
  margin-bottom: 2rem;
}

.formation h4 {
  text-align: center;
  color: #fff;
  margin-bottom: 2rem;
  font-size: 1.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Pitch wrapper to anchor coach box */
.pitch-wrap {
  position: relative;
  overflow-x: auto;
  padding-bottom: 10px;
}

.pitch {
  position: relative;
  width: 100%;
  max-width: 960px;
  min-width: 760px;
  height: min(90vh, 900px);
  margin: 0 auto;
  background: linear-gradient(180deg, #2d8a2d 0%, #1e6b1e 50%, #2d8a2d 100%);
  border: 4px solid rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.3);
}

.pitch::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90px;
  height: 90px;
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
}

.pitch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.4);
}

.pos {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: rgba(208, 0, 0, 0.9);
  border: 3px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s;
}

.pos:hover {
  transform: translate(-50%, -50%) scale(1.12);
}

.pos img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.pos span {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font: 700 0.7rem system-ui;
  text-shadow: 0 1px 2px #000;
}

/* Coach box */
.coach-box {
  position: absolute;
  top: -78px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  padding: 0.55rem 1rem;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  border: 2px solid rgba(208, 0, 0, 0.25);
}

.coach-box img {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--mu-red);
}

.coach-box .name {
  font-weight: 800;
  color: #0b0b0b;
  line-height: 1;
}

.coach-box small {
  color: #666;
}

/* ========================================
   BENCH
   ======================================== */
.bench {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 1.2rem;
}

.bench-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.82rem;
}

.bench-player img {
  width: 55px;
  height: 55px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--mu-red);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  margin-bottom: 0.4rem;
}

/* ========================================
   STANDINGS TABLE
   ======================================== */
.table-standings {
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  border-top: 4px solid var(--mu-red);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.table-standings thead th {
  background: #111;
  color: #fff;
  font-weight: 800;
  padding: 1rem 0.75rem;
}

.table-standings tbody td {
  padding: 0.85rem 0.75rem;
}

.badge-form {
  display: inline-flex;
  gap: 4px;
}

.badge-W,
.badge-D,
.badge-L {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: #fff;
  font-weight: 800;
  font-size: 0.72rem;
}

.badge-W {
  background: #16a34a;
}

.badge-D {
  background: #6b7280;
}

.badge-L {
  background: #dc2626;
}

/* Club cell with logo */
.club {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.club img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

/* ========================================
   FOOTER
   ======================================== */
footer {
  color: #666;
  padding: 28px 0;
  font-size: 0.92rem;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Large Desktop */
@media (max-width: 1200px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
  }
  .pitch {
    min-width: 680px;
    height: min(85vh, 800px);
  }
  .pos {
    width: 58px;
    height: 58px;
    font-size: 0.7rem;
  }
  .pos span {
    font-size: 0.65rem;
    bottom: -16px;
  }
  .coach-box {
    top: -72px;
    right: 12px;
    padding: 0.5rem 0.8rem;
  }
  .coach-box img {
    width: 52px;
    height: 52px;
  }
}

/* Tablet Landscape */
@media (max-width: 992px) {
  header {
    flex-direction: column;
    text-align: center;
    padding: 1.2rem;
  }
  header h1 {
    font-size: 1.5rem;
  }
  header img {
    height: 60px;
  }
  .section-title {
    font-size: 1.3rem;
    margin: 2rem 0 1rem;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 18px;
  }
  .player-card {
    height: 340px;
  }
  .card-back .player-name {
    font-size: 1.2rem;
    margin-bottom: 1.2rem;
  }
  .card-back .player-info {
    padding: 0.7rem;
    margin-bottom: 0.7rem;
  }
  .match-card {
    padding: 16px 20px;
  }
  .match-card .score {
    font-size: 1.8rem;
  }
  .team img {
    width: 38px;
    height: 38px;
  }
  .pitch {
    min-width: 600px;
    height: min(80vh, 700px);
  }
  .pos {
    width: 52px;
    height: 52px;
    font-size: 0.65rem;
  }
  .pos span {
    font-size: 0.6rem;
    bottom: -14px;
  }
  .formation {
    padding: 2rem;
  }
  .formation h4 {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
  }
  .coach-box {
    position: relative;
    top: 0;
    right: 0;
    margin: 0 auto 1.5rem;
    max-width: 280px;
  }
  .bench-player img {
    width: 48px;
    height: 48px;
  }
  .bench-player {
    font-size: 0.78rem;
  }
}

/* Tablet Portrait */
@media (max-width: 768px) {
  header {
    padding: 1rem;
  }
  header h1 {
    font-size: 1.3rem;
  }
  header img {
    height: 50px;
  }
  .top-content {
    padding: 1.5rem;
    margin-top: 1rem;
  }
  .top-content p {
    font-size: 0.95rem;
    line-height: 1.6;
  }
  .section-title {
    font-size: 1.2rem;
    margin: 1.5rem 0 1rem;
    padding-left: 0.6rem;
    border-left: 4px solid var(--mu-red);
  }
  .search-wrapper {
    margin-bottom: 1rem;
  }
  .search-wrapper input {
    font-size: 0.9rem;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
  }
  .player-card {
    height: 300px;
  }
  .frame {
    margin: 12px;
  }
  .squad-badge {
    width: 42px;
    height: 42px;
    font-size: 1rem;
    top: 16px;
    right: 16px;
  }
  .card-back .player-name {
    font-size: 1.1rem;
  }
  .card-back .player-info {
    padding: 0.6rem;
    font-size: 0.9rem;
  }
  .match-card {
    padding: 14px 16px;
  }
  .match-header {
    gap: 0.8rem;
  }
  .match-card .score {
    font-size: 1.6rem;
  }
  .match-card .subtitle {
    font-size: 0.85rem;
  }
  .team img {
    width: 34px;
    height: 34px;
  }
  .team small {
    font-size: 0.75rem;
  }
  .pitch-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .pitch {
    min-width: 500px;
    height: 600px;
  }
  .pos {
    width: 46px;
    height: 46px;
    font-size: 0.6rem;
  }
  .pos span {
    font-size: 0.55rem;
    bottom: -13px;
  }
  .formation {
    padding: 1.5rem;
    margin-top: 2rem;
  }
  .formation h4 {
    font-size: 1.2rem;
  }
  .coach-box {
    flex-direction: column;
    text-align: center;
    padding: 0.6rem;
  }
  .coach-box img {
    width: 48px;
    height: 48px;
  }
  .coach-box .name {
    font-size: 0.9rem;
  }
  .coach-box small {
    font-size: 0.75rem;
  }
  .bench {
    gap: 10px;
  }
  .bench-player img {
    width: 44px;
    height: 44px;
    border: 2px solid var(--mu-red);
  }
  .bench-player {
    font-size: 0.75rem;
  }
  .table-standings {
    font-size: 0.85rem;
  }
  .table-standings th,
  .table-standings td {
    padding: 0.6rem 0.4rem;
  }
  .club img {
    width: 18px;
    height: 18px;
  }
  .badge-W,
  .badge-D,
  .badge-L {
    width: 20px;
    height: 20px;
    font-size: 0.68rem;
  }
  footer {
    font-size: 0.85rem;
    padding: 20px 0;
  }
}

/* Mobile */
@media (max-width: 576px) {
  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  header h1 {
    font-size: 1.1rem;
  }
  header img {
    height: 42px;
  }
  .top-content {
    padding: 1.2rem;
    border-radius: 12px;
  }
  .top-content p {
    font-size: 0.88rem;
  }
  .section-title {
    font-size: 1.1rem;
    letter-spacing: 0.3px;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }
  .player-card {
    height: 270px;
  }
  .squad-badge {
    width: 38px;
    height: 38px;
    font-size: 0.9rem;
    top: 12px;
    right: 12px;
    border: 2px solid var(--mu-red);
  }
  .namebar {
    font-size: 0.85rem;
    padding: 10px 12px;
  }
  .card-back {
    padding: 1.5rem;
  }
  .card-back .player-name {
    font-size: 1rem;
    margin-bottom: 1rem;
  }
  .card-back .player-info {
    padding: 0.5rem;
    margin-bottom: 0.6rem;
    min-height: 40px;
  }
  .card-back .info-label {
    font-size: 0.7rem;
    min-width: 50px;
  }
  .card-back .info-value {
    font-size: 0.88rem;
  }
  .match-card {
    padding: 12px 14px;
    border-radius: 12px;
  }
  .match-header {
    grid-template-columns: 1fr;
    gap: 1rem;
    text-align: center;
  }
  .team {
    flex-direction: row;
    justify-content: center;
  }
  .team.text-start,
  .team.text-end {
    align-items: center;
  }
  .team img {
    width: 32px;
    height: 32px;
  }
  .team small {
    font-size: 0.72rem;
  }
  .match-card .score {
    font-size: 1.4rem;
  }
  .match-card .subtitle {
    font-size: 0.8rem;
    margin-top: 0.25rem;
  }
  .pitch {
    min-width: 420px;
    height: 520px;
  }
  .pos {
    width: 42px;
    height: 42px;
    font-size: 0.55rem;
  }
  .pos span {
    font-size: 0.5rem;
    bottom: -12px;
  }
  .formation {
    padding: 1.2rem;
    border-radius: 12px;
  }
  .formation h4 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
  }
  .coach-box {
    max-width: 240px;
    padding: 0.5rem;
  }
  .coach-box img {
    width: 42px;
    height: 42px;
    border: 2px solid var(--mu-red);
  }
  .coach-box .name {
    font-size: 0.85rem;
  }
  .coach-box small {
    font-size: 0.7rem;
  }
  .bench {
    gap: 8px;
  }
  .bench-player img {
    width: 40px;
    height: 40px;
  }
  .bench-player {
    font-size: 0.7rem;
  }
  .table-standings {
    font-size: 0.8rem;
    border-radius: 12px;
  }
  .table-standings th,
  .table-standings td {
    padding: 0.5rem 0.3rem;
  }
  .table-standings th:first-child,
  .table-standings td:first-child {
    padding-left: 0.6rem;
  }
  .club {
    gap: 6px;
  }
  .club img {
    width: 16px;
    height: 16px;
  }
  .badge-form {
    gap: 3px;
  }
  .badge-W,
  .badge-D,
  .badge-L {
    width: 18px;
    height: 18px;
    font-size: 0.65rem;
    border-radius: 4px;
  }
  footer {
    font-size: 0.8rem;
  }
}

/* Extra Small Mobile */
@media (max-width: 380px) {
  header h1 {
    font-size: 1rem;
  }
  .grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .player-card {
    height: 250px;
  }
  .pitch {
    min-width: 360px;
    height: 480px;
  }
  .pos {
    width: 38px;
    height: 38px;
  }
}
/* ==== FIX 1: Kartu pertandingan lebih “fit” di HP ==== */
/* Kurangi padding & tinggi visual elemen di mobile kecil */
@media (max-width: 576px) {
  .match-card { padding: 10px 12px !important; }
  .match-card .score { font-size: 1.25rem !important; }
  .match-card .subtitle { font-size: 0.78rem !important; }
  .team img { width: 28px !important; height: 28px !important; }
  .team small { font-size: 0.7rem !important; }
  /* ruang antar kartu biar tidak “menggelembung” */
  .container > *:not(:last-child) { margin-bottom: 1.25rem; }
}

/* ==== FIX 2: Foto pelatih tak muncul di desktop ==== */
/* Naikkan z-index agar tidak ketutup pitch, dan cegah clip */
.pitch { position: relative; z-index: 1; }
.coach-box {
  z-index: 3;                   /* di atas pitch */
  overflow: visible;            /* antisipasi cropping */
}
.coach-box img {
  display: block;
  width: 58px; height: 58px;    /* pastikan ada ukuran pasti */
  object-fit: cover;
}

/* Saat layar <= 992px kamu memang ubah coach-box jadi relative
   (sudah ada di filemu) sehingga aman di mobile:contentReference[oaicite:2]{index=2}. */

/* ==== FIX 3: Kartu pemain & grid sedikit lebih rapih ==== */
.player-card { transition: transform .25s ease; }
.player-card:hover { transform: translateY(-3px); }

/* Sedikit rapikan spacing global antar section */
.container > *:not(:last-child) { margin-bottom: 2rem; }

/* Antisipasi gambar tinggi-lebar agar tidak gepeng */
.img-wrap img { width: 100%; height: 100%; object-fit: contain; }
/* === Desktop-only fixes untuk coach box === */
@media (min-width: 993px) {
  /* pastikan area di atas lapangan tidak terpotong */
  .pitch-wrap { 
    position: relative;
    overflow: visible;        /* tadinya auto; bikin elemen minus-top tidak ke-clip */
  }
  /* lapangan di bawah coach box */
  .pitch {
    position: relative;
    z-index: 1;
  }
  /* coach box di atas lapangan & tidak ke-clip */
  .coach-box {
    position: absolute;       /* sudah begitu di CSS kamu */
    top: -78px;
    right: 18px;
    z-index: 3;               /* kunci: tampil di atas pitch */
    overflow: visible;
  }
  .coach-box img {
    display: block;
    width: 58px; 
    height: 58px; 
    object-fit: cover;
  }
}
/* === Desktop: tampilkan coach-box tanpa negative offset === */
@media (min-width: 993px) {
  .pitch-wrap{
    position: relative;
    overflow: visible;     /* jangan ter-clip */
    padding-top: 90px;     /* sisakan ruang untuk card pelatih */
    z-index: 2;            /* di atas judul/elemen lain */
  }
  .pitch{
    position: relative;
    z-index: 1;            /* lapangan di bawah coach box */
  }
  .coach-box{
    position: absolute;
    top: 0;                /* gunakan ruang yang kita sediakan */
    right: 18px;
    z-index: 3;            /* di atas pitch */
  }
  .coach-box img{
    display: block;
    width: 58px; height: 58px; object-fit: cover;
  }
}

