@charset "utf-8";
/* ============================================================
    あそび・脳トレのゲーム
    ============================================================ */

/* ゲームで使う色（盤・石・数字・合図） */
:root{
    --boardGreen: #2f8f5b;      /* リバーシの盤 */
    --boardGreenLine: #22724a;
    --boardWood: #e8c48a;       /* 五目並べの盤 */
    --boardWoodLine: #a8834a;
    --stoneBlack: #262626;
    --stoneWhite: #fbfbfb;
    --stoneShadow: rgba(0, 0, 0, 0.35);
    --mineN1: #2a62b0;          /* 地雷さがしの数字の色 */
    --mineN2: #1f7a3a;
    --mineN3: #c8324b;
    --mineN4: #3f2f8f;
    --mineN5: #8f2e14;
    --mineN6: #13757a;
    --mineN7: #262626;
    --mineN8: #6e6e6e;
    --signalWait: #e8384f;      /* 反応速度：待って */
    --signalGo: #1fa35a;        /* 反応速度：押して */
    --signalText: #ffffff;
    --stroopRed: #e02b3c;       /* ストループ：はっきり見分けられる4色 */
    --stroopBlue: #1f5fd1;
    --stroopGreen: #138a3c;
    --stroopYellow: #d9a400;
}

/* ▼ 共通 */
.gameSettings{
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--spaceMd) var(--spaceXl);
    margin-bottom: var(--spaceLg);
}
.gameSettings .field{
    margin: 0;
}
.gameStatus{
    min-height: 1.6em;
    margin: var(--spaceSm) 0;
    font-weight: 700;
    text-align: center;
}
.gameScore{
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--spaceSm);
    margin: var(--spaceMd) 0;
}
.gameScore div{
    display: grid;
    justify-items: center;
    min-width: 6.5rem;
    padding: 0.4rem 0.9rem;
    border-radius: var(--radiusMd);
    background: var(--catSoft);
}
.gameScore dt{
    font-size: 0.75rem;
    color: var(--textSub);
}
.gameScore dd{
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--catText);
    font-variant-numeric: tabular-nums;
}
/* 盤のマス（ボタン）の共通 */
.tttCell,
.revCell,
.gmkCell,
.slideTile,
.memoryCard,
.mineCell,
.npCell,
.ntCell,
.csCell,
.moleHole{
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}
.tttCell:focus-visible,
.revCell:focus-visible,
.gmkCell:focus-visible,
.slideTile:focus-visible,
.memoryCard:focus-visible,
.mineCell:focus-visible,
.npCell:focus-visible,
.ntCell:focus-visible,
.csCell:focus-visible,
.moleHole:focus-visible{
    outline: 3px solid var(--focusRing);
    outline-offset: 1px;
    z-index: 1;
}

/* ▼ 三目並べ */
.tttBoard{
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: min(100%, 360px);
    margin: 0 auto;
}
.tttCell{
    aspect-ratio: 1;
    border-radius: var(--radiusMd);
    background: var(--bgCard);
    box-shadow: inset 0 0 0 2px var(--line);
    font-size: clamp(2.5rem, 12vw, 4rem);
    font-weight: 700;
    line-height: 1;
}
.tttCell.isO{
    color: var(--accentText);
}
.tttCell.isX{
    color: var(--toneBlueText);
}
.tttCell.isWin{
    background: var(--highlightSoft);
    box-shadow: inset 0 0 0 3px var(--highlight);
}
.tttCell:disabled{
    cursor: default;
    opacity: 1;
}
@media (hover: hover){
    .tttCell:not(:disabled):hover{
        background: var(--catSoft);
    }
}

