/* MatchMind design system: flat, token-driven, mobile-first single column.
   Tokens are defined once in templates/base.html.twig. */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
}

button:disabled {
    cursor: default;
}

a {
    color: var(--mm-accent-strong);
}

:focus-visible {
    outline: 2px solid var(--mm-accent);
    outline-offset: 2px;
}

body {
    min-height: 100dvh;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

/* ── Page column ────────────────────────────────── */
.game-container {
    max-width: 560px;
    min-height: 100dvh;
    margin: 0 auto;
    padding: 16px 0 calc(24px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
}

/* ── Top bar ────────────────────────────────────── */
.game-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px 4px;
}

.game-nav-back {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    padding: 0 8px;
    color: var(--mm-ink);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
}

.game-nav-dates {
    display: flex;
    align-items: center;
    gap: 2px;
}

.game-nav-step {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: none;
    color: var(--mm-ink);
}

.game-nav-step:disabled {
    color: var(--mm-ink-disabled);
}

.game-date {
    min-width: 84px;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
}

/* ── Title block ────────────────────────────────── */
.game-header {
    padding: 4px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.game-header h1 {
    font-family: var(--mm-font-display);
    font-size: 28px;
    font-weight: 800;
    line-height: 1.05;
}

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

.game-brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.game-logo {
    display: block;
    flex: none;
    width: auto;
}

.game-logo--toplyga { height: 68px; }
.game-logo--my11 { height: 44px; }

.game-header .game-meta {
    margin-top: 10px;
}

/* ── Site brand bar (privacy pages) ─────────────── */
.site-header {
    max-width: 720px;
    margin: 0 auto;
    padding: 12px 16px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    color: var(--mm-ink);
    text-decoration: none;
}

.site-brand-name {
    font-family: var(--mm-font-display);
    font-weight: 800;
    font-size: 24px;
    letter-spacing: -0.3px;
    line-height: 1;
}

.site-back {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-height: 44px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    color: var(--mm-accent-strong);
}

.site-back:hover { text-decoration: underline; }

.game-description {
    font-size: 14px;
    color: var(--mm-ink-muted);
}

.game-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.4px;
    color: var(--mm-ink-muted);
}

/* ── Grid ───────────────────────────────────────── */
.grid-wrapper {
    padding: 0 16px;
    display: grid;
    grid-template-columns: 80px repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.grid-header,
.grid-row {
    display: contents;
}

.header-cell {
    min-width: 0;
}

.column-header {
    min-height: 92px;
    padding-bottom: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    text-align: center;
    border-bottom: 3px solid var(--mm-accent);
}

.criterion-icon-wrap {
    flex: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--mm-accent-tint);
    color: var(--mm-accent-strong);
}

.criterion-icon {
    display: block;
}

.criterion-icon .card-fill {
    stroke: color-mix(in srgb, currentColor 35%, transparent);
    stroke-width: 1.2;
}

.criterion-icon .card-fill--yellow { fill: #f5c518; }
.criterion-icon .card-fill--red { fill: #d92d34; }

.column-header .criterion-label {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.row-header {
    height: 94px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
}

.row-header .criterion-label {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.criterion-badge {
    position: relative;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid var(--mm-ink);
    border-radius: 50%;
    background: var(--mm-surface);
    font-family: var(--mm-font-display);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.criterion-badge .criterion-image,
.column-header .criterion-image {
    object-fit: contain;
}

.criterion-badge .criterion-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--mm-surface);
}

.column-header .criterion-image {
    width: 24px;
    height: 24px;
}

/* ── Answer cells ───────────────────────────────── */
.answer-cell {
    height: 94px;
    min-width: 0;
    padding: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    border: 1.5px solid var(--mm-border);
    border-radius: var(--mm-radius-cell);
    background: var(--mm-surface);
    color: var(--mm-ink-muted);
    text-align: left;
}

.answer-cell:hover:not(.answered) {
    border-color: var(--mm-accent);
    color: var(--mm-accent-strong);
}

.cell-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.cell-placeholder {
    display: flex;
}

.cell-placeholder .icon-x {
    display: none;
}

.answer-cell.answered {
    cursor: default;
}

.answer-cell.correct {
    border-color: var(--mm-accent);
    background: var(--mm-accent);
    color: var(--mm-on-accent);
}

.answer-cell.correct .cell-content {
    align-items: flex-start;
    justify-content: flex-end;
    padding: 8px;
}

.answer-cell.incorrect {
    border: 2.5px solid var(--mm-error);
    color: var(--mm-error);
    animation: shake 0.4s;
}

.answer-cell.incorrect .icon-plus {
    display: none;
}

.answer-cell.incorrect .icon-x {
    display: block;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

.cell-player-initial {
    font-size: 12px;
    color: var(--mm-on-accent-muted);
}

.cell-player-name {
    max-width: 100%;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.cell-rarity {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--mm-on-accent-muted);
}

.is-finished .answer-cell:not(.answered) {
    cursor: default;
    opacity: 0.6;
}

/* ── Progress ───────────────────────────────────── */
.game-stats {
    margin: 18px 16px 0;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--mm-surface);
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius-card);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-item-end {
    align-items: flex-end;
    gap: 6px;
}

.stat-label {
    font-size: 13px;
    color: var(--mm-ink-muted);
}

.stat-figure {
    font-family: var(--mm-font-display);
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
}

.stat-total {
    font-size: 18px;
    color: var(--mm-ink-muted);
}

.guess-dots {
    display: flex;
    gap: 5px;
}

.guess-dot {
    width: 12px;
    height: 12px;
    border: 2px solid var(--mm-accent);
    border-radius: 50%;
    background: var(--mm-accent);
}

.guess-dot.is-spent {
    border-color: var(--mm-border-strong);
    background: none;
}

.game-actions {
    padding: 12px 16px 0;
    display: flex;
}

.game-actions .btn-secondary {
    flex: 1;
}

/* ── Buttons ────────────────────────────────────── */
.btn-primary,
.btn-secondary {
    width: 100%;
    min-height: 52px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--mm-radius-control);
    font-size: 16px;
    text-decoration: none;
}

.btn-primary {
    border: 0;
    background: var(--mm-accent);
    color: var(--mm-on-accent);
    font-weight: 700;
}

.btn-primary:hover,
.btn-primary:active {
    background: var(--mm-accent-strong);
}

.btn-secondary {
    border: 1.5px solid var(--mm-border-strong);
    background: var(--mm-surface);
    color: var(--mm-ink);
    font-weight: 600;
}

.btn-secondary:hover {
    border-color: var(--mm-ink-muted);
}

.btn-secondary[hidden] {
    display: none;
}

/* ── Bottom sheets ──────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: flex-end;
    justify-content: center;
    background: var(--mm-scrim);
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 560px;
    max-height: calc(100dvh - 48px);
    display: flex;
    flex-direction: column;
    background: var(--mm-ground);
    color: var(--mm-ink);
    border-radius: var(--mm-radius-sheet) var(--mm-radius-sheet) 0 0;
    animation: sheet-in 0.2s ease-out;
}

/* The search sheet is tall so the keyboard has room */
.modal:not(.game-complete-modal) .modal-content {
    height: calc(100dvh - 96px);
}

@keyframes sheet-in {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .modal-content,
    .answer-cell.incorrect {
        animation: none;
    }
}

.sheet-handle {
    align-self: center;
    flex-shrink: 0;
    width: 40px;
    height: 5px;
    margin-top: 8px;
    border-radius: 3px;
    background: var(--mm-border-strong);
}

.modal-header {
    flex-shrink: 0;
    padding: 10px 16px 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.modal-header h2 {
    padding-top: 4px;
    font-family: var(--mm-font-display);
    font-size: 26px;
    font-weight: 800;
    line-height: 1.05;
}

.modal-close {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--mm-border);
    border-radius: 50%;
    background: var(--mm-surface);
    color: var(--mm-ink);
}

.modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Player search ──────────────────────────────── */
.player-search {
    flex-shrink: 0;
    height: 54px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--mm-surface);
    border: 2px solid var(--mm-border-strong);
    border-radius: var(--mm-radius-control);
    color: var(--mm-ink-muted);
}

.player-search:focus-within {
    border-color: var(--mm-accent);
}

.player-search-input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--mm-ink);
    font-family: inherit;
    font-size: 18px;
}

