/* ============================================
   ფიფქი — Base CSS
   ბიზნეს-კლასი: თეთრი, სადა, წვეტიანი, სოლიდური
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+Georgian:wght@100..900&display=swap');

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

/* --- CSS Variables --- */
:root {
    /* ფერები */
    --brand: #0055ff;
    --brand-light: #e8f0ff;
    --white: #ffffff;
    --off-white: #fafafa;
    --gray-50: #f5f5f5;
    --gray-100: #ebebeb;
    --gray-200: #d6d6d6;
    --gray-300: #b8b8b8;
    --gray-400: #878787;
    --gray-500: #6b6b6b;
    --gray-600: #4a4a4a;
    --gray-700: #333333;
    --gray-800: #1a1a1a;
    --black: #000000;

    /* თამაშის ფერები */
    --correct: #6aaa64;
    --present: #c9b458;
    --absent: #787c7e;
    --correct-dark: #538d4e;
    --present-dark: #b59f3b;

    /* Connections ფერები */
    --conn-yellow: #f9df6d;
    --conn-green: #a0c35a;
    --conn-blue: #b0c4ef;
    --conn-purple: #ba81c5;

    /* ტიპოგრაფია */
    --font-body: 'Noto Serif Georgian', 'Georgia', serif;
    --font-mono: 'Courier New', monospace;
    --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* ზომები */
    --header-height: 52px;
    --max-width: 500px;
    --border: 1px solid var(--gray-200);
    --border-dark: 2px solid var(--gray-800);
}

/* --- Base --- */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--gray-800);
    background: var(--white);
    line-height: 1.5;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--gray-800);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button {
    cursor: pointer;
    font-family: var(--font-body);
    border: none;
    background: none;
    font-size: inherit;
}

input, select, textarea {
    font-family: var(--font-body);
    font-size: 16px;
    outline: none;
}

/* --- Header --- */
.header {
    height: var(--header-height);
    border-bottom: var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--white);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header__logo {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 1px;
    color: var(--gray-800);
}

.header__logo img {
    height: 28px;
    vertical-align: middle;
}

.header__nav {
    display: flex;
    gap: 16px;
    align-items: center;
}

.header__link {
    font-size: 14px;
    color: var(--gray-500);
    font-family: var(--font-ui);
    transition: color 0.15s;
}

.header__link:hover {
    color: var(--gray-800);
    text-decoration: none;
}

.header__link--active {
    color: var(--gray-800);
    font-weight: 600;
}

/* --- Page Container --- */
.page {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px;
}

.page--center {
    justify-content: center;
}

/* --- Card --- */
.card {
    background: var(--white);
    border: var(--border);
    padding: 32px;
    width: 100%;
    max-width: var(--max-width);
}

.card__title {
    font-size: 24px;
    font-weight: normal;
    margin-bottom: 24px;
    color: var(--gray-800);
}

/* --- Form --- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 4px;
    font-family: var(--font-ui);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: var(--border);
    background: var(--white);
    color: var(--gray-800);
    transition: border-color 0.15s;
}

.form-input:focus {
    border-color: var(--gray-800);
}

.form-input::placeholder {
    color: var(--gray-300);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    font-size: 15px;
    font-family: var(--font-ui);
    font-weight: 500;
    transition: all 0.15s;
    letter-spacing: 0.3px;
}

.btn--primary {
    background: var(--gray-800);
    color: var(--white);
    border: 2px solid var(--gray-800);
}

.btn--primary:hover {
    background: var(--black);
}

.btn--secondary {
    background: var(--white);
    color: var(--gray-800);
    border: var(--border);
}

.btn--secondary:hover {
    border-color: var(--gray-800);
}

.btn--full {
    width: 100%;
}

.btn--small {
    padding: 6px 14px;
    font-size: 13px;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --- Alert / Messages --- */
.alert {
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    font-family: var(--font-ui);
    border-left: 3px solid;
}

.alert--error {
    background: #fef2f2;
    border-color: #dc2626;
    color: #991b1b;
}

.alert--success {
    background: #f0fdf4;
    border-color: #16a34a;
    color: #166534;
}

.alert--info {
    background: var(--gray-50);
    border-color: var(--gray-400);
    color: var(--gray-700);
}

/* --- Divider --- */
.divider {
    border: none;
    border-top: var(--border);
    margin: 24px 0;
}

/* --- Stats Grid --- */
.stats-row {
    display: flex;
    gap: 2px;
    margin-bottom: 16px;
}

.stat-box {
    flex: 1;
    text-align: center;
    padding: 12px 4px;
}

.stat-box__value {
    font-size: 28px;
    font-weight: bold;
    color: var(--gray-800);
    line-height: 1;
}

.stat-box__label {
    font-size: 11px;
    color: var(--gray-500);
    font-family: var(--font-ui);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* --- Distribution Bar --- */
.dist-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-family: var(--font-ui);
    font-size: 14px;
}

.dist-row__label {
    width: 16px;
    text-align: right;
    color: var(--gray-600);
    font-weight: bold;
}

.dist-row__bar {
    height: 24px;
    background: var(--gray-300);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    color: var(--white);
    font-weight: bold;
    font-size: 13px;
    min-width: 28px;
}

.dist-row__bar--highlight {
    background: var(--correct);
}

/* --- Modal / Overlay --- */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.overlay--visible {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--white);
    border: var(--border-dark);
    padding: 32px;
    max-width: 420px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal__title {
    font-size: 20px;
    margin-bottom: 16px;
}

.modal__close {
    float: right;
    font-size: 24px;
    color: var(--gray-400);
    line-height: 1;
    padding: 4px;
}

.modal__close:hover {
    color: var(--gray-800);
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--gray-800);
    color: var(--white);
    padding: 10px 20px;
    font-size: 14px;
    font-family: var(--font-ui);
    font-weight: 500;
    animation: toast-in 0.2s ease-out;
}

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

/* --- Utilities --- */
.text-center { text-align: center; }
.text-small { font-size: 13px; }
.text-muted { color: var(--gray-500); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* --- No Puzzle Card --- */
.no-puzzle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    padding: 40px 16px;
    text-align: center;
}

.no-puzzle__title {
    font-size: 18px;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.no-puzzle__label {
    font-size: 12px;
    font-family: var(--font-ui);
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gray-400);
    margin-bottom: 8px;
}

.no-puzzle__countdown {
    font-size: 28px;
    font-family: var(--font-ui);
    font-weight: bold;
    letter-spacing: 3px;
    color: var(--gray-800);
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .card {
        padding: 24px 16px;
        border-left: none;
        border-right: none;
    }

    .header {
        padding: 0 12px;
    }
}
