/* Brickan, topplistan och firandet. */

.board-title { font-size: clamp(1.5rem, 4vw, 2.2rem); }

.scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.score {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.6rem 0.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.score-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.score-of { font-size: 1rem; color: var(--muted); font-weight: 500; }
.score-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.badges { flex-direction: row; justify-content: center; align-items: center; gap: 0.3rem; font-size: 1.4rem; }
.badge { display: inline-block; }
.badge.small { font-size: 0.9rem; }

.board-progress {
  width: 100%;
  height: 0.7rem;
  border-radius: 999px;
  overflow: hidden;
  border: none;
  margin-bottom: 0.8rem;
  background: var(--line);
}

.board-progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
.board-progress::-webkit-progress-value { background: linear-gradient(90deg, var(--slot-0), var(--accent)); border-radius: 999px; transition: width 0.4s ease; }
.board-progress::-moz-progress-bar { background: linear-gradient(90deg, var(--slot-0), var(--accent)); border-radius: 999px; }

.suggestion { background: rgba(255, 255, 255, 0.7); border-left: 4px solid var(--accent); padding: 0.5rem 0.8rem; border-radius: 8px; }

.board-grid {
  display: grid;
  gap: 6px;
  margin: 0 auto 1.25rem;
  padding: 6px;
  background: #3f3a33;
  border-radius: 12px;
  max-width: 900px;
}

.board-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.board-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.board-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.board-grid.cols-6 { grid-template-columns: repeat(6, 1fr); }
.board-grid.cols-7 { grid-template-columns: repeat(7, 1fr); }

.board-grid.board-full { box-shadow: 0 0 0 4px gold, 0 0 30px rgba(255, 200, 0, 0.6); }

.cell { position: relative; aspect-ratio: 1 / 1; min-width: 0; }
.cell.slot-0 .cell-button { background: var(--slot-0); color: var(--slot-0-ink); }
.cell.slot-1 .cell-button { background: var(--slot-1); color: var(--slot-1-ink); }

.cell-form { height: 100%; margin: 0; }

.cell-button {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.3rem;
  font: inherit;
  font-weight: 500;
  font-size: clamp(0.62rem, 1.5vw, 0.95rem);
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.1s ease, filter 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.cell-button:hover:not(:disabled) { filter: brightness(1.05); transform: scale(1.02); }
.cell-button:active:not(:disabled) { transform: scale(0.98); }
.cell-button:disabled { cursor: default; }
.cell-button:focus-visible { outline: 3px solid var(--ink); outline-offset: -3px; }

.cell-text { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; hyphens: auto; overflow-wrap: anywhere; }

.cell-count { font-weight: 700; font-size: 0.9em; }
.cell-progress { width: 80%; height: 0.35rem; border: none; border-radius: 999px; overflow: hidden; background: rgba(0, 0, 0, 0.12); }
.cell-progress::-webkit-progress-bar { background: rgba(0, 0, 0, 0.12); }
.cell-progress::-webkit-progress-value { background: var(--done); }
.cell-progress::-moz-progress-bar { background: var(--done); }

.cell.done .cell-button { filter: saturate(0.6); }
.cell.done .cell-text { opacity: 0.55; }

.stamp {
  position: absolute;
  inset: auto auto 6% auto;
  font-family: var(--font-hand);
  font-size: clamp(0.9rem, 2.4vw, 1.5rem);
  color: var(--done);
  border: 2px solid var(--done);
  border-radius: 6px;
  padding: 0 0.35em;
  transform: rotate(-12deg);
  background: rgba(255, 255, 255, 0.75);
  animation: stamp-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
  pointer-events: none;
}

@keyframes stamp-in {
  from { transform: rotate(-12deg) scale(2.2); opacity: 0; }
  to { transform: rotate(-12deg) scale(1); opacity: 1; }
}

.cell.in-line .cell-button { box-shadow: inset 0 0 0 3px var(--done); }
.cell.in-line .cell-button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.5) 50%, transparent 70%);
  animation: shine 2.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes shine {
  0% { transform: translateX(-100%); }
  60%, 100% { transform: translateX(100%); }
}

