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

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: max(18px, calc(env(safe-area-inset-top) + 12px));
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f6f6f6;
    color: #222;
}

.page {
    min-height: 100vh;
    padding: 20px;
}

.card {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    background: #ffffff;
    border: 1px solid #d8d8d8;
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

.card.card-wide {
    max-width: 860px;
}

.card.card-subtle {
    margin-top: 10px;
    padding: 24px 22px;
    box-shadow: none;
    background: #fbfbfb;
}

.card.card-plan {
    max-width: 720px;
}

h1 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 28px;
    line-height: 1.2;
}

.sub,
.meta,
.hint {
    color: #666;
    line-height: 1.45;
}

.sub {
    margin-bottom: 24px;
}

.meta {
    margin-bottom: 10px;
}

.hint {
    margin-top: 14px;
    font-size: 14px;
}

label {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
}

input[type="text"],
input[type="password"],
select,
button {
    font: inherit;
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    border: 1px solid #cfcfcf;
    background: #fff;
    color: #222;
    font-size: 16px;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    outline: none;
    border-color: #9a9a9a;
}

button {
    background: #2d2d2d;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 14px 20px;
    font-size: 16px;
    cursor: pointer;
}

button.secondary {
    background: #ffffff;
    color: #222;
    border: 1px solid #c8c8c8;
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.actions > button {
    flex: 1 1 180px;
}

.status-box,
.closed-box {
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.status-box {
    background: #eef4ff;
}

.status-open {
    background: #e6f6ea;
    color: #1d5c30;
}

.status-closed {
    background: #fdeaea;
    color: #8a1f1f;
}

.closed-box {
    background: #fdeaea;
    color: #8a1f1f;
    font-weight: bold;
}

.error,
.success {
    margin-top: 16px;
    font-weight: bold;
}

.error {
    color: #8a1f1f;
}

.success {
    color: #1d5c30;
}

.section-hidden {
    display: none;
}

.turnstile-wrap {
    margin-bottom: 18px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.turnstile-wrap > div {
    min-height: 65px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 24px;
}

.day-card {
    border: 1px solid #d5d5d5;
    border-radius: 12px;
    padding: 12px 10px;
    background: #fff;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
}

.day-card:hover {
    background: #f8f8f8;
}

.day-card.selected {
    background: #f3d6d6;
    border-color: #c97d7d;
}

.day-card.disabled {
    cursor: default;
    opacity: 0.72;
}

.day-label {
    font-weight: bold;
    text-align: center;
    font-size: 16px;
    line-height: 1.3;
}

.helper-box {
    margin-top: 10px;
    margin-bottom: 10px;
    color: #555;
    font-size: 14px;
}

#pinInput {
    margin-bottom: 10px;
}

#nameSection label {
    margin-bottom: 10px;
}

#nameSelect {
    margin-bottom: 10px;
}

.continue-button {
    margin-top: 8px;
}

#nameSection .hint {
    margin-top: 18px;
    margin-bottom: 26px;
}

.plan-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 2px;
}

.plan-card-title {
    font-size: 18px;
    font-weight: 700;
    color: #222;
    line-height: 1.2;
    margin-bottom: 14px;
}

.plan-card-sub {
    margin-top: 0;
    margin-bottom: 18px;
    color: #666;
    line-height: 1.45;
    font-size: 14px;
}

.plan-card-actions {
    margin-top: 18px;
}

.plan-card-actions > button,
.plan-card-actions > a {
    width: 100%;
}

@media (min-width: 700px) {
    .grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    #nameSelect {
        display: block;
        width: 100%;
        height: 50px;
        min-height: 50px;
        padding: 0 14px;
        font-size: 17px;
        line-height: 1.2;
    }

    .plan-card-actions > button,
    .plan-card-actions > a {
        width: auto;
        min-width: 240px;
    }
}

@media (min-width: 1000px) {
    .grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .page {
        padding: 12px;
        padding-top: calc(12px + env(safe-area-inset-top));
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    .card,
    .card.card-wide {
        max-width: none;
        border-radius: 14px;
        border: 1px solid #d8d8d8;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
        padding: 18px 14px 20px;
    }

    .card.card-subtle {
        padding: 16px 14px 18px;
    }

    h1 {
        font-size: 24px;
    }

    .sub,
    .meta,
    .hint,
    .helper-box,
    .plan-card-sub {
        font-size: 14px;
    }

    .plan-card-title {
        font-size: 17px;
    }

    .actions {
        flex-direction: column;
    }

    .actions > button {
        width: 100%;
        flex: none;
    }

    .grid {
        gap: 8px;
    }

    .day-card {
        min-height: 52px;
        padding: 10px 8px;
        border-radius: 10px;
    }

    .day-label {
        font-size: 15px;
    }

    #pinInput,
    #nameSelect {
        scroll-margin-top: calc(12px + env(safe-area-inset-top));
    }
}

.helper-emphasis {
    color: #ff2b2b;
    font-weight: 700;
    text-decoration: underline;
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    text-decoration: none;
    background: #2d2d2d;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 14px 20px;
    font-size: 16px;
    cursor: pointer;
}

.button-link.secondary {
    background: #ffffff;
    color: #222;
    border: 1px solid #c8c8c8;
}

.button-link.section-hidden {
    display: none;
}