:root{
  --bg: #0b1020;
  --card: rgba(255,255,255,0.06);
  --card2: rgba(255,255,255,0.09);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.65);
  --line: rgba(255,255,255,0.10);
  --shadow: 0 20px 60px rgba(0,0,0,0.35);
  --radius: 18px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 20% 0%, rgba(124,58,237,0.22), transparent 60%),
    radial-gradient(900px 500px at 80% 10%, rgba(59,130,246,0.18), transparent 55%),
    radial-gradient(700px 500px at 50% 100%, rgba(16,185,129,0.12), transparent 55%),
    var(--bg);
}

.app{
  max-width: 1100px;
  margin: 28px auto;
  padding: 0 16px 28px;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.brand{
  display:flex;
  align-items:center;
  gap: 12px;
  min-width: 220px;
}
.logo{
  width: 44px; height: 44px;
  display:grid; place-items:center;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(124,58,237,0.9), rgba(59,130,246,0.85));
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
  font-weight: 800;
  letter-spacing: 0.5px;
}
.title{ font-weight: 800; font-size: 18px; line-height: 1.1; }
.subtitle{ color: var(--muted); font-size: 13px; margin-top: 2px; }

.controls{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.monthLabel{
  min-width: 190px;
  text-align:center;
  font-weight: 750;
  letter-spacing: 0.2px;
  color: rgba(255,255,255,0.9);
}

.card{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.weekdays{
  display:grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
}
.weekdays > div{
  padding: 12px 10px;
  text-align:center;
  font-weight: 700;
  color: rgba(255,255,255,0.72);
  letter-spacing: 0.4px;
}

.grid{
  display:grid;
  grid-template-columns: repeat(7, 1fr);
}

.day{
  appearance:none;
  border: 0;
  background: transparent;
  color: inherit;
  text-align:left;
  padding: 10px;
  min-height: 118px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}
.day:nth-child(7n){ border-right: 0; }
.day.is-out{
  opacity: 0.35;
  cursor: default;
}
.day:not(.is-out):hover{
  background: rgba(255,255,255,0.06);
  transform: translateY(-1px);
}
.day__header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 8px;
}
.day__num{
  font-weight: 800;
  color: rgba(255,255,255,0.86);
}
.day.is-today .day__num{
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(59,130,246,0.22);
  border: 1px solid rgba(59,130,246,0.35);
}

.day__body{ display:flex; flex-direction:column; gap: 6px; }

.day.has-events{
  background: linear-gradient(180deg, rgba(124,58,237,0.12), transparent 55%);
}

.chip{
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip--more{
  color: rgba(255,255,255,0.72);
  background: rgba(255,255,255,0.03);
}

.btn{
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.92);
  padding: 10px 12px;
  border-radius: 12px;
  cursor:pointer;
  font-weight: 700;
  transition: transform 120ms ease, background 120ms ease;
}
.btn:hover{ background: rgba(255,255,255,0.10); transform: translateY(-1px); }
.btn:disabled{ opacity: 0.6; cursor: default; transform:none; }

.btn-primary{
  background: linear-gradient(135deg, rgba(16,185,129,0.38), rgba(59,130,246,0.28));
  border-color: rgba(255,255,255,0.18);
}
.btn-ghost{ background: rgba(255,255,255,0.03); }
.btn-sm{ padding: 8px 10px; border-radius: 10px; font-size: 12px; }

.footer{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: var(--muted);
}
.pill{
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  font-size: 12px;
}

/* Modal */
.modal{
  position: fixed;
  inset: 0;
  display: none;
}
.modal.is-open{ display:block; }
.modal__backdrop{
  position:absolute; inset:0;
  background: rgba(0,0,0,0.55);
}
.modal__panel{
  position: relative;
  width: min(820px, calc(100% - 24px));
  margin: 56px auto;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal__header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 12px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
}
.modal__title{ font-weight: 900; font-size: 16px; }
.modal__subtitle{ color: var(--muted); font-size: 13px; margin-top: 2px; }

.iconBtn{
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.92);
  width: 38px; height: 38px;
  border-radius: 12px;
  cursor: pointer;
}

