:root {
  color-scheme: light;
  --color-cream: #f7f2e6;
  --color-mustard: #f0c45a;
  --color-teal: #5b8f8a;
  --color-coral: #e88e7a;
  --color-olive: #7d8c5a;
  --color-slate: #8fa3b3;
  --color-graphite: #333333;
  --color-paper: #fffdf5;
  --color-line: rgba(90, 70, 42, 0.16);
  --color-hairline: rgba(90, 70, 42, 0.09);
  --shadow-soft: 0 2px 8px rgba(60, 45, 30, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Nunito", "Trebuchet MS", "Avenir Next", ui-sans-serif, system-ui, sans-serif;
  background-color: var(--color-cream);
  color: var(--color-graphite);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

button {
  border: 0;
  font: inherit;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: -12px -12px 14px;
  padding: max(12px, env(safe-area-inset-top)) 12px 10px;
  background: rgba(247, 242, 230, 0.94);
  border-bottom: 1px solid var(--color-line);
  backdrop-filter: blur(8px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-block > div:last-child {
  min-width: 0;
}

.quest-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 2px solid #483b28;
  border-radius: 13px 10px 15px 9px;
  background: var(--color-mustard);
  box-shadow: 2px 3px 0 rgba(72, 59, 40, 0.18);
  font-weight: 900;
  transform: rotate(-2deg);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 5vw, 2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.32rem;
}

.topbar p,
.player-head p,
.activity-info span {
  color: rgba(51, 51, 51, 0.68);
  font-size: 0.9rem;
}

.top-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
  background: transparent;
}

.info-button {
  width: 30px;
  min-height: 30px;
  border: 1px solid rgba(90, 70, 42, 0.18);
  border-radius: 999px;
  background: rgba(255, 253, 245, 0.54);
  color: rgba(51, 51, 51, 0.68);
  cursor: pointer;
  font-weight: 900;
}

.info-button[aria-expanded="true"] {
  background: rgba(240, 196, 90, 0.5);
  color: #2d2418;
}

.rules-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  width: min(320px, calc(100vw - 24px));
  border: 1px solid var(--color-line);
  border-radius: 13px 10px 14px 11px;
  background: var(--color-paper);
  box-shadow: var(--shadow-soft);
  color: rgba(51, 51, 51, 0.76);
  font-size: 0.84rem;
  font-weight: 750;
  line-height: 1.35;
  padding: 10px 12px;
}

.rules-popover strong {
  display: block;
  margin-bottom: 6px;
}

.rules-popover ul {
  margin: 0;
  padding-left: 17px;
}

.rules-popover li + li {
  margin-top: 2px;
}

.rules-popover p {
  margin-top: 7px;
  color: rgba(51, 51, 51, 0.62);
  font-size: 0.8rem;
}

.reset-data-button {
  margin-top: 9px;
  padding: 0;
  background: transparent;
  color: rgba(96, 70, 24, 0.84);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 900;
  text-decoration: underline;
  text-decoration-color: rgba(240, 196, 90, 0.8);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.nav-link {
  position: relative;
  border: 0;
  color: var(--color-graphite);
  font-size: 0.92rem;
  font-weight: 850;
  padding: 6px 1px 8px;
  text-decoration: none;
  white-space: nowrap;
}

.nav-link.active {
  background: transparent;
}

.nav-link.active::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: 2px;
  height: 3px;
  border-radius: 999px;
  background: var(--color-mustard);
  transform: rotate(-1deg);
}

.board {
  display: grid;
  gap: 14px;
}

.player-card {
  position: relative;
  border: 1px solid rgba(90, 70, 42, 0.12);
  border-radius: 13px 11px 15px 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.34), transparent 42%),
    rgba(255, 253, 245, 0.42);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.player-card::before {
  content: "";
  display: block;
  height: 7px;
  background: var(--color-teal);
}

.player-card.julinka::before {
  background: var(--color-coral);
}

.player-card.alenka::before {
  background: var(--color-mustard);
}

.player-card.pavlik::before {
  background: var(--color-slate);
}

.player-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-hairline);
}

.player-avatar {
  width: 64px;
  height: 64px;
  object-fit: contain;
  align-self: end;
}

.activity-list {
  display: grid;
}