/* ▼ リバーシ */
.revScoreBar{
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--spaceSm);
    max-width: 480px;
    margin: 0 auto var(--spaceSm);
}
.revScoreBar .gameStatus{
    margin: 0;
    font-size: 0.875rem;
}
.revCount{
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    font-weight: 700;
}
.revCount b{
    font-size: 1.25rem;
    font-variant-numeric: tabular-nums;
}
.revStone{
    width: 1.2em;
    height: 1.2em;
    border-radius: 50%;
}
.revStone.isBlack{
    background: var(--stoneBlack);
}
.revStone.isWhite{
    background: var(--stoneWhite);
    box-shadow: inset 0 0 0 1px var(--lineStrong);
}
.revBoard{
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    width: min(100%, 480px);
    margin: 0 auto;
    padding: 6px;
    border-radius: var(--radiusSm);
    background: var(--boardGreenLine);
}
.revCell{
    position: relative;
    aspect-ratio: 1;
    background: var(--boardGreen);
    border-radius: 2px;
}
.revCell::after{
    content: "";
    position: absolute;
    inset: 10%;
    border-radius: 50%;
    transition: background-color 200ms ease, transform 200ms ease;
}
.revCell.hasBlack::after{
    background: var(--stoneBlack);
    box-shadow: 0 2px 2px var(--stoneShadow);
}
.revCell.hasWhite::after{
    background: var(--stoneWhite);
    box-shadow: 0 2px 2px var(--stoneShadow);
}
.revCell.isHint::after{
    inset: 38%;
    background: var(--stoneShadow);
}
.revCell.isLast::before{
    content: "";
    position: absolute;
    z-index: 1;
    top: 50%;
    left: 50%;
    width: 16%;
    height: 16%;
    margin: -8% 0 0 -8%;
    border-radius: 50%;
    background: var(--accent);
}
.revCell:disabled{
    cursor: default;
    opacity: 1;
}

/* ▼ 五目並べ */
.gmkWrap{
    overflow-x: auto;
}
.gmkBoard{
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    width: min(100%, 540px);
    min-width: 330px;
    margin: 0 auto;
    padding: 6px;
    border-radius: var(--radiusSm);
    background: var(--boardWood);
}
.gmkCell{
    position: relative;
    aspect-ratio: 1;
    background:
        linear-gradient(var(--boardWoodLine), var(--boardWoodLine)) center / 100% 1px no-repeat,
        linear-gradient(var(--boardWoodLine), var(--boardWoodLine)) center / 1px 100% no-repeat;
}
.gmkCell.isStar{
    background:
        radial-gradient(circle, var(--boardWoodLine) 2.5px, transparent 3px),
        linear-gradient(var(--boardWoodLine), var(--boardWoodLine)) center / 100% 1px no-repeat,
        linear-gradient(var(--boardWoodLine), var(--boardWoodLine)) center / 1px 100% no-repeat;
}
.gmkCell::after{
    content: "";
    position: absolute;
    inset: 8%;
    border-radius: 50%;
}
.gmkCell.hasBlack::after{
    background: var(--stoneBlack);
    box-shadow: 0 1px 2px var(--stoneShadow);
}
.gmkCell.hasWhite::after{
    background: var(--stoneWhite);
    box-shadow: 0 1px 2px var(--stoneShadow);
}
.gmkCell.isLast::after{
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.gmkCell.isWin::after{
    outline: 3px solid var(--highlight);
    outline-offset: 1px;
}
.gmkCell:disabled{
    cursor: default;
    opacity: 1;
}

/* ▼ スライドパズル */
.slideBoard{
    --size: 4;
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--size), 1fr);
    gap: 4px;
    width: min(100%, 420px);
    margin: 0 auto;
    padding: 6px;
    border-radius: var(--radiusMd);
    background: var(--lineStrong);
}
.slideTile{
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    border-radius: 8px;
    background-color: var(--bgCard);
    background-size: calc(var(--size) * 100%) calc(var(--size) * 100%);
    font-size: clamp(1rem, 6vw, 1.75rem);
    font-weight: 700;
    color: var(--textMain);
    transition: transform 80ms ease;
}
.slideTile.isEmpty{
    visibility: hidden;
}
/* 写真のときは、数字を小さくすみに出す */
.slideBoard.hasPhoto .slideTile{
    place-items: start;
    padding: 4px 6px;
    font-size: 0.75rem;
    color: var(--textOnAccent);
    text-shadow: 0 1px 2px var(--stoneShadow);
}
.slideBoard.isHint .slideTile.isPlaced{
    box-shadow: inset 0 0 0 3px var(--success);
}
/* 完成の形を重ねて見せる（写真のとき） */
.slideBoard.hasPhoto.isHint::after{
    content: "";
    position: absolute;
    inset: 6px;
    border-radius: 8px;
    background: var(--photo) center / cover;
    opacity: 0.85;
    pointer-events: none;
}
@media (hover: hover){
    .slideTile:hover{
        transform: scale(0.97);
    }
}

