:root {
    --game-ink: #19233c;
    --game-muted: #68708a;
    --game-blue: #4f67e8;
    --game-line: #e2e6f0;
}

* { box-sizing: border-box; }

body {
    color: var(--game-ink) !important;
    background: radial-gradient(circle at 50% 0, #e9edff 0, transparent 28rem), #f7f8fc !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif !important;
    line-height: 1.6;
}

.game-header {
    width: 100%;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--game-line);
    background: rgba(255,255,255,.86);
    backdrop-filter: blur(12px);
}

.game-header-inner {
    width: min(920px, calc(100% - 28px));
    min-height: 60px;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.game-brand, .back-link {
    color: var(--game-ink);
    font-size: .9rem;
    font-weight: 700;
    text-decoration: none;
}

.game-brand { display: inline-flex; align-items: center; gap: 8px; }
.game-brand::before {
    content: "脳";
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 10px;
    color: #fff;
    background: linear-gradient(135deg, #6578f2, #4c55c9);
}
.back-link { color: var(--game-muted); font-weight: 500; }
.back-link:hover { color: var(--game-blue); }

.container {
    width: min(920px, calc(100% - 28px)) !important;
    margin: 0 auto !important;
    padding: clamp(18px, 4vw, 34px) !important;
    border: 1px solid var(--game-line);
    border-radius: 24px;
    background: rgba(255,255,255,.9);
    box-shadow: 0 16px 38px rgba(35,47,92,.09);
}

h1 {
    margin: 0 0 20px !important;
    font-size: clamp(1.65rem, 5vw, 2.35rem) !important;
    letter-spacing: -.03em;
}
h1::before, h1::after { content: none !important; }

button {
    min-height: 48px;
    border: 0;
    border-radius: 12px;
    color: #fff;
    background: var(--game-blue);
    box-shadow: 0 7px 15px rgba(79,103,232,.22);
    font-family: inherit;
    font-weight: 700;
    transition: transform .15s, background .15s;
}
button:hover { background: #3e54d1; transform: translateY(-1px); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

input {
    border: 2px solid var(--game-line) !important;
    border-radius: 12px;
    background: #fff;
    font-family: inherit;
    outline: none;
}
input:focus { border-color: var(--game-blue) !important; box-shadow: 0 0 0 4px rgba(79,103,232,.12); }

#board { margin-inline: auto !important; border: 1px solid var(--game-line); }
#timer { font-variant-numeric: tabular-nums; }

footer {
    margin: 28px 0 0 !important;
    color: var(--game-muted);
    font-size: .84rem;
}
footer a { color: inherit; }

body > footer { margin: 28px auto !important; }

table { max-width: 100%; }

.math-grid-wrap {
    width: 100%;
    overflow-x: auto;
    padding: 4px 0 12px;
    -webkit-overflow-scrolling: touch;
}

.math-grid-wrap table { min-width: 605px; }

.container > p {
    max-width: 760px;
    margin-inline: auto;
    color: var(--game-muted);
}

.container > h2 {
    margin-top: 42px;
    font-size: clamp(1.3rem, 4vw, 1.8rem);
}

@media (max-width: 600px) {
    .game-header-inner { min-height: 54px; }
    .game-brand { font-size: .82rem; }
    .container { padding: 18px 12px !important; border-radius: 18px; }
    #board { max-height: 62vh; }
    #instruction { font-size: 1.45rem !important; }
    #question { font-size: clamp(1.55rem, 8vw, 2.4rem) !important; }
}
