:root {
    color-scheme: light;
    --blue: #1769aa;
    --blue-dark: #104c7d;
    --blue-pale: #eaf4fc;
    --ink: #203246;
    --muted: #64758a;
    --line: #d7e1eb;
    --surface: #fff;
    --background: #f3f7fb;
    --green: #23845b;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--ink);
    font-family: "Yu Gothic UI", "Meiryo", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.page {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 28px 20px 48px;
}

.header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

h1 {
    margin: 0;
    color: var(--blue-dark);
    font-size: clamp(1.45rem, 3vw, 2rem);
}

.intro {
    margin: 7px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.demo-note {
    margin: 0 0 20px;
    padding: 12px 15px;
    border: 1px solid #f0d99c;
    border-radius: 10px;
    background: #fff8e7;
    color: #70551b;
    line-height: 1.55;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 20px;
    align-items: start;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 5px 18px rgb(23 61 95 / 6%);
}

.board-panel {
    padding: 20px;
}

.team-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 18px;
}

.team-tab {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: var(--ink);
    font-weight: 700;
}

.team-tab[aria-pressed="true"] {
    border-color: var(--blue);
    background: var(--blue);
    color: #fff;
}

.board-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.board-heading h2 {
    margin: 0;
    font-size: 1.1rem;
}

.board-heading span {
    color: var(--muted);
    font-size: .9rem;
}

.bingo-board {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.square {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 112px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    padding: 10px;
    border: 1px solid #c8d8e7;
    border-radius: 11px;
    background: #fff;
    color: var(--ink);
    text-align: left;
    transition: border-color .15s, transform .15s, background .15s;
}

.square:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: var(--blue);
    background: #f5faff;
}

.square.completed {
    border-color: #9acfb5;
    background: #effaf4;
}

.square.free {
    align-items: center;
    justify-content: center;
    border-color: #9bb9d4;
    background: var(--blue-pale);
    color: var(--blue-dark);
    text-align: center;
}

.square:disabled {
    cursor: default;
}

.square-number {
    color: var(--blue);
    font-family: "Segoe UI", sans-serif;
    font-size: .82rem;
    font-weight: 700;
}

.square.completed .square-number {
    color: var(--green);
}

.square-formats {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    min-height: 18px;
}

.square-format {
    display: inline-flex;
    align-items: center;
    padding: 2px 5px;
    border: 1px solid #c9dced;
    border-radius: 99px;
    background: var(--blue-pale);
    color: var(--blue-dark);
    font-size: .68rem;
    font-weight: 700;
    line-height: 1.2;
}

.square-title {
    display: -webkit-box;
    overflow: hidden;
    width: 100%;
    font-size: .86rem;
    font-weight: 600;
    line-height: 1.4;
    -webkit-box-orient: vertical;
    line-clamp: 3;
    -webkit-line-clamp: 3;
}

.square-status {
    color: var(--green);
    font-size: .75rem;
    font-weight: 700;
}

.summary {
    padding: 20px;
}

.summary h2 {
    margin: 0 0 18px;
    font-size: 1.1rem;
}

.score-label {
    margin: 0;
    color: var(--muted);
    font-size: .88rem;
}

.score {
    margin: 4px 0 18px;
    color: var(--blue-dark);
    font-family: "Segoe UI", sans-serif;
    font-size: 2rem;
    font-weight: 700;
}

.progress-track {
    height: 9px;
    overflow: hidden;
    border-radius: 99px;
    background: #e8eef4;
}

.progress-value {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--blue);
    transition: width .2s;
}

.progress-copy {
    margin: 8px 0 22px;
    color: var(--muted);
    font-family: "Segoe UI", sans-serif;
    font-size: .9rem;
}

.bonus-note {
    margin: 0;
    padding-top: 15px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .83rem;
    line-height: 1.6;
}

.reset-button {
    width: 100%;
    margin-top: 18px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-weight: 600;
}

.reset-button:hover {
    background: #f5f8fb;
}

.modal-backdrop {
    position: fixed;
    z-index: 5;
    inset: 0;
    display: grid;
    overflow-y: auto;
    padding: 20px;
    place-items: center;
    background: rgb(16 34 52 / 55%);
}

.modal-backdrop[hidden] {
    display: none;
}

.dialog {
    width: min(520px, 100%);
    padding: 24px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 18px 60px rgb(0 0 0 / 22%);
}

.dialog-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.dialog h2 {
    margin: 0;
    font-size: 1.25rem;
    line-height: 1.5;
}

.close-button {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fff;
    color: var(--ink);
    font-size: 1.2rem;
}

.mission-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0;
}