.player-search-input::placeholder {
    color: var(--mm-ink-muted);
}

.player-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.player-list-empty,
.player-list-error {
    padding: 24px 0;
    text-align: center;
    font-size: 15px;
    color: var(--mm-ink-muted);
}

.player-list-error {
    color: var(--mm-error);
}

.player-results {
    overflow: hidden;
    background: var(--mm-surface);
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius-card);
}

.player-item {
    width: 100%;
    min-height: 64px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 0;
    border-bottom: 1px solid var(--mm-divider);
    background: none;
    color: var(--mm-ink);
    text-align: left;
}

.player-item:last-child {
    border-bottom: 0;
}

.player-item:hover:not(.is-used) {
    background: var(--mm-accent-tint);
}

.player-avatar {
    position: relative;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 50%;
    background: var(--mm-accent-tint);
    color: var(--mm-accent-strong);
    font-size: 14px;
    font-weight: 700;
}

.player-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.player-name {
    font-size: 17px;
    font-weight: 600;
}

.player-meta {
    font-size: 13px;
    color: var(--mm-ink-muted);
}

.player-item.is-used {
    cursor: default;
    color: var(--mm-ink-muted);
}

.player-item.is-used .player-avatar {
    background: var(--mm-divider);
    color: var(--mm-ink-muted);
}

