/* LoL Grid 3x3 — builds on style.css tokens. */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.grid-status {
  display: flex; justify-content: center; align-items: baseline; gap: 8px;
  margin: 20px 0 14px; font-size: 0.82rem; color: var(--text-muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.guesses-left {
  font-family: 'Cinzel', serif; font-size: 1.4rem; color: var(--gold-light);
  text-shadow: 0 0 8px rgba(200, 170, 110, 0.35);
}

/* Give-up confirmation */
.confirm-modal { max-width: 400px; text-align: center; }
.confirm-modal h2 { margin-bottom: 10px; }
.confirm-modal p { color: var(--text-muted); font-size: 0.9rem; }

/* Countdown to the next grid, in the result modal below the share buttons. */
.grid-countdown {
  margin-top: 22px; padding-top: 16px;
  border-top: 1px solid rgba(200, 170, 110, 0.15);
  text-align: center; font-size: 0.72rem; color: var(--text-muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.grid-countdown-time {
  margin-top: 4px;
  font-family: 'Cinzel', serif; font-size: 1.6rem; color: var(--gold-light);
  font-variant-numeric: tabular-nums; letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(200, 170, 110, 0.3);
}

/* 4x4 layout: corner + 3 column headers, then 3 × (row header + 3 cells). */
.lolgrid {
  display: grid;
  grid-template-columns: minmax(64px, 0.8fr) repeat(3, 1fr);
  gap: 8px;
  max-width: 560px;
  margin: 0 auto;
}
.lolgrid-corner { display: flex; align-items: center; justify-content: center; }
.lolgrid-corner img { width: 46%; opacity: 0.55; filter: drop-shadow(0 0 6px rgba(200, 170, 110, 0.4)); }
.axis {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px 4px 7px; min-height: 92px; min-width: 0; border-radius: 8px;
  background: linear-gradient(180deg, rgba(22, 34, 58, 0.75), rgba(13, 21, 38, 0.6)); border: 1px solid var(--border);
}
.axis-col { border-bottom: 2px solid var(--gold-dark); }
.axis-row { border-right: 2px solid var(--gold-dark); }
.axis > .cond { position: static; }

.cell {
  position: relative; aspect-ratio: 1;
  background: var(--panel2);
  border: 1px solid rgba(200, 170, 110, 0.22);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(0, 180, 255, 0.03);
  transition: border-color .2s, background .2s, transform .2s, box-shadow .2s;
}
button.cell { cursor: pointer; font: inherit; color: inherit; }
/* Empty cells: small gold corners, like a camera frame. */
button.cell::before {
  content: ''; position: absolute; inset: 5px; pointer-events: none; opacity: 0.45;
  background:
    linear-gradient(var(--gold), var(--gold)) top left / 10px 1.5px, linear-gradient(var(--gold), var(--gold)) top left / 1.5px 10px,
    linear-gradient(var(--gold), var(--gold)) bottom right / 10px 1.5px, linear-gradient(var(--gold), var(--gold)) bottom right / 1.5px 10px;
  background-repeat: no-repeat;
}
button.cell:focus-visible {
  border-color: var(--gold);
  background: rgba(200, 170, 110, 0.08);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), inset 0 0 8px rgba(200, 170, 110, 0.15);
  outline: none;
}
.cell-plus {
  font-size: 2.2rem; font-weight: 300; color: var(--gold);
  line-height: 1; opacity: 0.7; transition: opacity .2s, transform .2s;
}
/* Hover only with a real pointer — on touch it would stick after closing the search. */
@media (hover: hover) {
  button.cell:hover {
    border-color: var(--cyan);
    background: rgba(63, 208, 232, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 0 0 1px rgba(63, 208, 232, 0.35), 0 0 18px rgba(63, 208, 232, 0.18);
  }
  button.cell:hover .cell-plus { opacity: 1; transform: scale(1.1); }
}
button.cell:active { background: rgba(200, 170, 110, 0.14); border-color: var(--gold); }

.cell.filled { border-color: rgba(74, 224, 136, 0.7); background: rgba(20, 43, 30, 0.55); }
.cell.revealed { opacity: 0.6; border-style: dashed; }
.cell-player { position: absolute; inset: 0; display: flex; flex-direction: column; }
/* flex-basis 0 + min-height 0: the 256px portrait shrinks to the space left above the nickname
   instead of pushing the nickname out of the cell. */
.cell-player .avatar { flex: 1 1 0; min-height: 0; width: 100%; border-radius: 0; font-size: 1.6rem; }
.cell-player-nick {
  flex-shrink: 0;
  background: linear-gradient(to top, rgba(5, 8, 17, 0.95), rgba(5, 8, 17, 0.7));
  padding: 4px 4px 5px; font-size: 0.74rem; font-weight: 700; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--gold-light);
}
.cell-count {
  position: absolute; top: 4px; right: 5px; font: inherit; font-size: 0.62rem; color: var(--text-muted);
  background: rgba(5, 8, 17, 0.75); border: 1px solid transparent; border-radius: 3px; padding: 0 4px;
  cursor: pointer; transition: color .15s, background .15s, border-color .15s;
}
.cell-count:hover, .cell-count:focus-visible, .cell-count.active {
  color: var(--gold-light); background: rgba(200, 170, 110, 0.25); border-color: rgba(200, 170, 110, 0.5);
  outline: none;
}
.cell.revealed:has(.cell-count.active) { opacity: 1; }

.answers-popover {
  position: fixed; z-index: 60; width: 190px; max-height: min(300px, 60vh); overflow-y: auto;
  background: #0d1527; border: 1px solid rgba(200, 170, 110, 0.4); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55); padding: 4px;
  animation: answers-in .14s ease-out;
}
.answers-popover ul { list-style: none; margin: 0; padding: 0; }
.answers-popover li {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 4px;
  font-size: 0.8rem; color: var(--text);
}
.answers-popover li.current { background: rgba(74, 224, 136, 0.14); color: var(--gold-light); font-weight: 700; }
.answers-popover .avatar { width: 24px; height: 24px; font-size: 0.6rem; }
@keyframes answers-in { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- Avatars ---------- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover; object-position: top;
  background: #1a2235; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--gold); font-size: 0.95rem; letter-spacing: 0.5px;
}
.avatar.initials { border: 1px solid rgba(200, 170, 110, 0.3); }

/* ---------- Condition badges ---------- */
.cond { display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; max-width: 100%; }
.cond-icon {
  width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; position: relative;
}
.cond-icon > img { max-width: 100%; max-height: 100%; }
.cond-caption {
  max-width: 100%; overflow-wrap: normal; word-break: normal; /* a word too long shrinks (grid.js fitCaptions) instead of breaking */
  font-size: 0.68rem; font-weight: 700; line-height: 1.2; color: var(--gold-light);
  text-transform: uppercase; letter-spacing: 0.3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* The two conditions at the top of the search window: big enough to read the logos (phones: see below). */
.cond.small .cond-icon { width: 64px; height: 64px; }
/* League logos are white traces on a transparent background (scripts/make-league-logos.js): straight on the card. */
.cond-league .cond-icon > img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }
/* As in Guess the Pro: team logos, trophies and the coach/retired icons without a light plate, with a soft halo — dark
   by default, light for logos that are dark themselves (grid.js fitLogo marks them and evens out their size). */
:is(.cond-team, .cond-trophy, .cond-coach, .cond-retired, .cond-role) .cond-icon > img {
  width: 78%; height: 78%; object-fit: contain;
  filter: drop-shadow(0 0 3.5px rgba(5, 8, 17, 0.45)) drop-shadow(0 0 1px rgba(5, 8, 17, 0.25));
}
:is(.cond-team, .cond-trophy, .cond-coach, .cond-retired, .cond-role) .cond-icon > img.logo-dark {
  filter: drop-shadow(0 0 1px rgba(240, 230, 210, 0.75)) drop-shadow(0 0 3.5px rgba(240, 230, 210, 0.4));
}
/* Logos only partly near-black (100 Thieves' "100", the ELEMENTS lettering, Liquid's shield edge): a tight light outline only —
   a wide glow would fill the gaps of thin lettering ("THIEVES"). */
:is(.cond-team, .cond-trophy, .cond-coach, .cond-retired, .cond-role) .cond-icon > img.logo-mixed { filter: drop-shadow(0 0 0.8px rgba(240, 230, 210, 0.8)); }
/* Black one-colour logos in negative: white, with the default dark halo. */
:is(.cond-team, .cond-trophy, .cond-coach, .cond-retired, .cond-role) .cond-icon > img.logo-neg {
  filter: invert(1) drop-shadow(0 0 3.5px rgba(5, 8, 17, 0.45)) drop-shadow(0 0 1px rgba(5, 8, 17, 0.25));
}
.cond.small .cond-caption { font-size: 0.78rem; }
/* Flags are 4:3 — keep the ratio inside the square icon box. */
.cond-nationality .cond-icon > img {
  width: 100%; height: auto; border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(200, 170, 110, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.emblem {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; font-weight: 800; font-size: 0.78rem; letter-spacing: 0.5px;
  color: #fff; border: 2px solid rgba(255, 255, 255, 0.35); text-align: center; line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
/* League emblem: shield shape, colour per league. */
.emblem-league { clip-path: polygon(50% 0, 100% 18%, 100% 62%, 50% 100%, 0 62%, 0 18%); border: none; }
.emblem-league[data-league="LCK"] { background: linear-gradient(160deg, #3d7bd9, #173a7a); }
.emblem-league[data-league="LPL"] { background: linear-gradient(160deg, #e0453a, #7a1a14); }
.emblem-league[data-league="LEC"] { background: linear-gradient(160deg, #22b8c7, #0d5260); }
.emblem-league[data-league="LCS"] { background: linear-gradient(160deg, #3a4b9b, #151d48); }
.emblem-league[data-league="LTA"] { background: linear-gradient(160deg, #e8a33a, #7a4a10); }
.emblem-team { border-radius: 10px; background: linear-gradient(160deg, #2a3550, #121a2c); font-size: 0.72rem; }

.cond-info {
  position: absolute; top: 3px; right: 3px; width: 17px; height: 17px; padding: 0; border-radius: 50%;
  border: 1px solid rgba(63, 208, 232, 0.7); background: rgba(5, 8, 17, 0.75); color: var(--cyan);
  font: italic 800 0.62rem/15px Georgia, serif; text-align: center; cursor: help;
}
/* The dot stays small; 17 + 2 × 14 = 45 px to tap. */
.cond-info::after { content: ''; position: absolute; inset: -14px; }
.cond-info:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.cond-info.tip-open, .cond-info:hover { background: var(--cyan); color: #04141a; }
/* The bubble of a condition (grid.js openTip): fixed next to its button, arrow pointing at it. */
.cond-tip {
  position: fixed; z-index: 1000; max-width: min(300px, calc(100vw - 16px)); padding: 8px 12px; border-radius: 6px;
  background: #0d1527; border: 1px solid var(--gold); color: var(--gold-light); font-size: 0.82rem; font-weight: 600;
  line-height: 1.4; text-align: center; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.55), 0 0 10px rgba(200, 170, 110, 0.2);
}
.cond-tip::after {
  content: ''; position: absolute; left: var(--arrow-x, 50%); bottom: -6px; width: 10px; height: 10px; margin-left: -5px;
  background: #0d1527; border: solid var(--gold); border-width: 0 1px 1px 0; transform: rotate(45deg);
}
.cond-tip.below::after { bottom: auto; top: -6px; border-width: 1px 0 0 1px; }
.cond { cursor: pointer; }

.cond-teammate .avatar { width: 100%; height: 100%; border: 2px solid var(--gold); }
.cond-teammate .handshake {
  position: absolute; right: -4px; bottom: -4px; font-size: 0.9rem;
  background: #0d1527; border: 1px solid var(--gold); border-radius: 50%;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
}

/* ---------- Search modal ---------- */
.search-modal { max-width: 460px; padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.search-conds {
  display: flex; align-items: center; justify-content: center; gap: 14px; padding-right: 20px;
}
.search-conds .times { color: var(--text-muted); font-size: 1.1rem; }
.search-input {
  width: 100%; padding: 12px 14px; border-radius: 4px;
  border: 1px solid rgba(200, 170, 110, 0.3); background: rgba(10, 16, 28, 0.8);
  color: var(--text); font-family: inherit; font-size: 1rem;
}
.search-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 10px rgba(200, 170, 110, 0.2); }
.search-results {
  list-style: none; max-height: min(52vh, 420px); overflow-y: auto;
  border: 1px solid rgba(200, 170, 110, 0.12); border-radius: 4px;
}
.search-results:empty { display: none; }
.result-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.result-item:last-child { border-bottom: none; }
.result-item.active, .result-item:hover { background: rgba(200, 170, 110, 0.12); }
.result-item.disabled { opacity: 0.35; cursor: not-allowed; }
.result-text { min-width: 0; }
.result-nick {
  font-weight: 800; font-size: 1.05rem; color: var(--gold-light); line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result-name { font-size: 0.74rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-tag { margin-left: auto; font-size: 0.66rem; color: var(--text-muted); text-transform: uppercase; white-space: nowrap; }
.search-msg { min-height: 20px; text-align: center; font-size: 0.85rem; font-weight: 600; color: #ffca58; }
.search-msg.bad { color: #ff7a7a; }
.search-modal.shake { animation: shake .45s ease; }

.result-score {
  font-family: 'Cinzel', serif; font-size: 2rem; color: var(--gold-light);
  text-shadow: 0 0 10px rgba(200, 170, 110, 0.35);
}

/* Landscape screens: the board is about as tall as it is wide, so its width follows the window height and the
   whole panel (header, board, button) fits without scrolling. */
@media (min-width: 521px) {
  .lolgrid { max-width: clamp(240px, calc(100vh - 290px), 560px); }
}
@media (min-width: 521px) and (max-height: 900px) {
  .grid-status { margin: 8px 0 6px; }
  .axis { min-height: 0; }
  .lolgrid { max-width: clamp(240px, calc(100vh - 270px), 560px); }
  .cond-icon { width: 42px; height: 42px; }
  .cond-caption { font-size: 0.6rem; }
  .lolgrid-corner img { width: 38%; }
}

@media (max-width: 520px) {
  .lolgrid { gap: 6px; grid-template-columns: minmax(70px, 0.8fr) repeat(3, 1fr); }
  .axis { min-height: 0; }
  .cond-icon { width: 46px; height: 46px; }
  .cond-caption { font-size: 0.68rem; }
  .cell-player-nick { font-size: 0.64rem; }
  .grid-status { margin: 10px 0 8px; }
  .cell-count { font-size: 0.6rem; padding: 2px 5px; }
  /* Search sits at the top, so the on-screen keyboard doesn't cover the results. */
  #searchOverlay { align-items: flex-start; }
  .search-modal { padding: 16px 14px 12px; gap: 10px; }
  .cond.small .cond-icon { width: 52px; height: 52px; }
  .cond.small .cond-caption { font-size: 0.72rem; }
  .search-results { max-height: 46vh; max-height: 46dvh; }
  .result-item { padding: 10px 12px; }
  .grid-countdown-time { font-size: 1.4rem; }
}
@media (max-width: 374px) {
  .lolgrid { grid-template-columns: minmax(62px, 0.75fr) repeat(3, 1fr); gap: 5px; }
  .cond-icon { width: 40px; height: 40px; }
  .cond-caption { font-size: 0.62rem; }
}