.badge {
    padding: 5px 9px;
    border-radius: 99px;
    background: var(--blue-pale);
    color: var(--blue-dark);
    font-size: .8rem;
    font-weight: 700;
}

.mission-description {
    color: var(--muted);
    line-height: 1.65;
}

.answer-label {
    display: block;
    margin: 18px 0 7px;
    font-weight: 700;
}

.answer-field {
    width: 100%;
    min-height: 96px;
    padding: 10px 12px;
    border: 1px solid #bccbd8;
    border-radius: 9px;
    resize: vertical;
}

.photo-field {
    display: block;
    width: 100%;
    padding: 10px;
    border: 1px dashed #9bb1c4;
    border-radius: 9px;
    background: #f8fbfd;
}

.photo-preview {
    display: block;
    max-width: 100%;
    max-height: 240px;
    margin-top: 12px;
    border-radius: 8px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 20px;
}

.primary-button,
.secondary-button {
    min-height: 42px;
    padding: 9px 16px;
    border-radius: 8px;
    font-weight: 700;
}

.primary-button {
    border: 1px solid var(--blue);
    background: var(--blue);
    color: #fff;
}

.primary-button:hover {
    background: var(--blue-dark);
}

.secondary-button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
}

.toast {
    position: fixed;
    z-index: 10;
    right: 20px;
    bottom: 20px;
    max-width: min(420px, calc(100% - 40px));
    padding: 12px 16px;
    border-radius: 9px;
    background: #183951;
    color: #fff;
    box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
}

.toast[hidden] {
    display: none;
}

@media (max-width: 760px) {
    .page {
        padding: 20px 12px 32px;
    }

    .layout {
        grid-template-columns: 1fr;
    }

    .summary {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px 16px;
        align-items: center;
    }

    .summary h2 {
        grid-column: 1 / -1;
    }

    .summary h2 {
        margin-bottom: 5px;
    }

    .score {
        margin: 4px 0 10px;
        text-align: right;
    }

    .progress-track,
    .progress-copy {
        grid-column: 1 / -1;
    }

    .progress-copy {
        margin: 3px 0 12px;
    }

    .bonus-note {
        padding-top: 12px;
    }

    .board-panel {
        padding: 10px;
    }

    .bingo-board {
        gap: 6px;
    }

    .square {
        min-height: 84px;
        padding: 7px 6px;
    }

    .square-title {
        font-size: .76rem;
        line-height: 1.3;
        overflow-wrap: anywhere;
        line-clamp: 3;
        -webkit-line-clamp: 3;
    }

    .square-number,
    .square-status {
        font-size: .7rem;
    }

    .square-formats {
        min-height: 16px;
        gap: 2px;
    }

    .square-format {
        padding: 2px 4px;
        font-size: .62rem;
    }

    .summary {
        padding: 14px;
        gap: 5px 12px;
    }

    .summary h2 {
        margin-bottom: 2px;
    }

    .score {
        margin: 0;
        font-size: 1.65rem;
    }

    .progress-track {
        margin-top: 3px;
    }

    .progress-copy {
        margin: 0 0 5px;
    }

    .bonus-note {
        grid-column: 1 / 2;
        padding-top: 8px;
        font-size: .75rem;
    }

    .reset-button {
        grid-column: 2 / 3;
        align-self: stretch;
        margin-top: 8px;
        padding: 7px 8px;
        font-size: .78rem;
    }

    .modal-backdrop {
        align-items: end;
        padding: 8px;
    }

    .dialog {
        max-height: 92dvh;
        overflow-y: auto;
        padding: 20px;
        border-radius: 16px;
    }

    .toast {
        right: 12px;
        bottom: 12px;
        max-width: calc(100% - 24px);
    }
}

@media (max-width: 420px) {
    .page {
        padding: 14px 8px 24px;
    }

    .header {
        margin-bottom: 12px;
    }

    h1 {
        font-size: 1.35rem;
    }

    .intro,
    .demo-note {
        font-size: .86rem;
    }

    .demo-note {
        margin-bottom: 12px;
        padding: 9px 10px;
    }

    .board-panel {
        padding: 8px;
    }

    .team-tabs {
        gap: 5px;
        margin-bottom: 12px;
    }

    .team-tab {
        min-height: 40px;
        font-size: .85rem;
    }

    .bingo-board {
        gap: 4px;
    }

    .square {
        min-height: 82px;
        padding: 6px 4px;
        border-radius: 8px;
    }

    .square-title {
        font-size: .72rem;
    }

    .square-number,
    .square-status {
        font-size: .66rem;
    }

    .square-format {
        font-size: .58rem;
    }
}