/* ▼ 神経衰弱 */
.memoryBoard{
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: min(100%, 560px);
    margin: 0 auto;
}
.memoryBoard[data-count="20"]{
    grid-template-columns: repeat(5, 1fr);
}
.memoryBoard[data-count="30"]{
    grid-template-columns: repeat(6, 1fr);
}
.memoryCard{
    position: relative;
    aspect-ratio: 3 / 4;
    perspective: 600px;
}
.memoryFace{
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    border-radius: var(--radiusSm);
    backface-visibility: hidden;
    transition: transform 300ms ease;
}
.memoryBack{
    background: repeating-linear-gradient(45deg, var(--catColor) 0 6px, var(--catSoft) 6px 12px);
    box-shadow: inset 0 0 0 3px var(--bgCard), 0 2px 4px var(--stoneShadow);
}
.memoryFront{
    background: var(--bgCard);
    box-shadow: inset 0 0 0 2px var(--line);
    font-size: clamp(1.4rem, 6vw, 2.4rem);
    font-weight: 700;
    transform: rotateY(180deg);
}
.memoryCard.isOpen .memoryBack,
.memoryCard.isDone .memoryBack{
    transform: rotateY(180deg);
}
.memoryCard.isOpen .memoryFront,
.memoryCard.isDone .memoryFront{
    transform: rotateY(0);
}
.memoryCard.isDone .memoryFront{
    background: var(--highlightSoft);
    opacity: 0.75;
}

/* ▼ 地雷さがし */
.mineWrap{
    overflow-x: auto;
    padding-bottom: 4px;
}
.mineBoard{
    --cols: 9;
    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(24px, 36px));
    gap: 2px;
    justify-content: center;
    width: max-content;
    min-width: 100%;
    margin: 0 auto;
}
.mineCell{
    aspect-ratio: 1;
    border-radius: 4px;
    background: var(--catSoft);
    box-shadow: inset 0 -3px 0 var(--lineStrong);
    font-weight: 700;
    font-size: 0.9375rem;
    line-height: 1;
}
.mineCell.isOpen{
    background: var(--bgCard);
    box-shadow: inset 0 0 0 1px var(--line);
}
.mineCell.isFlag{
    color: var(--danger);
}
.mineCell.isMine{
    background: var(--bgMuted);
}
.mineCell.isBoom{
    background: var(--danger);
    color: var(--textOnAccent);
}
.mineCell.isWrong{
    text-decoration: line-through;
}
.mineCell.n1{ color: var(--mineN1); }
.mineCell.n2{ color: var(--mineN2); }
.mineCell.n3{ color: var(--mineN3); }
.mineCell.n4{ color: var(--mineN4); }
.mineCell.n5{ color: var(--mineN5); }
.mineCell.n6{ color: var(--mineN6); }
.mineCell.n7{ color: var(--mineN7); }
.mineCell.n8{ color: var(--mineN8); }

/* ▼ ナンプレ */
.npBoard{
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    width: min(100%, 450px);
    margin: 0 auto;
    border: 3px solid var(--textMain);
    border-radius: 4px;
    background: var(--bgCard);
}
.npCell{
    position: relative;
    aspect-ratio: 1;
    border-right: 1px solid var(--lineStrong);
    border-bottom: 1px solid var(--lineStrong);
    border-radius: 0;
    font-size: clamp(1rem, 5vw, 1.5rem);
    font-weight: 700;
    color: var(--toneBlueText);
    line-height: 1;
}
.npCell.isRightEdge{
    border-right: 2px solid var(--textMain);
}
.npCell.isBottomEdge{
    border-bottom: 2px solid var(--textMain);
}
.npCell.isGiven{
    color: var(--textMain);
}
.npCell.isRelated{
    background: var(--bgMuted);
}
.npCell.isSame{
    background: var(--catSoft);
}
.npCell.isSelected{
    background: var(--highlightSoft);
    box-shadow: inset 0 0 0 2px var(--highlight);
}
.npCell.isWrong{
    color: var(--danger);
}
.npMemos{
    position: absolute;
    inset: 2px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    font-size: clamp(0.5rem, 2vw, 0.625rem);
    font-weight: 400;
    color: var(--textSub);
}
.npPad{
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 4px;
    width: min(100%, 450px);
    margin: var(--spaceMd) auto;
}
.npKey{
    min-height: 44px;
    border-radius: var(--radiusSm);
    background: var(--bgCard);
    box-shadow: inset 0 0 0 2px var(--line);
    font-size: 1.125rem;
    font-weight: 700;
}
.npKey.isWide{
    grid-column: span 3;
    font-size: 0.875rem;
}
.npKey[aria-pressed="true"]{
    background: var(--catSoft);
    box-shadow: inset 0 0 0 2px var(--catColor);
}
.npKey:focus-visible{
    outline: 3px solid var(--focusRing);
    outline-offset: 1px;
}

