html, body {
    height: 100%;
}
body {
    font-family: 'Segoe UI', 'Meiryo', sans-serif;
    background: radial-gradient(circle at 60% 30%, #e3f0ff 60%, #f9f9f9 100%);
    color: #1a2740;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
}

header {
    background: linear-gradient(90deg, #3259a8 80%, #5ecfff 100%);
    color: #fff;
    padding: 1.3rem 0.5rem 1rem 0.5rem;
    text-align: center;
    box-shadow: 0 2px 12px #0002;
    position: relative;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
}
header h1 {
    margin-bottom: 0.5em;
    font-size: 2em;
    letter-spacing: 0.04em;
    text-shadow: 1px 2px 0 #0001;
    text-transform: uppercase;
    line-height: 1.2;
}
header p {
    font-size: 1em;
    margin-bottom: 0.5em;
}
.official-link {
    display: inline-block;
    margin: 0.7em 0 0.1em 0;
    color: #ffe900;
    background: #233b6c;
    border-radius: 6px;
    padding: 0.3em 1.1em;
    font-weight: bold;
    letter-spacing: 0.03em;
    text-decoration: none;
    transition: background .2s, color .2s;
    font-size: 1em;
    text-transform: uppercase;
}
.official-link:hover, .official-link:focus {
    background: #ffe900;
    color: #3259a8;
    text-decoration: underline;
    outline: none;
}
nav {
    margin: 0.5em 0 0.8em 0;
}
.nav-links {
    display: flex;
    justify-content: center;
    gap: 1.2em;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 1em;
}
.nav-links a {
    color: #ffe900;
    text-decoration: none;
    font-weight: bold;
    padding: 0.18em 0.7em;
    border-radius: 4px;
    transition: background .15s, color .15s;
    text-transform: uppercase;
}
.nav-links a:hover, .nav-links a:focus {
    background: #ffe900;
    color: #3259a8;
    outline: none;
}
.save-load {
    margin-top: 0.3rem;
    margin-bottom: 0.5rem;
}
.save-load button {
    background: #fff;
    border: 1.5px solid #3259a8;
    color: #3259a8;
    padding: 0.3em 1.1em;
    margin: 0 0.15em;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: background .2s, color .2s, box-shadow .1s, transform .07s;
    font-size: 1em;
    touch-action: manipulation;
    box-shadow: 0 1px 3px #0001;
    user-select: none;
}
.save-load button:active {
    background: #b8d6ff;
    box-shadow: 0 1px 2px #0002 inset;
    transform: scale(0.97);
}
.save-load button:hover, .save-load button:focus {
    background: #d7e4ff;
    color: #233b6c;
    outline: none;
}
#saveMsg {
    margin-left: 0.6em;
    color: #ffe900;
    font-weight: bold;
    font-size: 1em;
    transition: opacity .7s;
}

main {
    max-width: 480px;
    margin: 2.2rem auto;
    padding: 0 0.6rem;
}
.card {
    background: #fff;
    border-radius: 18px;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 28px #3259a81a, 0 1.5px 6px #fff7;
    padding: 1.2rem 0.7rem 1rem 0.7rem;
    outline: none;
    transition: box-shadow .15s, transform .08s;
    user-select: none;
}
.card:focus {
    box-shadow: 0 0 0 2px #5ecfff80, 0 8px 28px #3259a81a;
}

#status ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
#status li {
    margin-bottom: 0.5em;
    font-size: 1.15em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#status strong {
    min-width: 5em;
    display: inline-block;
}

#actions .actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-gap: 0.5em;
    margin-top: 0.3em;
    justify-items: center;
}
#actions button {
    background: #f5f9ff;
    border: 1.5px solid #3259a8;
    color: #234;
    border-radius: 14px;
    font-size: 1.03em;
    font-weight: bold;
    padding: 0.95em 0.15em 0.6em 0.15em;
    width: 100%;
    min-width: 80px;
    min-height: 86px;
    box-shadow: 0 2px 8px #3259a820;
    cursor: pointer;
    transition: background .2s, box-shadow .2s, border .2s, transform .07s;
    display: flex;
    flex-direction: column;
    align-items: center;
    outline: none;
    margin-bottom: 0.1em;
    touch-action: manipulation;
    user-select: none;
    will-change: transform, box-shadow;
}
#actions button:active {
    background: #b8d6ff;
    box-shadow: 0 0 0 2px #5ecfff;
    transform: scale(0.97);
}
#actions button.pressed {
    background: #b8d6ff;
    box-shadow: 0 0 0 2px #5ecfff;
    transform: scale(0.97);
}
#actions button span {
    font-size: 1.34em;
    margin-bottom: 0.12em;
    line-height: 1.1;
}
#actions button small {
    font-weight: normal;
    color: #3259a8;
    font-size: 0.93em;
    margin-top: 0.13em;
}

#log h2 {
    margin-top: 0;
}
#logList {
    max-height: 220px;
    overflow-y: auto;
    padding-left: 1.2em;
    font-size: 1em;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
#logList li {
    margin-bottom: 0.38em;
    border-bottom: 1px solid #eef3ff;
    padding-bottom: 0.16em;
    word-break: break-all;
}

footer {
    text-align: center;
    color: #789;
    font-size: 1em;
    margin-bottom: 1.3rem;
    margin-top: 2rem;
}
footer .official-link {
    color: #3259a8;
    background: #ffe900;
    margin-left: 0.5em;
    margin-top: 0;
    padding: 0.18em 0.8em;
    font-size: 1em;
    text-transform: uppercase;
}
footer .official-link:hover, footer .official-link:focus {
    background: #3259a8;
    color: #ffe900;
    outline: none;
}

@media (max-width: 700px) {
    main {
        max-width: 100vw;
        margin: 1.1rem 0 0.5rem 0;
        padding: 0 0.1em;
    }
    .card {
        border-radius: 12px;
        padding: 0.8rem 0.22em 0.7rem 0.22em;
        margin-bottom: 1.1rem;
    }
    header {
        border-bottom-left-radius: 12px;
        border-bottom-right-radius: 12px;
        padding: 1.15rem 0.2rem 0.8rem 0.2rem;
    }
    #actions .actions-grid {
        grid-template-columns: 1fr 1fr;
        grid-gap: 0.5em;
    }
    #actions button {
        min-width: 74px;
        min-height: 74px;
        font-size: 0.97em;
        padding: 0.7em 0.1em 0.5em 0.1em;
    }
}

@media (max-width: 420px) {
    header h1 {
        font-size: 1.23em;
    }
    #status li {
        font-size: 1em;
    }
    .official-link, footer .official-link {
        font-size: 0.93em;
        padding: 0.22em 0.6em;
    }
    #actions .actions-grid {
        grid-template-columns: 1fr;
        grid-gap: 0.4em;
    }
    .card {
        padding: 0.5rem 0.1em 0.5rem 0.1em;
    }
}