@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
    --bg: #e9f1ff;
    --panel: #ffffff;
    --border: #cdd8ff;
    --accent: #3a6ff8;
    --accent-soft: #e2e9ff;
    --text: #0f1b3d;
    --subtle: #5d6b8a;
    --shadow: 0 24px 60px rgba(25, 56, 130, 0.12);
    --glow: 0 0 0 1px rgba(58, 111, 248, 0.16), 0 12px 30px rgba(58, 111, 248, 0.18);
}

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

body {
    min-height: 100vh;
    font-family: 'Space Grotesk', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at 20% 20%, rgba(58, 111, 248, 0.08), transparent 35%), radial-gradient(circle at 80% 10%, rgba(92, 207, 252, 0.15), transparent 30%), radial-gradient(circle at 50% 80%, rgba(78, 196, 166, 0.12), transparent 28%), var(--bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 4vw, 32px);
}

.main {
    width: min(960px, 100%);
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(242, 247, 255, 0.95));
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: clamp(20px, 5vw, 36px);
    backdrop-filter: blur(6px);
}

.header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

h1 {
    font-size: clamp(36px, 3.6vw, 52px);
    letter-spacing: 0.04em;
    color: var(--text);
    text-transform: uppercase;
}

.content {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 45px;
    align-items: center;
}

.header2 {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid rgba(58, 111, 248, 0.2);
    border-radius: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    padding: 10px 16px;
    margin-top: 10px;
}

h2 {
    font-size: clamp(24px, 3vw, 28px);
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.board {
    width: min(560px, 90vw);
    height: min(560px, 90vw);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 1fr;
    gap: 10px;
    margin: 6px auto 0;
    padding: 18px;
    background: linear-gradient(145deg, #f5f7ff, #e9f0ff);
    border-radius: 22px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: relative;
}

.board::after {
    content: '';
    position: absolute;
    inset: -12px;
    border-radius: 26px;
    background: linear-gradient(135deg, rgba(58, 111, 248, 0.12), transparent 60%);
    z-index: -1;
}

.cell {
    background: var(--panel);
    border-radius: 16px;
    border: 1px solid rgba(12, 26, 75, 0.06);
    box-shadow: 0 10px 24px rgba(12, 26, 75, 0.08);
    cursor: pointer;
    font-size: 96px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.cell:hover {
    background-color: #f3f6ff;
    border-color: rgba(58, 111, 248, 0.35);
    box-shadow: var(--glow);
    transform: translateY(-4px) scale(1.02);
}

.cell:active {
    transform: translateY(0) scale(1);
    box-shadow: 0 6px 14px rgba(12, 26, 75, 0.14);
}

.restart {
    place-self: center;
    height: 60px;
    width: min(220px, 80vw);
    border-radius: 16px;
    background: linear-gradient(120deg, var(--accent), #5ccffc);
    border: none;
    color: #fff;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(58, 111, 248, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.restart:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 36px rgba(58, 111, 248, 0.45);
    filter: brightness(1.02);
}

.restart:active {
    transform: translateY(0);
    box-shadow: 0 10px 18px rgba(58, 111, 248, 0.35);
}

.dialog {
    border: none;
    border-radius: 20px;
    padding: 0;
    max-width: min(520px, 90vw);
    width: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(242, 247, 255, 0.98));
    box-shadow: 0 30px 80px rgba(16, 46, 112, 0.26);
    overflow: hidden;
    inset: 50% auto auto 50%;
    margin: auto;
    transform: translate(-50%,-50%);
    position: fixed;
}

.dialog::backdrop {
    background: rgba(6, 16, 40, 0.25);
    backdrop-filter: blur(6px);
}

.dialog form {
    display: grid;
    gap: 30px;
    padding: 26px 28px 24px;
}

.dialog h1 {
    font-size: 22px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text);
}

.dialog label {
    font-weight: 600;
    color: var(--subtle);
    letter-spacing: 0.01em;
    margin-bottom: -18px;
}

.dialog input[type="text"] {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #f8faff;
    font-size: 16px;
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.dialog input[type="text"]:focus {
    outline: none;
    border-color: rgba(58, 111, 248, 0.55);
    box-shadow: var(--glow);
    background: #ffffff;
}

.dialog .submit {
    margin-top: 8px;
    height: 52px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(120deg, var(--accent), #5ccffc);
    color: #fff;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(58, 111, 248, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.dialog .submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 34px rgba(58, 111, 248, 0.35);
    filter: brightness(1.02);
}

.dialog .submit:active {
    transform: translateY(0);
    box-shadow: 0 10px 18px rgba(58, 111, 248, 0.3);
}

@media (max-width: 600px) {
    .main {
        padding: 18px;
    }

    .board {
        gap: 8px;
        padding: 12px;
        border-radius: 18px;
    }

    .cell {
        border-radius: 12px;
        font-size: 72px;
    }
}