.modal__body{
  padding: 14px 16px 18px;
  display:flex;
  flex-direction:column;
  gap: 12px;
}

.match{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 14px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
}
.match__time{ font-weight: 900; margin-bottom: 6px; }
.match__teams{ display:flex; gap: 10px; align-items:center; flex-wrap:wrap; }
.team{ font-weight: 800; }
.team.is-me{ color: rgba(16,185,129,0.95); }
.vs{ color: var(--muted); font-weight: 800; }
.match__meta{
  margin-top: 8px;
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.tag{
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(124,58,237,0.12);
  color: rgba(255,255,255,0.82);
}

/* =========================
   Mobile: layout + compactness + shrink fixes
   ========================= */

button, .btn, .day, .iconBtn, a.btn{
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (max-width: 760px){

  .app{
    margin: 14px auto;
    padding: 0 12px 18px;
  }

  .topbar{
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 12px;
  }

  .brand{ min-width: 0; }
  .logo{
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }
  .title{ font-size: 16px; }
  .subtitle{ font-size: 12px; }

  /* controls as grid */
  .controls{
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    gap: 8px;
    align-items: center;
  }

  #prevBtn, #nextBtn{
    padding: 10px 0;
    width: 44px;
    justify-self: stretch;
  }

  .monthLabel{
    min-width: 0;
    font-size: 14px;
    font-weight: 800;
    padding: 10px 0;
  }

  #todayBtn, #reloadBtn{
    grid-column: 1 / -1;
  }

  #todayBtn{ padding: 10px 12px; }
  #reloadBtn{ padding: 11px 12px; }

  .btn{ border-radius: 14px; }

  .weekdays > div{
    font-size: 11px;
    padding: 8px 2px;
  }

  /* ====== THE IMPORTANT PART: allow true shrink (no wide grid) ====== */
  .grid{
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .day{
    min-width: 0;
    width: 100%;
    overflow: hidden;

    /* ultra-compact height */
    min-height: 72px;
    padding: 6px;

    border-right: 1px solid rgba(255,255,255,0.08);
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  .day *{
    min-width: 0;
  }

  .day__header{ margin-bottom: 4px; }
  .day__num{ font-size: 12px; }

  .day__body{
    gap: 4px;
    overflow: hidden;
  }

  .chip{
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;

    font-size: 10.5px;
    line-height: 1.05;
    padding: 4px 6px;
    border-radius: 9px;
  }

  /* show only first chip on mobile */
  .day__body .chip:nth-child(n+2){
    display: none;
  }

  /* no +n more on mobile (details live in modal) */
  .chip--more{
    display: none;
  }

  .footer{
    margin-top: 10px;
    gap: 8px;
  }
  .pill{
    font-size: 11px;
    padding: 7px 9px;
  }

  /* modal becomes near-fullscreen sheet */
  .modal__panel{
    width: calc(100% - 14px);
    margin: 10px auto;
    border-radius: 18px;
    max-height: calc(100vh - 20px);
    display: flex;
    flex-direction: column;
  }

  .modal__header{
    padding: 14px 14px 10px;
    position: sticky;
    top: 0;
    z-index: 2;
    backdrop-filter: blur(10px);
  }

  .modal__body{
    padding: 12px 14px 16px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .match{
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
    border-radius: 16px;
  }

  .match__right{
    display:flex;
    justify-content:flex-end;
  }

  .match__teams{ gap: 8px; }
}

/* Extra small phones */
@media (max-width: 380px){
  .controls{
    grid-template-columns: 42px 1fr 42px;
    gap: 7px;
  }

  .day{
    min-height: 64px;
    padding: 5px;
  }

  .day__num{ font-size: 11px; }

  .chip{
    font-size: 10px;
    padding: 3px 5px;
  }

  .monthLabel{ font-size: 13px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  .btn, .day{ transition: none !important; }
}