.cell.suggested .cell-button { box-shadow: inset 0 0 0 3px var(--accent); animation: pulse 1.8s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: inset 0 0 0 3px var(--accent); }
  50% { box-shadow: inset 0 0 0 5px var(--accent); }
}

.cell.free .cell-button { background: #fff; color: var(--muted); }
.cell-free { font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.08em; }

.cell.flash .cell-button { animation: flash 0.6s ease; }

@keyframes flash {
  0% { filter: brightness(1); }
  30% { filter: brightness(1.8); transform: scale(1.06); }
  100% { filter: brightness(1); transform: scale(1); }
}

.cell-menu { position: absolute; top: 2px; right: 2px; z-index: 2; }
.cell-menu summary {
  list-style: none;
  cursor: pointer;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.7);
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}

.cell-menu summary::-webkit-details-marker { display: none; }
.cell-menu[open] summary { background: var(--ink); color: #fff; }

.cell-menu-panel {
  position: absolute;
  right: 0;
  top: 1.8rem;
  width: 14rem;
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: left;
}

.cell-menu-panel p { margin: 0; }
.undo-form { margin: 0; }

.celebrate {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.8rem 1rem;
  margin-bottom: 0.8rem;
  font-weight: 600;
  text-align: center;
  animation: pop 0.4s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.celebrate-line, .celebrate-full, .celebrate-half { font-size: 1.3rem; background: linear-gradient(90deg, var(--slot-0), #fff, var(--slot-1)); }
.celebrate-full { font-size: 1.6rem; }

@keyframes pop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.banner-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 30;
}

.banner-overlay span {
  font-size: clamp(2.5rem, 10vw, 6rem);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 4px 0 var(--accent), 0 8px 30px rgba(0, 0, 0, 0.4);
  animation: banner 2.6s ease forwards;
  letter-spacing: 0.04em;
}

@keyframes banner {
  0% { transform: scale(0.3) rotate(-8deg); opacity: 0; }
  15% { transform: scale(1.1) rotate(2deg); opacity: 1; }
  25% { transform: scale(1) rotate(0); }
  80% { opacity: 1; }
  100% { transform: scale(1.05); opacity: 0; }
}

.fly-points {
  position: fixed;
  font-weight: 700;
  color: var(--done);
  font-size: 1.4rem;
  pointer-events: none;
  animation: fly 0.9s ease-out forwards;
  z-index: 30;
}

@keyframes fly {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-60px); opacity: 0; }
}

.board-description { margin-top: 1rem; }

/* Topplista */
.team-total {
  background: linear-gradient(120deg, var(--slot-0), var(--slot-1));
  border-radius: 12px;
  padding: 0.9rem 1.2rem;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-weight: 500;
}

.team-total-value { font-size: 2rem; font-weight: 700; }

.podium { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; align-items: end; }
.podium-place { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 0.8rem 0.5rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.podium-place.place-1 { order: 2; padding-top: 1.4rem; background: linear-gradient(180deg, #fff6d5, #fff); }
.podium-place.place-2 { order: 1; }
.podium-place.place-3 { order: 3; }
.podium-place .avatar { width: 2.8rem; height: 2.8rem; font-size: 1.5rem; }
.podium-medal { font-size: 1.6rem; }
.podium-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; max-width: 100%; white-space: nowrap; }
.podium-points { color: var(--muted); font-size: 0.9rem; }
.podium-place.me { outline: 3px solid var(--accent); }

.leaderboard { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.leaderboard th, .leaderboard td { padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); text-align: left; }
.leaderboard th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.leaderboard tr.me { background: rgba(217, 130, 43, 0.1); font-weight: 600; }
.leaderboard tr.moved { animation: row-flash 1.2s ease; }
.player-cell { display: flex; align-items: center; gap: 0.5rem; }
.points { font-weight: 700; }

@keyframes row-flash {
  0% { background: rgba(63, 143, 90, 0.35); }
  100% { background: transparent; }
}

@media (max-width: 600px) {
  .cell-menu-panel { width: 11rem; }
  .board-grid { gap: 4px; padding: 4px; }
  .cell-button { padding: 0.25rem 0.2rem; }
  .cell-text { -webkit-line-clamp: 4; }
}