/* ▼ もぐらたたき */
.moleField{
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: min(100%, 420px);
    margin: 0 auto;
}
.moleHole{
    position: relative;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(ellipse at 50% 70%, var(--textSub) 0 38%, var(--catLifeSoft) 39%);
    overflow: hidden;
}
.moleChar{
    position: absolute;
    left: 0;
    right: 0;
    bottom: 12%;
    font-size: clamp(2rem, 11vw, 3.5rem);
    line-height: 1;
    transform: translateY(110%);
    transition: transform 120ms ease-out;
}
.moleHole.isUp .moleChar{
    transform: translateY(0);
}
.moleHole.isHit .moleChar{
    transform: translateY(20%) scale(0.85);
    filter: grayscale(0.6);
}

/* ▼ 反応速度 */
.reactionPad{
    display: grid;
    place-content: center;
    gap: var(--spaceSm);
    width: 100%;
    min-height: 260px;
    border-radius: var(--radiusLg);
    background: var(--catColor);
    color: var(--signalText);
    text-align: center;
}
.reactionPad[data-state="wait"]{
    background: var(--signalWait);
}
.reactionPad[data-state="go"]{
    background: var(--signalGo);
}
.reactionPad[data-state="early"]{
    background: var(--textSub);
}
.reactionMain{
    font-size: clamp(1.5rem, 6vw, 2.5rem);
    font-weight: 700;
}
.reactionSub{
    font-size: 0.875rem;
}
.reactionLog{
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--spaceSm);
    padding: 0;
    list-style: none;
    font-family: var(--fontMono);
}

/* ▼ 連打 */
.clickPad{
    display: grid;
    place-content: center;
    gap: var(--spaceSm);
    width: 100%;
    min-height: 240px;
    border-radius: var(--radiusLg);
    background: var(--catSoft);
    box-shadow: inset 0 0 0 3px var(--catColor);
    text-align: center;
}
.clickPad.isPressing{
    background: var(--catColor);
}
.clickPad.isDone{
    opacity: 0.7;
}
.clickCount{
    font-size: clamp(3rem, 15vw, 5rem);
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.clickHint{
    font-size: 0.875rem;
    color: var(--textSub);
}

/* ▼ 数字タッチ */
.ntBoard{
    --size: 5;
    display: grid;
    grid-template-columns: repeat(var(--size), 1fr);
    gap: 6px;
    width: min(100%, 420px);
    margin: 0 auto;
}
.ntCell{
    aspect-ratio: 1;
    border-radius: var(--radiusSm);
    background: var(--bgCard);
    box-shadow: inset 0 0 0 2px var(--line);
    font-size: clamp(1.1rem, 6vw, 1.75rem);
    font-weight: 700;
}
.ntCell.isDone{
    background: var(--bgMuted);
    color: var(--lineStrong);
    opacity: 1;
}
.ntCell.isWrong{
    animation: gameShake 0.3s;
}

/* ▼ 色の違い */
.csBoard{
    --size: 2;
    display: grid;
    grid-template-columns: repeat(var(--size), 1fr);
    gap: 4px;
    width: min(100%, 420px);
    aspect-ratio: 1;
    margin: 0 auto;
}
.csCell{
    border-radius: 6px;
}
.csCell.isAnswer{
    box-shadow: 0 0 0 4px var(--textMain);
    opacity: 1;
}
.csCell.isWrong{
    animation: gameShake 0.3s;
}

/* ▼ ストループ */
.stroopStage{
    display: grid;
    place-items: center;
    min-height: 160px;
    border-radius: var(--radiusLg);
    background: var(--bgCard);
    box-shadow: inset 0 0 0 2px var(--line);
}
.stroopWord{
    margin: 0;
    font-size: clamp(2.5rem, 12vw, 4.5rem);
    font-weight: 700;
}
.stroopWord[data-ink="red"]{ color: var(--stroopRed); }
.stroopWord[data-ink="blue"]{ color: var(--stroopBlue); }
.stroopWord[data-ink="green"]{ color: var(--stroopGreen); }
.stroopWord[data-ink="yellow"]{ color: var(--stroopYellow); }
.stroopChoices{
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spaceSm);
    margin-top: var(--spaceMd);
}
.stroopBtn{
    min-height: 56px;
    border-radius: var(--radiusMd);
    color: var(--signalText);
    font-weight: 700;
}
.stroopBtn.isRed{ background: var(--stroopRed); }
.stroopBtn.isBlue{ background: var(--stroopBlue); }
.stroopBtn.isGreen{ background: var(--stroopGreen); }
.stroopBtn.isYellow{ background: var(--stroopYellow); }
.stroopBtn:focus-visible{
    outline: 3px solid var(--focusRing);
    outline-offset: 2px;
}
@media (max-width: 719px){
    .stroopChoices{
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ▼ ヘビ */
.snakeStage{
    position: relative;
    width: min(100%, 400px);
    margin: 0 auto;
}
.snakeCanvas{
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--radiusSm);
    box-shadow: inset 0 0 0 2px var(--line);
    touch-action: none;
}
.snakeOverlay{
    position: absolute;
    inset: auto 8px 8px;
    margin: 0;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radiusSm);
    background: var(--bgHeader);
    font-weight: 700;
    font-size: 0.875rem;
    text-align: center;
}
.snakePad{
    display: grid;
    grid-template-columns: repeat(3, 56px);
    grid-template-areas: ". up ." "left . right" ". down .";
    gap: 4px;
    justify-content: center;
    margin: var(--spaceMd) 0;
}
.snakeKey{
    height: 48px;
    border-radius: var(--radiusSm);
    background: var(--catSoft);
    color: var(--catText);
    font-size: 1.125rem;
}
.snakeKey.isUp{ grid-area: up; }
.snakeKey.isDown{ grid-area: down; }
.snakeKey.isLeft{ grid-area: left; }
.snakeKey.isRight{ grid-area: right; }
@media (hover: hover) and (pointer: fine){
    .snakePad{
        display: none;
    }
}