.activity-row {
  display: grid;
  grid-template-columns: minmax(170px, 0.72fr) minmax(0, 1.28fr);
  gap: 10px;
  align-items: center;
  padding: 13px 12px;
  border-bottom: 1px solid var(--color-hairline);
}

.activity-row:last-child {
  border-bottom: 0;
}

.activity-row.done-today {
  background: linear-gradient(90deg, rgba(125, 140, 90, 0.08), rgba(125, 140, 90, 0.02));
}

.activity-info {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.activity-info strong {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  min-width: 0;
}

.activity-info span {
  color: rgba(51, 51, 51, 0.54);
  font-weight: 650;
}

.progress-cell {
  position: relative;
  display: grid;
  gap: 5px;
  min-width: 0;
}

.activity-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.icon-token {
  border: 1px solid rgba(113, 91, 54, 0.24);
  border-radius: 12px 9px 12px 10px;
  background: rgba(240, 196, 90, 0.42);
  color: #3a2f22;
  font-size: 0.82rem;
  font-weight: 900;
  box-shadow: inset 0 -1px 0 rgba(113, 91, 54, 0.08);
}

.ondrasek .icon-token {
  background: rgba(91, 143, 138, 0.24);
}

.sticker-track {
  display: grid;
  grid-template-columns: repeat(20, minmax(25px, 1fr));
  gap: 5px;
  padding: 2px 1px;
  background: transparent;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.sticker-track::-webkit-scrollbar {
  display: none;
}

.sticker-track.series-complete .dot.filled {
  animation: seriesGlow 760ms ease-out both;
}

.dot {
  display: grid;
  place-items: center;
  position: relative;
  aspect-ratio: 1;
  min-width: 25px;
  min-height: 25px;
  border: 1.5px solid rgba(113, 91, 54, 0.31);
  border-radius: 48% 52% 50% 46% / 50% 47% 53% 49%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.86), transparent 42%),
    rgba(255, 253, 245, 0.78);
  color: #8b7b62;
  font-size: 0.62rem;
  font-weight: 850;
  line-height: 1;
  box-shadow: inset 0 -1px 0 rgba(113, 91, 54, 0.06);
  cursor: default;
  padding: 0;
}

.dot:nth-child(3n) {
  border-radius: 51% 47% 49% 53% / 48% 52% 46% 50%;
  transform: translateY(1px);
}

.dot:nth-child(4n) {
  border-radius: 46% 54% 52% 48% / 52% 46% 50% 48%;
  transform: rotate(-3deg);
}

.dot.filled {
  border-color: rgba(125, 140, 90, 0.35);
  background: var(--color-olive);
  color: #fffdf5;
  box-shadow: 0 2px 0 rgba(68, 101, 68, 0.14);
}

.julinka .dot.filled {
  background: var(--color-coral);
}

.alenka .dot.filled {
  background: var(--color-mustard);
  color: #3a2f22;
}

.pavlik .dot.filled {
  background: var(--color-teal);
}

.dot.checkpoint {
  border-width: 2px;
  border-color: rgba(191, 142, 45, 0.62);
  border-radius: 42% 58% 46% 54% / 52% 44% 56% 48%;
  background:
    radial-gradient(circle at 36% 30%, rgba(255, 253, 245, 0.88), transparent 40%),
    rgba(240, 196, 90, 0.18);
  color: #8a6820;
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 253, 245, 0.84),
    inset 0 -1px 0 rgba(113, 91, 54, 0.08);
}

.dot.checkpoint::before {
  content: "★";
  position: absolute;
  inset: -7px -5px auto auto;
  color: rgba(240, 196, 90, 0.82);
  font-size: 0.6rem;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 253, 245, 0.86);
}

.dot.filled.checkpoint {
  border-color: rgba(240, 196, 90, 0.78);
  box-shadow:
    0 2px 0 rgba(68, 101, 68, 0.14),
    inset 0 0 0 2px rgba(255, 253, 245, 0.48);
}

.dot.filled.checkpoint::before {
  inset: auto auto 50% 50%;
  color: rgba(255, 253, 245, 0.92);
  font-size: 0.5rem;
  transform: translate(-50%, 50%);
}

.dot.just-bonus {
  animation: bonusPulse 720ms ease-out both;
}

.dot.next {
  outline: 2px dotted rgba(193, 132, 59, 0.42);
  outline-offset: 2px;
}

