/* the look: the same as the review page (white, thin lines, one accent color, the device's own font)
   phone and pc: the layout follows the width of .screen (a container query), not the window,
   so a phone frame on the review page still shows the phone layout */

/* the colors: change them here only */
:root {
    --paper: #ffffff;
    --field: #f5f6f7;
    --ink: #1d2830;
    --ink-soft: #56636d;
    --line: #cdd6dc;
    --accent: #34495e;
    --accent-ink: #ffffff;
    --village: #2f6f5e;
    --village-soft: #dcefe8;
    --wolf: #a8433a;
    --wolf-soft: #f6e1dd;
    --card-back: #34495e;
    --card-back-ink: #ffffff;
    --veil: rgba(29, 40, 48, 0.45);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #15191c;
        --field: #1e2327;
        --ink: #e4eaee;
        --ink-soft: #9aa7b1;
        --line: #2b3640;
        --accent: #a9c1d6;
        --accent-ink: #12181d;
        --village: #5fb39a;
        --village-soft: #1d332d;
        --wolf: #e07a6f;
        --wolf-soft: #3b2522;
        --card-back: #2c3b49;
        --card-back-ink: #e4eaee;
        --veil: rgba(0, 0, 0, 0.6);
        color-scheme: dark;
    }
}

/* the same dark colors when a page above this one says "dark" (the review page's theme switch) */
:root[data-theme="dark"] {
    --paper: #15191c;
    --field: #1e2327;
    --ink: #e4eaee;
    --ink-soft: #9aa7b1;
    --line: #2b3640;
    --accent: #a9c1d6;
    --accent-ink: #12181d;
    --village: #5fb39a;
    --village-soft: #1d332d;
    --wolf: #e07a6f;
    --wolf-soft: #3b2522;
    --card-back: #2c3b49;
    --card-back-ink: #e4eaee;
    --veil: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

button,
input {
    font: inherit;
    color: inherit;
}

/* no double-tap zoom or tap delay on buttons */
button,
input,
summary {
    touch-action: manipulation;
}

/* read by screen readers, not shown */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

h1 {
    margin: 0 0 12px;
    font-size: 20px;
    line-height: 1.4;
    text-wrap: balance;
}

h2 {
    margin: 0 0 10px;
    font-size: 17px;
}


/* ---------- the frame: title bar and the area the screens are drawn into ---------- */

.title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    max-width: 960px;
    margin: 0 auto;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.title-text {
    font-weight: 700;
}

.room-badge {
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.room-badge.is-away {
    color: var(--wolf);
    border-color: var(--wolf);
}

.screen {
    container-type: inline-size;
    padding: 8px 16px 48px;
}

/* the width of the content: one column on a phone, two columns (or a wider single one) on a pc */
.columns,
.single,
.how-to {
    max-width: 560px;
    margin-inline: auto;
}

.intro {
    padding-top: 12px;
}

.join-field {
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.panel {
    margin: 12px 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
}


/* ---------- text ---------- */

.lead {
    margin: 0 0 16px;
    color: var(--ink-soft);
}

.hint {
    margin: 8px 0;
    color: var(--ink-soft);
    font-size: 14px;
}

.center {
    text-align: center;
}

.error {
    margin: 8px 0 12px;
    padding: 8px 12px;
    background: var(--wolf-soft);
    color: var(--wolf);
    border-radius: 8px;
    font-size: 14px;
}

.code {
    letter-spacing: 0.1em;
}

.label {
    margin: 0;
    color: var(--ink-soft);
    text-align: center;
    font-size: 14px;
}

.label.left {
    text-align: left;
}

/* why "始める" cannot be pressed yet, in normal text above the button */
.need {
    margin: 16px 0 0;
    font-weight: 700;
    text-align: center;
}

.big-code {
    margin: 0 0 4px;
    text-align: center;
    font-size: 44px;
    font-weight: 700;
    letter-spacing: 0.2em;
    line-height: 1.2;
}

/* the room's QR code: dark squares on white in both themes (a camera needs that); hidden until drawn */
.qr {
    width: 168px;
    margin: 12px auto;
    padding: 10px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.qr:empty {
    display: none;
}

.qr svg {
    display: block;
    width: 100%;
    height: auto;
}

.share-url {
    word-break: break-all;
    user-select: all;
}


/* ---------- inputs and buttons ---------- */

.field {
    display: block;
    margin: 12px 0;
}

.field span {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 700;
}

.field input {
    width: 100%;
    padding: 12px;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 18px;
}

.main-button,
.sub-button {
    display: block;
    width: 100%;
    margin: 12px 0 4px;
    padding: 13px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

.main-button {
    background: var(--accent);
    color: var(--accent-ink);
    border: 1px solid var(--accent);
    font-size: 17px;
}

.sub-button {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.main-button:disabled,
.sub-button:disabled {
    opacity: 0.4;
    cursor: default;
}

.text-button {
    display: block;
    min-height: 44px;
    margin: 12px auto 0;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--ink-soft);
    text-decoration: underline;
    cursor: pointer;
}

/* going on without the others: set apart from the other links, in the warning color */
.text-button.is-danger {
    margin-bottom: 20px;
    color: var(--wolf);
}

.small-button {
    min-width: 44px;
    min-height: 36px;
    margin-left: auto;
    padding: 2px 12px;
    background: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
}

/* a mouse shows what it is over (phones have no hover, so this is for pc only) */
@media (hover: hover) {
    .main-button:not(:disabled):hover {
        filter: brightness(1.12);
    }

    .sub-button:not(:disabled):hover,
    .choice:not(.is-chosen):hover,
    .small-button:hover,
    button.judge:hover {
        background: var(--field);
    }

    .text-button:hover {
        color: var(--ink);
    }

    .card.is-closed:hover {
        filter: brightness(1.15);
    }
}


/* ---------- the people in the room ---------- */

.players {
    margin: 0;
    padding: 0;
    list-style: none;
}

.player {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px 2px;
    border-bottom: 1px solid var(--line);
}

.player.is-empty {
    color: var(--ink-soft);
}

.player.is-ghost {
    min-height: 42px;
    border-bottom-style: dashed;
}

/* who has pressed 見ました / sent the answer */
.waiting {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 14px;
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
    font-size: 14px;
}

.waiting li {
    display: flex;
    align-items: center;
    gap: 4px;
}

.waiting .is-waiting {
    color: var(--ink-soft);
}

.waiting-mark {
    font-weight: 700;
}

.waiting .is-done .waiting-mark {
    color: var(--village);
}

.player-name {
    font-weight: 700;
}

.mark {
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12px;
}

.mark.is-me {
    border-color: var(--accent);
    color: var(--accent);
}

.mark.is-away {
    color: var(--wolf);
}

.mark.is-wolf {
    margin-left: 6px;
    background: var(--wolf);
    border-color: var(--wolf);
    color: var(--paper);
}

/* the talk time: chosen in the room */
.setting {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 16px 0 0;
    font-size: 14px;
}

.setting > span {
    font-weight: 700;
}

.choices {
    display: flex;
    gap: 6px;
}

.choice {
    min-width: 52px;
    min-height: 44px;
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
}

.choice.is-chosen {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: var(--accent);
    font-weight: 700;
}


/* ---------- my card ---------- */

.card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    min-height: 120px;
    padding: 16px;
    border-radius: 10px;
    text-align: center;
}

button.card {
    cursor: pointer;
}

.card.is-big {
    min-height: 220px;
    margin-bottom: 8px;
}

.card.is-closed {
    background: var(--card-back);
    color: var(--card-back-ink);
    border: 1px solid var(--card-back);
}

.card.is-open {
    background: var(--paper);
    border: 1px solid var(--line);
}

.card-back-text {
    font-size: 20px;
    font-weight: 700;
}

.card-role {
    font-weight: 700;
    color: var(--village);
}

.card-role.is-wolf {
    color: var(--wolf);
}

.card-label {
    font-size: 13px;
    color: var(--ink-soft);
}

.card-word {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.3;
}

.card-note {
    font-size: 13px;
    opacity: 0.8;
}

/* the example lie: only on the wolf's own card, which is hidden from the others */
.card-decoy {
    margin-top: 6px;
    padding: 6px 10px;
    background: var(--wolf-soft);
    border-radius: 8px;
    font-size: 13px;
}


/* ---------- the talk: timer and the card window ---------- */

.timer {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0 4px;
}

.timer-label {
    color: var(--ink-soft);
    font-size: 14px;
}

.timer-value {
    font-size: 64px;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.timer.is-short .timer-value,
.timer.is-short .timer-label {
    color: var(--wolf);
}

/* 狼当て: who you think the wolf is (on the answer screen) */
.vote {
    margin: 12px 0 0;
}

.vote-label {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 700;
}

.vote .choices {
    flex-wrap: wrap;
}

.vote-choice {
    flex: 1 1 30%;
}

/* what to say during the talk (the same for everyone, also for the wolf) */
.talk-guide {
    margin: 14px 0 4px;
    padding-left: 22px;
    font-size: 16px;
    line-height: 1.6;
}

.talk-guide li {
    margin: 4px 0;
}

.window-timer {
    margin: 0 0 8px;
    color: var(--ink-soft);
    font-size: 14px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* the window for a player who forgot the card */
.card-window {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: safe center;
    justify-content: center;
    padding: 16px;
    background: var(--veil);
    z-index: 10;
}

.card-window-box {
    width: 100%;
    max-width: 420px;
    max-height: 100%;
    overflow-y: auto;
    padding: 16px;
    background: var(--paper);
    border-radius: 12px;
}

.reminder {
    margin: 12px 0 0;
    color: var(--ink-soft);
    font-size: 14px;
}


/* ---------- writing and the result ---------- */

.count {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 0;
    color: var(--ink-soft);
    font-size: 14px;
}

.count.center {
    justify-content: center;
}

.sent {
    margin: 8px 0;
    font-size: 14px;
}

.result {
    text-align: center;
    border: none;
}

.result.is-village {
    background: var(--village-soft);
}

.result.is-wolf {
    background: var(--wolf-soft);
}

.winner {
    margin: 0;
    font-size: 30px;
    font-weight: 700;
}

.answer-line {
    margin: 4px 0;
    font-size: 17px;
}

.decoy-line {
    margin: 8px 0 0;
    font-size: 14px;
}

.result .count {
    justify-content: center;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.result-table th,
.result-table td {
    padding: 8px 4px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.result-table th {
    color: var(--ink-soft);
    font-weight: 400;
    font-size: 12px;
}

.result-table tr.is-wolf td {
    background: var(--wolf-soft);
}

.judge {
    display: inline-block;
    min-width: 44px;
    min-height: 40px;
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--village);
    font-weight: 700;
    text-align: center;
}

.judge.is-no {
    color: var(--wolf);
}

button.judge {
    cursor: pointer;
}

.flipped {
    display: block;
    color: var(--ink-soft);
    font-size: 11px;
}


/* ---------- the title and its menu ---------- */

/* the title screen shows the name big, so the bar with the small name is hidden there (app.js) */
.is-title .title-bar {
    display: none;
}

.title-screen {
    max-width: 420px;
    margin: 0 auto;
    padding-top: 32px;
    text-align: center;
}

.logo {
    display: block;
    width: 200px;
    height: auto;
    margin: 0 auto 16px;
    color: var(--accent);
}

.logo-person {
    fill: none;
    stroke: currentColor;
    stroke-width: 3;
}

.logo-wolf {
    fill: currentColor;
    stroke: currentColor;
    stroke-width: 3;
    stroke-linejoin: round;
}

.game-name {
    margin: 0 0 8px;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.3;
}

.tagline {
    margin: 0 0 28px;
    color: var(--ink-soft);
}

.menu {
    text-align: left;
}

.menu .main-button {
    padding: 16px;
    font-size: 19px;
}

.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.menu-grid .sub-button {
    margin: 0;
    padding: 13px 6px;
}

/* the menu items and the "はじめる" at the end of 遊び方 are links that look like buttons */
a.main-button,
a.sub-button {
    text-align: center;
    text-decoration: none;
}

a.text-button {
    width: fit-content;
    text-align: center;
}

.legal-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px 20px;
    margin: 24px 0 4px;
    font-size: 14px;
}

.legal-links a,
.consent a,
.menu-page a:not([class]),
.faq a {
    color: var(--accent);
}

.version {
    margin: 0;
    color: var(--ink-soft);
    font-size: 12px;
}

/* the line under the buttons that start playing: pressing them agrees to the terms */
.consent {
    margin: 12px 0 0;
    color: var(--ink-soft);
    font-size: 13px;
}

.back-link {
    display: inline-block;
    min-height: 44px;
    padding: 10px 0;
    color: var(--ink-soft);
    font-size: 14px;
    text-decoration: none;
}

.menu-page h1 {
    margin-top: 4px;
}

.menu-page h3 {
    margin: 16px 0 4px;
    font-size: 15px;
}

.menu-page p,
.menu-page ul,
.menu-page ol {
    margin: 8px 0;
}

.menu-page ul,
.menu-page ol {
    padding-left: 20px;
}

.menu-page li {
    margin: 6px 0;
}

.menu-page .panel > :last-child {
    margin-bottom: 0;
}

/* 遊び方: the five steps, each with its number in a circle */
.menu-page ol.steps {
    padding-left: 0;
    list-style: none;
    counter-reset: step;
}

.steps li {
    position: relative;
    padding-left: 40px;
    counter-increment: step;
}

.steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 14px;
    font-weight: 700;
    line-height: 28px;
    text-align: center;
}

.roles li {
    margin: 8px 0;
}

/* 遊び方: the example of a talk, one line per person */
.menu-page ol.talk-example {
    margin: 12px 0;
    padding: 12px 14px;
    background: var(--field);
    border-radius: 8px;
    list-style: none;
}

.talk-example li {
    margin: 8px 0;
}

.talk-example .who {
    display: block;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 700;
}

/* よくある質問: each question opens by itself */
.faq-list {
    margin: 12px 0;
    border-top: 1px solid var(--line);
}

.faq {
    border-bottom: 1px solid var(--line);
}

.faq summary {
    min-height: 44px;
    padding: 12px 4px;
    font-weight: 700;
    cursor: pointer;
}

.faq p {
    margin: 0 4px 14px;
    color: var(--ink-soft);
}

/* 設定 */
.saved-list {
    font-size: 14px;
}

.sub-button.is-danger {
    color: var(--wolf);
    border-color: var(--wolf);
}

/* このゲームについて */
.about-head {
    text-align: center;
}

.about-head .logo {
    width: 160px;
}

.about-head .game-name {
    font-size: 24px;
}

.facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    margin: 0;
}

.facts dt {
    color: var(--ink-soft);
    font-size: 14px;
}

.facts dd {
    margin: 0;
}

/* ---------- 利用規約 and プライバシーポリシー (terms.html, privacy.html: pages of their own) ---------- */

.title-link {
    color: inherit;
    text-decoration: none;
}

.doc {
    max-width: 720px;
    margin: 0 auto;
    padding: 8px 16px 64px;
    line-height: 1.8;
    overflow-wrap: anywhere;
}

.doc h1 {
    margin-top: 4px;
}

.doc h2 {
    margin: 40px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
    font-size: 19px;
}

.doc h3 {
    margin: 24px 0 8px;
    font-size: 16px;
}

.doc p,
.doc ul,
.doc ol {
    margin: 8px 0;
}

.doc ul,
.doc ol {
    padding-left: 22px;
}

.doc li {
    margin: 4px 0;
}

.doc a {
    color: var(--accent);
}

/* "this is a draft": set apart at the top */
.doc-draft {
    padding: 12px 14px;
    background: var(--field);
    border-left: 4px solid var(--accent);
    border-radius: 4px;
    font-size: 14px;
}

.doc-toc {
    margin: 16px 0;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.doc-footer {
    margin-top: 48px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: 14px;
    text-align: center;
}

/* the headings of the menu pages take the keyboard focus when the page opens (app.js) */
h1[tabindex="-1"]:focus {
    outline: none;
}


/* ---------- how to play, footer, messages ---------- */

.how-to {
    display: block;
    margin-top: 12px;
    margin-bottom: 12px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.how-to summary {
    min-height: 32px;
    font-weight: 700;
    cursor: pointer;
}

.how-to ol {
    margin: 8px 0 0;
    padding-left: 20px;
    font-size: 14px;
}

.how-to li {
    margin: 6px 0;
}

.footer {
    margin-top: 24px;
    text-align: center;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    padding: 10px 16px;
    background: var(--ink);
    color: var(--paper);
    border-radius: 8px;
    font-size: 14px;
    z-index: 20;
}


/* ---------- a narrow phone: the result table becomes one card per player ---------- */

@container (max-width: 480px) {
    .result-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .result-table,
    .result-table tbody,
    .result-table tr,
    .result-table td {
        display: block;
    }

    .result-table tr {
        position: relative;
        padding: 10px 56px 10px 10px;
        border-bottom: 1px solid var(--line);
    }

    .result-table td {
        padding: 2px 0;
        border: none;
    }

    .result-table td[data-label="ヒント"]::before,
    .result-table td[data-label="書いた答え"]::before,
    .result-table td[data-label="狼だと思った人"]::before {
        content: attr(data-label) ": ";
        color: var(--ink-soft);
        font-size: 12px;
    }

    .result-table td[data-label="名前"] {
        font-weight: 700;
    }

    .result-table td[data-label="判定"] {
        position: absolute;
        top: 10px;
        right: 6px;
    }
}


/* ---------- a pc (a wide screen): two columns, bigger timer and card ---------- */

@container (min-width: 820px) {
    .columns {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
        align-items: start;
        max-width: 960px;
    }

    .columns > .panel {
        min-width: 0;
    }

    .single {
        max-width: 680px;
    }

    .how-to {
        max-width: 960px;
    }

    .panel {
        padding: 24px;
    }

    h1 {
        font-size: 24px;
    }

    .big-code {
        font-size: 60px;
    }

    .title-screen {
        padding-top: 64px;
    }

    .title-screen .logo {
        width: 240px;
    }

    .game-name {
        font-size: 40px;
    }

    .card.is-big {
        min-height: 300px;
    }

    .card-word {
        font-size: 40px;
    }

    .timer-value {
        font-size: 128px;
    }

    .winner {
        font-size: 40px;
    }

    .result-table {
        font-size: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}