/* ▼ 百ます計算 */
.hmWrap{
    overflow-x: auto;
}
.hmTable{
    margin: 0 auto;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}
.hmTable th,
.hmTable td{
    width: 2.6rem;
    height: 2.6rem;
    padding: 0;
    border: 1px solid var(--lineStrong);
    text-align: center;
}
.hmTable th{
    background: var(--catSoft);
    font-weight: 700;
}
.hmTable .hmCorner{
    background: var(--catColor);
    color: var(--textOnAccent);
}
.hmInput{
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 1.05rem;
    text-align: center;
}
.hmInput:focus{
    outline: 3px solid var(--focusRing);
    outline-offset: -3px;
    background: var(--highlightSoft);
}
.hmInput.isRight{
    color: var(--success);
}
.hmInput.isWrong{
    background: var(--accentSoft);
    color: var(--danger);
}
@media (max-width: 719px){
    .hmTable th,
    .hmTable td{
        width: 2.1rem;
        height: 2.3rem;
    }
}
@media print{
    .hmTable th,
    .hmTable td{
        width: 1.4cm;
        height: 1.4cm;
    }
}

/* ▼ フラッシュ暗算 */
.flashStage{
    display: grid;
    place-items: center;
    min-height: 200px;
    border-radius: var(--radiusLg);
    background: var(--bgCode);
}
.flashNumber{
    margin: 0;
    font-size: clamp(3.5rem, 18vw, 6rem);
    font-weight: 700;
    color: var(--textOnCode);
    font-variant-numeric: tabular-nums;
}
.flashAnswer{
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spaceSm);
    justify-content: center;
    margin-top: var(--spaceMd);
}
.flashAnswer .fieldLabel{
    margin: 0;
}
.flashAnswer .inputText{
    width: 9rem;
}

/* ▼ 動き */
@keyframes gameShake{
    0%, 100%{ transform: translateX(0); }
    25%{ transform: translateX(-4px); }
    75%{ transform: translateX(4px); }
}
@media (prefers-reduced-motion: reduce){
    .memoryFace,
    .moleChar,
    .revCell::after{
        transition: none;
    }
    .ntCell.isWrong,
    .csCell.isWrong{
        animation: none;
    }
}