.dot.next:not(:disabled) {
  border-color: var(--color-mustard);
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 253, 245, 0.9), transparent 40%),
    #f8dfa2;
  cursor: pointer;
  box-shadow: 1px 2px 0 rgba(72, 59, 40, 0.12);
}

.dot.next:not(:disabled)::after {
  content: "+";
  position: absolute;
  inset: -12px -10px auto auto;
  color: var(--color-coral);
  font-size: 0.9rem;
  font-weight: 900;
  opacity: 0;
  transform: translateY(4px);
}

.dot.next:not(:disabled):active {
  transform: translateY(1px);
}

.bonus-hint {
  justify-self: start;
  border: 1px solid rgba(191, 142, 45, 0.28);
  border-radius: 999px;
  background: rgba(240, 196, 90, 0.16);
  color: rgba(96, 70, 24, 0.88);
  font-size: 0.76rem;
  font-weight: 900;
  padding: 3px 8px;
}

.bonus-pop {
  position: absolute;
  right: 10px;
  top: -12px;
  z-index: 1;
  border: 1px solid rgba(191, 142, 45, 0.38);
  border-radius: 999px;
  background: var(--color-mustard);
  box-shadow: 2px 3px 0 rgba(72, 59, 40, 0.14);
  color: #2d2418;
  font-size: 0.76rem;
  font-weight: 950;
  padding: 4px 8px;
  pointer-events: none;
  animation: bonusFloat 760ms ease-out both;
}

@keyframes bonusPulse {
  0% {
    transform: scale(1);
  }
  44% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes bonusFloat {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.94);
  }
  20%,
  74% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-10px) scale(1);
  }
}

@keyframes seriesGlow {
  0% {
    filter: saturate(1);
  }
  42% {
    filter: saturate(1.18) brightness(1.07);
  }
  100% {
    filter: saturate(1);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 20px));
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(64, 50, 30, 0.22);
  border-radius: 14px 11px 15px 12px;
  padding: 12px 14px;
  background: #3a2f22;
  color: #fff8e8;
  z-index: 20;
  box-shadow: var(--shadow-soft);
}

.toast img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  flex: 0 0 auto;
}

.toast strong {
  display: block;
  margin-bottom: 2px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(54, 47, 34, 0.45);
  backdrop-filter: blur(3px);
}

.confirm-card {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid rgba(64, 50, 30, 0.22);
  border-radius: 18px 13px 19px 15px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.55), transparent 48%),
    var(--color-paper);
  box-shadow: 0 18px 42px rgba(60, 45, 30, 0.18);
}

.confirm-badge {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid var(--color-line);
  border-radius: 18px 14px 18px 13px;
  background: rgba(247, 242, 230, 0.85);
  box-shadow: 2px 3px 0 rgba(72, 59, 40, 0.12);
}

.confirm-badge .activity-icon {
  width: 42px;
  height: 42px;
}

.confirm-card p {
  margin-top: 8px;
  color: rgba(51, 51, 51, 0.72);
  line-height: 1.4;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ghost-button,
.primary-button {
  min-height: 44px;
  border: 1px solid var(--color-line);
  border-radius: 13px 10px 14px 11px;
  cursor: pointer;
  font-weight: 900;
}

.ghost-button {
  background: rgba(255, 253, 245, 0.68);
  color: var(--color-graphite);
}

.primary-button {
  background: var(--color-mustard);
  color: #2d2418;
  box-shadow: 2px 3px 0 rgba(72, 59, 40, 0.16);
}

.danger-button {
  background: var(--color-coral);
  color: #2d2418;
}

.stats-board {
  display: grid;
  gap: 14px;
}

.stats-overview,
.stats-card {
  border: 1px solid rgba(90, 70, 42, 0.12);
  border-radius: 13px 11px 15px 12px;
  background: rgba(255, 253, 245, 0.42);
  box-shadow: var(--shadow-soft);
}

.stats-overview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px;
}

.stats-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.stats-actions label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(51, 51, 51, 0.62);
  font-size: 0.82rem;
  font-weight: 850;
}

.stats-actions select,
.stats-actions button {
  min-height: 34px;
  border: 1px solid var(--color-hairline);
  border-radius: 11px 9px 12px 10px;
  background: rgba(255, 253, 245, 0.58);
  color: var(--color-graphite);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 850;
  padding: 6px 9px;
}

