/* 食べごろいちご摘み (#549)。strawberry_game/templates/strawberry_game/ のページだけで読む */

.sg-page {
    --sg-red: #be123c;
    --sg-red-dark: #9f1239;
    --sg-text: #1f2937;
    --sg-muted: #6b7280;
    --sg-line: #06c755;
    --sg-cream: #fffbf5;
    min-height: 100vh;
    padding: 64px 16px 64px;
    background: linear-gradient(180deg, var(--sg-cream) 0%, #fff1f2 100%);
    color: var(--sg-text);
    /* 日本語を文節で折り返す (対応しないブラウザは今までどおり 1 文字ずつ) */
    word-break: auto-phrase;
}

/* hidden 属性で消す要素に display を付けても、消えたままにする */
.sg-page [hidden] {
    display: none !important;
}

.sg-symbols {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ── 見出し ── */
.sg-hero {
    max-width: 28rem;
    margin: 0 auto 16px;
    text-align: center;
}

.sg-eyebrow {
    margin: 0 0 4px;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--sg-red);
    letter-spacing: 0.08em;
}

.sg-title {
    margin: 0 0 8px;
    font-size: 1.875rem;
    font-weight: 900;
    line-height: 1.3;
}

.sg-lead {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.8;
    color: var(--sg-muted);
}

/* ── ボタン ── */
.sg-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    min-height: 44px;
    padding: 10px 22px;
    border: 0;
    border-radius: 999px;
    font-size: 0.9375rem;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sg-button:hover {
    transform: translateY(-1px);
}

.sg-button:disabled {
    opacity: 0.5;
    cursor: default;
    transform: none;
}

.sg-button--primary {
    color: #fff;
    background: linear-gradient(90deg, #e11d48, var(--sg-red));
    box-shadow: 0 10px 24px rgba(190, 18, 60, 0.25);
}

.sg-button--large {
    min-height: 52px;
    padding: 12px 40px;
    font-size: 1.0625rem;
}

.sg-button--line {
    color: #fff;
    background: var(--sg-line);
}

.sg-button--dark {
    color: #fff;
    background: #1f2937;
}

.sg-button--light {
    color: #374151;
    background: #fff;
    border: 1px solid #e5e7eb;
}

.sg-button--outline {
    color: var(--sg-red);
    background: #fff;
    border: 2px solid var(--sg-red);
}

/* ── 盤面 ── */
.sg-game {
    max-width: 26rem;
    margin: 0 auto;
}

/* 固定のヘッダー (高さ 48px) の下に隠れないように */
.sg-game,
.sg-result {
    scroll-margin-top: 64px;
}

.sg-hud {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    font-weight: 700;
}

.sg-hud-item {
    margin: 0;
    font-size: 0.9375rem;
    white-space: nowrap;
}

.sg-hud-value {
    display: inline-block;
    min-width: 2.2em;
    font-size: 1.375rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    text-align: right;
    color: var(--sg-red);
}

.sg-timebar {
    height: 8px;
    border-radius: 999px;
    background: #fde2e7;
    overflow: hidden;
}

.sg-timebar-fill {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: var(--sg-red);
    transform-origin: left center;
}

.sg-field {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: 24px;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.8), transparent 40%),
        linear-gradient(180deg, #eef7e8 0%, #dcefd2 100%);
    box-shadow: inset 0 0 0 2px rgba(47, 125, 50, 0.15), 0 12px 28px rgba(31, 41, 55, 0.08);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* 遊んでいるあいだは、盤面に触れた指でページをスクロール・拡大しない。速く摘んでいる指が
   滑って、盤面が途中でずれないように (遊ぶ前と後は、盤面からでもスクロールできる) */
.sg-field[data-state="playing"] {
    touch-action: none;
}

/* aspect-ratio の無いブラウザ (Safari 14 まで): 高さを幅の 4/3 にする。中身はどれも絶対配置 */
@supports not (aspect-ratio: 1 / 1) {
    .sg-field {
        height: 0;
        padding-bottom: 133.3333%;
    }
}

/* 高設栽培の棚。4 段。実は棚の縁から下がる */
.sg-benches {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-rows: repeat(4, 1fr);
}

.sg-bench {
    position: relative;
}

.sg-bench::before {
    /* 棚の上の葉 */
    content: "";
    position: absolute;
    top: 4%;
    left: 4%;
    right: 4%;
    height: 22%;
    border-radius: 999px 999px 40% 40%;
    background:
        radial-gradient(ellipse 14% 90% at 12% 70%, #4c9a2a 60%, transparent 62%),
        radial-gradient(ellipse 14% 90% at 34% 60%, #3e8e41 60%, transparent 62%),
        radial-gradient(ellipse 14% 90% at 56% 70%, #4c9a2a 60%, transparent 62%),
        radial-gradient(ellipse 14% 90% at 78% 60%, #3e8e41 60%, transparent 62%),
        radial-gradient(ellipse 14% 90% at 94% 72%, #4c9a2a 60%, transparent 62%);
}

.sg-bench::after {
    /* 棚の縁 */
    content: "";
    position: absolute;
    top: 24%;
    left: 2%;
    right: 2%;
    height: 7%;
    border-radius: 6px;
    background: linear-gradient(180deg, #a3a3a3, #737373);
}

.sg-slots {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

/* 場所のボタン。キーボードでは矢印キーで選び、Enter・スペースでその場所の実を摘む。
   指・マウスでは中の実に触れて摘む (game.js) */
.sg-slot {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: none;
    color: inherit;
    font: inherit;
    cursor: default;
}

.sg-slot:focus-visible {
    outline: 3px solid #1d4ed8;
    outline-offset: -3px;
}

/* 実は棚の縁 (段の高さの 24〜31%) から下がる。横は真ん中に置く (transform はアニメーションで使う) */
.sg-berry {
    position: absolute;
    top: 27%;
    left: 21%;
    display: block;
    width: 58%;
    aspect-ratio: 100 / 120;
    cursor: pointer;
    animation: sg-pop 0.16s ease-out;
}

.sg-berry .sg-berry-svg {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.sg-berry--white {
    left: 27%;
    width: 46%;
}

.sg-berry .sg-leaf {
    position: absolute;
    bottom: 6%;
    width: 62%;
    height: auto;
    aspect-ratio: 1;
    pointer-events: none;
}

.sg-leaf--left {
    left: -18%;
}

.sg-leaf--right {
    right: -18%;
    transform: scaleX(-1);
}

/* aspect-ratio の無いブラウザ: 場所は正方形 (3:4 の盤面を 3 列 × 4 段に分ける) なので、
   実の高さを場所の高さの割合で書く (実の高さは幅の 1.2 倍、葉は実の幅の 62% の正方形) */
@supports not (aspect-ratio: 1 / 1) {
    .sg-berry {
        height: 69.6%;
    }

    .sg-berry--white {
        height: 55.2%;
    }

    .sg-berry .sg-leaf {
        height: 51.7%;
    }
}

.sg-berry.is-picked {
    animation: sg-picked 0.22s ease-in forwards;
    pointer-events: none;
}

.sg-berry.is-wrong {
    animation: sg-wrong 0.26s ease-in-out forwards;
    pointer-events: none;
}

.sg-float {
    position: absolute;
    left: 50%;
    top: 30%;
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--sg-red);
    text-shadow: 0 1px 0 #fff, 0 0 6px #fff;
    transform: translateX(-50%);
    pointer-events: none;
    animation: sg-float 0.6s ease-out forwards;
}

.sg-float--minus {
    color: #374151;
}

@keyframes sg-pop {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes sg-picked {
    to { transform: translateY(-24px) scale(0.6); opacity: 0; }
}

@keyframes sg-wrong {
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    100% { transform: translateX(0); opacity: 0; }
}

@keyframes sg-float {
    from { transform: translate(-50%, 0); opacity: 1; }
    to { transform: translate(-50%, -28px); opacity: 0; }
}

@keyframes sg-fade {
    to { opacity: 0; }
}

/* 動きを減らす設定: 動かさず、うすくして消すだけにする */
@media (prefers-reduced-motion: reduce) {
    .sg-berry,
    .sg-button {
        animation: none;
        transition: none;
    }

    .sg-button:hover {
        transform: none;
    }

    .sg-berry.is-picked,
    .sg-berry.is-wrong,
    .sg-float {
        animation: sg-fade 0.3s linear forwards;
    }

    .sg-float {
        transform: translateX(-50%);
    }
}

/* ── 見本・ひと休み ── */
/* 終わった直後は「はじめる」と結果のボタンを押せなくする。終わり際に連打していた指が、
   出たばかりの結果を消したりシェアを開いたりしないように (game.js の FINISH_GUARD_MS) */
.sg-field.is-settling .sg-overlay,
.sg-result.is-settling {
    pointer-events: none;
}

.sg-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    text-align: center;
    background: rgba(255, 251, 245, 0.94);
}

.sg-overlay-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 900;
}

.sg-overlay-text {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    line-height: 1.8;
}

/* キーボードの案内は、マウスで使う端末だけに出す */
.sg-keyboard-note {
    display: none;
    margin: 0;
    font-size: 0.8125rem;
    color: var(--sg-muted);
}

@media (hover: hover) and (pointer: fine) {
    .sg-keyboard-note {
        display: block;
    }
}

.sg-legend {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sg-legend-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.sg-legend-berry {
    width: 56px;
    height: 67px;
}

.sg-legend-berry--small {
    width: 44px;
    height: 67px;
}

.sg-legend-name {
    font-size: 0.875rem;
    font-weight: 800;
}

.sg-legend-points {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--sg-muted);
}

.sg-legend-points--plus {
    color: var(--sg-red);
}

/* ── 結果 ── */
.sg-result {
    max-width: 26rem;
    margin: 24px auto 0;
    padding: 24px 20px;
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(31, 41, 55, 0.08);
    text-align: center;
}

.sg-result > * + * {
    margin-top: 12px;
}

.sg-result-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--sg-muted);
}

.sg-result-title:focus {
    outline: none;
}

.sg-result-score {
    margin-bottom: 0;
    font-size: 1rem;
    font-weight: 800;
}

.sg-result-score span {
    font-size: 3rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    color: var(--sg-red);
}

.sg-result-detail {
    font-size: 0.875rem;
    color: var(--sg-muted);
}

.sg-result-rank {
    font-size: 1.5rem;
    font-weight: 900;
}

.sg-result-message {
    font-size: 0.9375rem;
    line-height: 1.8;
}

.sg-tip {
    padding: 14px 16px;
    border-radius: 16px;
    background: #fff1f2;
    text-align: left;
}

.sg-tip-label {
    margin: 0 0 4px;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--sg-red);
}

.sg-tip-text {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    line-height: 1.7;
}

.sg-share {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.sg-rank-level {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 0 0 8px;
}

.sg-rank-berry {
    width: 28px;
    height: 34px;
}

.sg-rank-berry--off {
    opacity: 0.2;
    filter: grayscale(1);
}

/* ── 本物のいちご狩りへ ── */
.sg-visit {
    max-width: 26rem;
    margin: 32px auto 0;
    text-align: center;
}

.sg-visit-title {
    margin: 0 0 6px;
    font-size: 1.25rem;
    font-weight: 900;
}

.sg-visit-lead,
.sg-visit-note {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.8;
    color: var(--sg-muted);
}

.sg-visit-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 16px 0 10px;
}

/* ── ランク ── */
.sg-ranks {
    max-width: 26rem;
    margin: 40px auto 0;
}

.sg-ranks-title {
    margin: 0 0 10px;
    font-size: 1rem;
    font-weight: 900;
    text-align: center;
}

.sg-ranks-list {
    margin: 0;
    padding: 0;
    list-style: none;
    border-radius: 16px;
    background: #fff;
    overflow: hidden;
}

.sg-ranks-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    font-size: 0.9375rem;
    border-top: 1px solid #f3f4f6;
}

.sg-ranks-item:first-child {
    border-top: 0;
}

.sg-ranks-item--current {
    background: #fff1f2;
    font-weight: 900;
}

.sg-ranks-name {
    font-weight: 800;
}

.sg-ranks-range {
    color: var(--sg-muted);
    font-variant-numeric: tabular-nums;
}

.sg-ranks-note {
    margin: 10px 0 0;
    font-size: 0.8125rem;
    text-align: center;
    color: var(--sg-muted);
}
