/* You are X in the site's sky blue; the rival cat is O in its orange fur.
   Green only ever means "you can play here". */
.cat-board-game {
    --you: #6fa8ff;
    --rival: #ff8a1e;
    --legal: #6cc93a;
    --well: #0a1640;
    --paper: #eef3ff;
    --paper-ink: #0b1f5c;
}
.cat-board-game .pn-body { padding: 12px; }

/* ---- the rival: portrait + speech bubble ---- */
.rival {
    display: grid; grid-template-columns: auto 1fr; gap: 14px;
    align-items: center; margin: 0 0 12px;
}
.face {
    position: relative; display: block; flex: none;
    width: 104px; aspect-ratio: 1; border-radius: 16px;
    background: radial-gradient(circle at 50% 38%, #24407e, var(--well) 72%);
    border: 2px solid var(--rival);
    box-shadow: 0 0 0 3px #050d2e, 0 0 20px rgba(255,138,30,.35);
}
.face-img {
    display: block; width: 100%; height: 100%; object-fit: contain;
    border-radius: 14px; transition: filter .3s, transform .3s;
}
.emote {
    position: absolute; top: -10px; right: -12px;
    font-size: 26px; line-height: 1; pointer-events: none;
}
.emote:empty { display: none; }

/* Moods, while there is only a portrait to work with */
.face[data-mood="thinking"] .face-img { transform: rotate(-7deg) translateY(-2px); }
.face[data-mood="smug"] .face-img { transform: rotate(5deg) scale(1.04); }
.face[data-mood="shocked"].pop .face-img { animation: face-shake .4s; }
.face[data-mood="win"].pop .face-img { animation: face-hop .6s; }
.face[data-mood="lose"] .face-img { transform: rotate(-4deg) translateY(5px); filter: grayscale(.75) brightness(.75); }
.face.pop .emote { animation: emote-pop .35s ease-out; }

/* Moods with a sprite sheet: 3 x 2 cells, see rival.js */
.face.has-sheet {
    background: var(--sheet) 0 0 / 300% 200% no-repeat,
                radial-gradient(circle at 50% 38%, #24407e, var(--well) 72%);
}
.face.has-sheet .face-img, .face.has-sheet .emote { display: none; }
.face.has-sheet[data-mood="thinking"] { background-position: 50% 0, 0 0; }
.face.has-sheet[data-mood="smug"]     { background-position: 100% 0, 0 0; }
.face.has-sheet[data-mood="shocked"]  { background-position: 0 100%, 0 0; }
.face.has-sheet[data-mood="win"]      { background-position: 50% 100%, 0 0; }
.face.has-sheet[data-mood="lose"]     { background-position: 100% 100%, 0 0; }
.face.has-sheet.pop { animation: face-pop .25s ease-out; }

@keyframes face-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px) rotate(-3deg); }
    40% { transform: translateX(5px) rotate(3deg); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}
@keyframes face-hop {
    0%, 100% { transform: translateY(0); }
    30% { transform: translateY(-12px) rotate(-4deg); }
    55% { transform: translateY(0); }
    75% { transform: translateY(-5px) rotate(3deg); }
}
@keyframes emote-pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes face-pop { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }

.bubble {
    position: relative; margin: 0 0 8px; padding: 9px 12px;
    min-height: 3.6em; display: flex; align-items: center;
    background: var(--paper); color: var(--paper-ink);
    font: 16px/1.25 "Dos", monospace;
    border: 2px solid var(--paper-ink); border-radius: 12px;
    box-shadow: 3px 3px 0 rgba(0,0,0,.5);
}
.bubble::before, .bubble::after {
    content: ""; position: absolute; top: 50%; border-style: solid;
    border-color: transparent;
}
.bubble::before { left: -12px; margin-top: -9px; border-width: 9px 12px 9px 0; border-right-color: var(--paper-ink); }
.bubble::after  { left: -8px;  margin-top: -7px; border-width: 7px 9px 7px 0;  border-right-color: var(--paper); }