.stats-actions button {
  cursor: pointer;
}

.stats-overview p,
.stats-head p {
  color: rgba(51, 51, 51, 0.68);
}

.stats-card {
  overflow: hidden;
}

.stats-card::before {
  content: "";
  display: block;
  height: 7px;
  background: var(--color-teal);
}

.stats-card.julinka::before {
  background: var(--color-coral);
}

.stats-card.alenka::before {
  background: var(--color-mustard);
}

.stats-card.pavlik::before {
  background: var(--color-slate);
}

.stats-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  padding: 13px 12px;
  border-bottom: 1px solid var(--color-hairline);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
}

.stats-table th,
.stats-table td {
  border-bottom: 1px solid var(--color-hairline);
  padding: 10px 12px;
  text-align: right;
  vertical-align: top;
}

.stats-table th:first-child,
.stats-table td:first-child {
  text-align: left;
}

.stats-table th {
  color: rgba(51, 51, 51, 0.62);
  font-size: 0.82rem;
  font-weight: 900;
}

.stats-table tr:last-child td {
  border-bottom: 0;
}

.stats-table details {
  max-width: 100%;
}

.stats-table summary {
  display: inline-grid;
  gap: 3px;
  cursor: pointer;
  list-style: none;
}

.stats-table summary::-webkit-details-marker {
  display: none;
}

.stats-activity {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
}

.stats-mobile-line {
  display: none;
  color: rgba(51, 51, 51, 0.66);
  font-size: 0.84rem;
  font-weight: 500;
}

.detail-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.detail-panel span {
  border: 1px solid var(--color-hairline);
  border-radius: 12px 9px 13px 10px;
  background: rgba(247, 242, 230, 0.32);
  padding: 5px 7px;
  color: rgba(51, 51, 51, 0.68);
  font-size: 0.78rem;
}

.secondary-stat {
  color: rgba(51, 51, 51, 0.56);
}

@media (max-width: 1024px) {
  .activity-row {
    grid-template-columns: 1fr;
  }

  .sticker-track {
    grid-column: auto;
    grid-row: auto;
  }

  .stats-table th,
  .stats-table td {
    padding: 10px 9px;
  }
}

@media (max-width: 640px) {
  .stats-overview {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-actions {
    justify-content: flex-start;
  }

  .stats-table,
  .stats-table tbody,
  .stats-table tr,
  .stats-table td {
    display: block;
  }

  .stats-table thead {
    display: none;
  }

  .stats-table td {
    border-bottom: 0;
    padding: 0;
    text-align: left;
  }

  .stats-table tr {
    border-bottom: 1px solid var(--color-hairline);
    padding: 10px;
  }

  .stats-table tr:last-child {
    border-bottom: 0;
  }

  .stats-table td:not(:first-child) {
    display: none;
  }

  .stats-mobile-line {
    display: block;
  }

}

@media (max-width: 520px) {
  .app-shell {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .topbar {
    align-items: center;
    gap: 8px;
    margin: -8px -8px 10px;
    padding: max(8px, env(safe-area-inset-top)) 8px 8px;
  }

  .quest-mark {
    width: 32px;
    height: 32px;
    font-size: 0.86rem;
  }

  h1 {
    font-size: 1.18rem;
  }

  h2 {
    font-size: 1.15rem;
  }

  .topbar p,
  .player-head p,
  .activity-info span {
    font-size: 0.82rem;
  }

  .nav-link {
    padding: 6px 1px 8px;
    font-size: 0.82rem;
  }

  .player-head,
  .activity-row,
  .stats-head {
    padding: 10px;
  }

  .player-head {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .player-avatar {
    width: 52px;
    height: 52px;
  }

  .activity-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .sticker-track {
    grid-template-columns: repeat(20, 40px);
    gap: 5px;
    padding: 3px 1px 5px;
    margin-inline: 0;
  }

  .dot {
    min-width: 40px;
    min-height: 40px;
    font-size: 0.5rem;
  }

  .confirm-card {
    padding: 15px;
  }

  .confirm-actions {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 375px) {
  .brand-block {
    gap: 7px;
  }

  .quest-mark {
    width: 30px;
    height: 30px;
  }

  h1 {
    font-size: 1.08rem;
  }

  .topbar p {
    font-size: 0.76rem;
  }

  .nav-link {
    padding: 6px 1px 8px;
  }
}
