
:root {
    --credit-h: 40px;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100dvh;
    overflow: hidden;
}

body {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100dvh;
}

#credit {
    flex-shrink: 0;
    height: var(--credit-h);
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 13px;
    box-sizing: border-box;
}

.stage-select-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 16px;
    font-family: "M PLUS Rounded 1c", "Kosugi Maru", "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
    background:
        radial-gradient(circle at 15% 15%, rgba(255, 255, 255, 0.75), transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(255, 255, 255, 0.55), transparent 40%),
        linear-gradient(145deg, rgba(255, 250, 253, 0.96), rgba(255, 243, 249, 0.94));
    z-index: 2000;
    overflow-y: auto;
}

.stage-select-overlay.is-hidden {
    display: none;
}

.stage-select-overlay__inner {
    width: min(100%, 500px);
    text-align: center;
    padding: 16px 0;
}

.stage-select-overlay__title {
    margin: 0 0 6px 0;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #c43f7a;
}

.stage-select-overlay__subtitle {
    margin: 0 0 20px 0;
    font-size: 16px;
    color: #666;
}

.stage-card-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.stage-card {
    border: none;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    background: #fff;
    box-shadow: 0 4px 16px rgba(196, 63, 122, 0.2);
    padding: 0;
    text-align: left;
    transition: transform 0.12s, box-shadow 0.12s;
    touch-action: manipulation;
}

.stage-card:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(196, 63, 122, 0.3);
}

.stage-card:not(:disabled):active {
    transform: scale(0.97);
}

.stage-card.is-loading {
    opacity: 0.6;
    cursor: progress;
}

.stage-card.is-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.stage-card__img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}

.stage-card__info {
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    height: 56px;
    box-sizing: border-box;
    overflow: hidden;
    background: linear-gradient(160deg, #ffacd0, #ff8fc1);
}

.stage-card__name {
    display: block;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.25;
    color: #fff;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stage-card__difficulty {
    display: block;
    font-size: 12px;
    line-height: 1.25;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stage-select-overlay__message {
    margin: 16px 0 0;
    min-height: 1.6em;
    font-size: 14px;
    color: #c43f7a;
    line-height: 1.6;
}

.back-to-stages-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 100;
    background: linear-gradient(135deg, #ffacd0, #ff8fc1);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 700;
    font-family: "M PLUS Rounded 1c", "Kosugi Maru", "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(196, 63, 122, 0.35);
    touch-action: manipulation;
    letter-spacing: 0.01em;
}

.button {
    display: inline-block;
    margin: 2px 16px;
    border: none;
    border-radius: 20px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 700;
    font-family: "M PLUS Rounded 1c", "Kosugi Maru", "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
    box-shadow: 0 3px 10px rgba(63, 63, 63, 0.35);
    cursor: pointer;
    touch-action: manipulation;
}

.modal-close-button {
    background: linear-gradient(135deg, #ffacd0, #ff8fc1);
    margin-top: 16px;
    color: #fff;
    box-shadow: 0 3px 10px rgba(196, 63, 122, 0.35);
}


.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2000;
    transition: opacity 0.2s;
}

.modal-overlay.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-wrapper {
    width: 360px;
    max-height: 80dvh;
    overflow-y: auto;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3000;
    padding: 20px;
}

.modal {
    background: #fff;
    box-shadow: 0 4px 16px rgba(196, 63, 122, 0.2);
    padding: 20px;
    text-align: center;
    z-index: 3000;
    border-radius: 16px;
}

.modal h2 {
    margin: 0 0 18px;
    text-align: center;
    font-size: 21px;
}

.section-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
}

.tag-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tag {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f7f8fb;
    border-radius: 12px;
    padding: 12px 14px;
}

.tag span:first-child {
    font-weight: 600;
}

.tag strong {
    color: #3478f6;
}

.notice {
    margin-top: 14px;
    background: #f7f8fb;
    border-radius: 12px;
    padding: 14px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
}

.reward {
    background: #fff8e7;
}

.login-box {
    background: #f3faf4;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 18px;
    text-align: center;
}

.login-box .when-logged-in {
    display: none;
}

.login-box.is-logged-in .when-logged-in {
    display: block;
}

.login-box .when-logged-out {
    display: block;
}

.login-box.is-logged-in .when-logged-out {
    display: none;
}

.login-status {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 10px;
}

.login-desc {
    font-size: 12px;
    color: #666;
    margin-bottom: 12px;
}

.line-login-button {
    width: 100%;
    border: none;
    border-radius: 10px;
    background: #06c755;
    color: white;
    padding: 12px;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    pointer-events: manipulation;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ddd;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
}

.user-name {
    font-weight: bold;
    font-size: 15px;
}

.user-id {
    font-size: 12px;
    color: #666;
}

.logout-button {
    margin-top: 10px;
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 10px;
    background: white;
    padding: 10px;
    font-size: 13px;
    cursor: pointer;
    pointer-events: manipulation;
}



.back-to-stages-btn:hover {
    background: linear-gradient(135deg, #ff8fc1, #ff70ae);
}

.back-to-stages-btn:active {
    transform: scale(0.96);
}

.back-to-stages-btn[hidden] {
    display: none;
}

#points-button {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 100;
    background: linear-gradient(135deg, #ffacd0, #ff8fc1);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 700;
    font-family: "M PLUS Rounded 1c", "Kosugi Maru", "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(196, 63, 122, 0.35);
    touch-action: manipulation;
    letter-spacing: 0.01em;
}

canvas {
    border: 1px solid black;
    display: block;
    box-sizing: border-box;
    touch-action: none;
    aspect-ratio: 9 / 16;
    width: min(100vw, 900px, calc((100dvh - var(--credit-h)) * 9 / 16));
    height: auto;
}