.rival-id { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.rival-name { font: 22px/1 "Arcade", sans-serif; color: var(--rival); letter-spacing: 1px; }
.rival-title { color: var(--muted); font-size: 11px; }
.conf { display: flex; align-items: center; gap: 6px; margin-left: auto; font-size: 10px; color: var(--muted); }
.conf-track { width: 64px; height: 6px; border-radius: 3px; background: var(--well); border: 1px solid var(--line); overflow: hidden; }
.conf-bar { display: block; height: 100%; width: 50%; background: var(--rival); transition: width .4s; }
.conf[hidden] { display: none; }

/* ---- scoreboard ---- */
.scorebar {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
    margin: 0 auto 10px; max-width: 420px; padding: 6px 12px;
    background: var(--well); border: 1px solid var(--line); border-radius: 8px;
}
.side { display: flex; align-items: center; gap: 8px; font: bold 12px var(--head-font); color: var(--navy); }
.side.them { justify-content: flex-end; }
.side .mark { font: 20px/1 "Arcade", sans-serif; }
.side.me .mark { color: var(--you); }
.side.them .mark { color: var(--rival); }
.side small { font: normal 10px var(--ui-font); color: var(--muted); }
.tally { display: flex; align-items: center; gap: 8px; font: 26px/1 "Arcade", sans-serif; }
.tally #tally-you { color: var(--you); }
.tally #tally-rival { color: var(--rival); }
.tally span { font: 10px var(--ui-font); color: var(--muted); }

/* ---- board ---- */
.board { position: relative; max-width: 420px; margin: 0 auto; }
.result {
    position: absolute; inset: 0; display: grid; place-content: center; justify-items: center;
    gap: 8px; padding: 16px; text-align: center; border-radius: 12px;
    background: rgba(5,13,46,.82);
}
.result[hidden] { display: none; }
.result .result-title { margin: 0; font: 40px/1 "Arcade", sans-serif; color: var(--paper); }
.result.win .result-title { color: var(--you); }
.result.loss .result-title { color: var(--rival); }
.result .result-sub { margin: 0 0 4px; font: 16px/1.3 "Dos", monospace; color: var(--ink); }

.status { margin: 8px 0 14px; min-height: 1.3em; text-align: center; font: 16px/1.3 "Dos", monospace; color: var(--muted); }
.status.you { color: var(--legal); }
.status.rival { color: var(--rival); }

/* ---- rival picker ---- */
.pick-head { margin: 0 0 6px; font: bold 12px var(--head-font); color: var(--navy); }
.rivals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rival-pick {
    display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto;
    column-gap: 8px; align-items: center; padding: 6px 8px; text-align: left;
    background: var(--well); color: var(--ink); text-shadow: none;
    border: 1px solid var(--line); border-radius: 10px;
    font: 11px/1.3 var(--ui-font); cursor: pointer;
}
.rival-pick:hover { background: #16224f; border-color: #3a5296; }
.rival-pick:is([aria-checked="true"], [aria-pressed="true"]) {
    background: #16224f; border-color: var(--rival);
    box-shadow: 0 0 0 1px var(--rival), 0 0 14px rgba(255,138,30,.3);
}
.rival-pick .face { grid-row: span 2; width: 44px; border-width: 1px; border-radius: 9px; box-shadow: none; border-color: var(--line); }
.rival-pick:is([aria-checked="true"], [aria-pressed="true"]) .face { border-color: var(--rival); }
.rival-pick .face-img { border-radius: 8px; }
.pick-name { font: bold 13px var(--head-font); color: var(--navy); align-self: end; }
.pick-meta { color: var(--muted); align-self: start; }
.pick-rec { color: var(--ink); }

.game-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-top: 12px; }
#score-display { font-size: 11px; color: var(--muted); }
#score-display a { color: var(--muted); }
#score-display a:hover { color: var(--orange); }

@media (max-width: 480px) {
    .face { width: 80px; border-radius: 13px; }
    .rival { gap: 12px; }
    .rival-pick { grid-template-columns: 1fr; grid-template-rows: auto; justify-items: center; text-align: center; row-gap: 2px; }
    .rival-pick .face { grid-row: auto; width: 40px; }
    .conf { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .face, .face *, .conf-bar { animation: none !important; transition: none !important; }
}