.player-item.is-used .player-name {
    text-decoration: line-through;
}

.player-used {
    font-size: 13px;
    font-weight: 600;
}

/* ── Game complete ──────────────────────────────── */
.game-complete-modal .modal-content {
    overflow-y: auto;
}

.game-complete-modal .modal-header {
    justify-content: center;
    padding-top: 20px;
}

.game-complete-modal .modal-header h2 {
    padding: 0;
    font-family: var(--mm-font-body);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--mm-accent-strong);
}

.game-complete-modal .modal-body {
    flex: none;
    align-items: stretch;
    gap: 16px;
}

.complete-score {
    text-align: center;
    font-family: var(--mm-font-display);
    font-size: 84px;
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -1px;
}

.complete-score-total {
    font-size: 40px;
    font-weight: 700;
    color: var(--mm-ink-muted);
}

.complete-score-label {
    margin-top: -12px;
    text-align: center;
    font-size: 16px;
    color: var(--mm-ink-muted);
}

.complete-stats {
    display: grid;
    gap: 8px;
}

.complete-stat {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--mm-surface);
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius-control);
}

.complete-stat-label {
    font-size: 13px;
    color: var(--mm-ink-muted);
}

.complete-stat-value {
    font-family: var(--mm-font-display);
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.answers-note {
    text-align: center;
    font-size: 14px;
    color: var(--mm-ink-muted);
}

.answers-list {
    max-height: 40dvh;
    overflow-y: auto;
    background: var(--mm-surface);
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius-card);
}

.answers-list[hidden] {
    display: none;
}

.answers-cell {
    padding: 10px 14px;
    border-bottom: 1px solid var(--mm-divider);
}

.answers-cell:last-child {
    border-bottom: 0;
}

.answers-cell-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--mm-ink-muted);
}

.answers-cell-players {
    font-size: 15px;
    font-weight: 600;
}

/* ── Wider screens: centred dialog instead of a bottom sheet ── */
@media (min-width: 600px) {
    .modal {
        align-items: center;
    }

    .modal-content,
    .modal:not(.game-complete-modal) .modal-content {
        height: auto;
        max-height: 90dvh;
        border-radius: var(--mm-radius-sheet);
    }

    .modal:not(.game-complete-modal) .modal-content {
        height: min(640px, 90dvh);
    }
}

/* ── How to play ─────────────────────────────────── */
.howto-open {
    color: var(--mm-ink);
    cursor: pointer;
}

/* Short sheet: only the search sheet needs room for the keyboard */
.modal.howto-modal .modal-content {
    height: auto;
}

.howto-rules {
    margin: 0;
    padding-left: 20px;
    display: grid;
    gap: 8px;
    font-size: 16px;
    line-height: 1.45;
    color: var(--mm-ink);
}

.howto-modal .btn-primary {
    width: 100%;
}

/* ── Share ───────────────────────────────────────── */
.share-status {
    min-height: 1.2em;
    margin: 0;
    text-align: center;
    font-size: 14px;
    color: var(--mm-ink-muted);
}
