.pet-game-page {
    --game-accent: #f6a13c;
    --game-accent-soft: rgba(246, 161, 60, 0.16);
    --game-ink: #35261f;
    --game-muted: #8b7568;
    --game-panel: rgba(255, 252, 247, 0.96);
    --game-radius: 24px;
}

.pet-game-page [hidden] {
    display: none !important;
}

.pet-game-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.game-title-emoji {
    display: inline-block;
    transform: translateY(2px);
}

.game-top-fullscreen {
    flex: 0 0 auto;
    border-radius: 999px;
    font-weight: 700;
}

.pet-game {
    position: relative;
}

.game-stage {
    position: relative;
    width: 100%;
    height: min(76vh, 800px);
    min-height: 520px;
    overflow: hidden;
    border-radius: var(--game-radius);
    background:
        radial-gradient(circle at 12% 16%, rgba(255, 255, 255, 0.9) 0 12%, transparent 38%),
        radial-gradient(circle at 88% 10%, rgba(255, 236, 197, 0.8) 0 10%, transparent 34%),
        radial-gradient(circle at 82% 88%, rgba(255, 205, 190, 0.55) 0 14%, transparent 42%),
        linear-gradient(155deg, #fff8ec 0%, #ffeeda 46%, #ffe2d6 100%);
    box-shadow: 0 18px 50px rgba(104, 69, 48, 0.16), inset 0 0 0 1px rgba(255, 255, 255, 0.7);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    outline: none;
    cursor: crosshair;
}

.game-stage:focus-visible {
    box-shadow: 0 0 0 4px var(--game-accent-soft), 0 18px 50px rgba(104, 69, 48, 0.16);
}

.game-stage:fullscreen,
.game-stage:-webkit-full-screen,
.game-stage.is-pseudo-fullscreen {
    width: 100vw;
    height: 100vh;
    height: 100svh;
    max-height: none;
    min-height: 0;
    border-radius: 0;
    box-shadow: none;
}

.game-stage.is-pseudo-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1080;
}

body.game-fs-lock {
    overflow: hidden;
}

#gameCanvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* ---------- HUD ---------- */
.game-hud {
    position: absolute;
    top: max(14px, env(safe-area-inset-top));
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.game-hud--left {
    left: max(14px, env(safe-area-inset-left));
    align-items: flex-start;
}

.game-hud--right {
    right: max(14px, env(safe-area-inset-right));
    align-items: flex-end;
}

.hud-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 8px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 8px 22px rgba(104, 69, 48, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.9);
}

.hud-avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--game-accent-soft);
    font-size: 1.3rem;
    line-height: 1;
}

.hud-profile-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.hud-profile-text strong {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--game-ink);
    font-size: 0.95rem;
}

.hud-profile-text small {
    color: var(--game-muted);
    font-size: 0.7rem;
}

.hud-combo {
    padding: 6px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ff8a65, var(--game-accent));
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 8px 20px rgba(246, 118, 76, 0.35);
    animation: comboPulse 0.35s ease;
}

.hud-combo strong {
    font-size: 1rem;
}

@keyframes comboPulse {
    0% { transform: scale(0.88); }
    60% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.hud-stat {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 118px;
    padding: 8px 14px 8px 10px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 8px 22px rgba(104, 69, 48, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.9);
}

.hud-stat-icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    border-radius: 12px;
    background: var(--game-accent-soft);
    color: var(--game-accent);
    font-size: 1rem;
}

.hud-stat--score .hud-stat-icon {
    background: rgba(255, 205, 60, 0.2);
    color: #e0a300;
}

.game-home-btn {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-end;
    padding: 7px 13px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--game-ink);
    font-size: 0.72rem;
    font-weight: 800;
    box-shadow: 0 8px 22px rgba(104, 69, 48, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.game-home-btn:hover {
    transform: translateY(-2px);
    background: #fff;
    color: var(--game-accent);
}

.game-home-btn:active {
    transform: scale(0.96);
}

.hud-stat-body {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}

.hud-stat-body small {
    color: var(--game-muted);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.hud-stat-body strong {
    color: var(--game-ink);
    font-size: 1.35rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.hud-stat--timer.is-warning .hud-stat-icon {
    background: rgba(255, 86, 86, 0.16);
    color: #f04545;
    animation: timerBlink 0.9s ease-in-out infinite;
}

.hud-stat--timer.is-warning .hud-stat-body strong {
    color: #f04545;
}

@keyframes timerBlink {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.score-bump {
    animation: scoreBump 0.28s ease;
}

@keyframes scoreBump {
    0% { transform: scale(1); }
    45% { transform: scale(1.28); }
    100% { transform: scale(1); }
}

/* ---------- toolbar ---------- */
.game-toolbar {
    position: absolute;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 20;
    display: flex;
    gap: 8px;
}

.game-icon-btn {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.82);
    color: var(--game-ink);
    font-size: 1.05rem;
    box-shadow: 0 8px 20px rgba(104, 69, 48, 0.14);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.game-icon-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    background: #fff;
    color: var(--game-accent);
}

.game-icon-btn:active:not(:disabled) {
    transform: scale(0.94);
}

.game-icon-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

/* ---------- overlays ---------- */
.game-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding:
        max(18px, env(safe-area-inset-top))
        max(18px, env(safe-area-inset-right))
        max(18px, env(safe-area-inset-bottom))
        max(18px, env(safe-area-inset-left));
    background: rgba(52, 35, 27, 0.38);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.game-panel {
    display: flex;
    flex-direction: column;
    width: min(820px, 100%);
    max-height: 100%;
    overflow: hidden;
    padding: 22px 26px;
    border-radius: 26px;
    background: var(--game-panel);
    box-shadow: 0 26px 70px rgba(54, 34, 24, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.9);
    animation: panelIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

.game-panel--compact {
    width: min(440px, 100%);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 117, 104, 0.35) transparent;
}

#setupForm {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
}

.setup-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 117, 104, 0.35) transparent;
}

@keyframes panelIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.game-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.game-kicker {
    display: block;
    color: var(--game-accent);
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    margin-bottom: 2px;
}

.game-panel-head h2 {
    margin: 0;
    color: var(--game-ink);
    font-size: clamp(1.4rem, 2.4vw, 1.75rem);
    font-weight: 800;
}

.game-panel-emoji {
    font-size: 2rem;
    line-height: 1;
    filter: drop-shadow(0 4px 8px rgba(104, 69, 48, 0.16));
}

.setup-section {
    padding: 10px 0;
    border-top: 1px dashed rgba(139, 117, 104, 0.24);
}

.setup-section:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.setup-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--game-ink);
    font-size: 0.86rem;
    font-weight: 800;
}

.setup-section-title > span {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--game-accent);
    color: #fff;
    font-size: 0.7rem;
}

.species-quick-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.species-quick-btn {
    padding: 3px 9px;
    border: 1px solid rgba(139, 117, 104, 0.22);
    border-radius: 999px;
    background: #fff;
    color: var(--game-muted);
    font-size: 0.66rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.species-quick-btn:hover {
    border-color: var(--game-accent);
    color: var(--game-accent);
}

.profile-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 8px;
    scrollbar-width: thin;
}

.profile-card {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 122px;
    padding: 8px 12px 8px 8px;
    border: 2px solid transparent;
    border-radius: 16px;
    background: #fff;
    color: var(--game-ink);
    text-align: left;
    box-shadow: 0 4px 14px rgba(104, 69, 48, 0.07);
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.profile-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(104, 69, 48, 0.12);
}

.profile-card.is-selected {
    border-color: var(--game-accent);
    background: linear-gradient(180deg, #fff, var(--game-accent-soft));
}

.profile-card-avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    overflow: hidden;
    border-radius: 50%;
    background: var(--game-accent-soft);
    font-size: 1.15rem;
}

.hud-avatar {
    overflow: hidden;
}

.hud-avatar img,
.profile-card-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.profile-card-info {
    display: flex;
    flex-direction: column;
    line-height: 1.12;
    min-width: 0;
}

.profile-card-info strong {
    max-width: 82px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8rem;
}

.profile-card-info small {
    color: var(--game-muted);
    font-size: 0.65rem;
    white-space: nowrap;
}

.profile-delete {
    position: absolute;
    top: -5px;
    right: -5px;
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: #ff6b6b;
    color: #fff;
    font-size: 0.65rem;
    box-shadow: 0 3px 8px rgba(255, 80, 80, 0.4);
    cursor: pointer;
}

.profile-create-row {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.profile-create-row .form-control,
.profile-create-row .form-select {
    border-radius: 12px;
    border-color: rgba(139, 117, 104, 0.26);
    font-size: 0.88rem;
}

.profile-create-row .form-control {
    flex: 1 1 160px;
    min-width: 0;
}

.profile-create-row .form-select {
    flex: 0 1 150px;
}

.profile-save-btn {
    flex: 0 0 auto;
    border-radius: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.avatar-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.avatar-upload {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px 12px;
    border: 1px dashed rgba(139, 117, 104, 0.4);
    border-radius: 10px;
    background: #fff;
    color: var(--game-ink);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.avatar-upload:hover {
    border-color: var(--game-accent);
    color: var(--game-accent);
}

.avatar-clear {
    padding: 4px 6px;
    border: 0;
    background: transparent;
    color: #d94b4b;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
}

.avatar-note {
    flex: 1 1 100%;
    color: var(--game-muted);
    font-size: 0.66rem;
    line-height: 1.45;
}

.species-picker {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.species-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 9px 6px 8px;
    border: 2px solid rgba(139, 117, 104, 0.16);
    border-radius: 16px;
    background: #fff;
    color: var(--game-ink);
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.species-btn span {
    font-size: 1.42rem;
    line-height: 1.1;
}

.species-btn:hover {
    transform: translateY(-2px);
}

.species-btn.is-selected {
    border-color: var(--game-accent);
    background: var(--game-accent-soft);
}

.target-style-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-bottom: 12px;
}

.target-style-row .color-picker {
    flex: 1 1 auto;
    margin-bottom: 0;
}

.target-style-row .size-row {
    flex: 1 1 250px;
    margin-bottom: 0;
}

.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.color-swatch {
    position: relative;
    width: 30px;
    height: 30px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(139, 117, 104, 0.22), 0 3px 8px rgba(104, 69, 48, 0.12);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.is-selected {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--game-accent), 0 3px 8px rgba(104, 69, 48, 0.16);
}

.special-targets {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
    margin-top: 12px;
}

.setup-scroll::-webkit-scrollbar {
    width: 8px;
}

.setup-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.setup-scroll::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(139, 117, 104, 0.3);
}

.setup-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 117, 104, 0.5);
}

.game-switch {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    cursor: pointer;
    user-select: none;
}

.game-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.game-switch-track {
    position: relative;
    width: 42px;
    height: 24px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: #d8cec7;
    transition: background 0.2s ease;
}

.game-switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.game-switch input:checked + .game-switch-track {
    background: var(--game-accent);
}

.game-switch input:checked + .game-switch-track::after {
    transform: translateX(18px);
}

.game-switch input:focus-visible + .game-switch-track {
    outline: 3px solid var(--game-accent-soft);
    outline-offset: 2px;
}

.game-switch-label {
    color: var(--game-ink);
    font-size: 0.82rem;
    font-weight: 700;
}

.game-switch-label small {
    color: var(--game-muted);
    font-weight: 600;
}

.speed-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.speed-label {
    flex: 0 0 auto;
    color: var(--game-ink);
    font-size: 0.82rem;
    font-weight: 700;
}

.speed-row .form-range {
    flex: 1 1 auto;
    accent-color: var(--game-accent);
}

.speed-value {
    flex: 0 0 48px;
    padding: 4px 0;
    border-radius: 10px;
    background: var(--game-accent-soft);
    color: var(--game-accent);
    font-size: 0.78rem;
    font-weight: 800;
    text-align: center;
}

.duration-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}

.duration-picker {
    display: flex;
    gap: 8px;
}

.duration-btn {
    flex: 1 1 0;
    padding: 7px 10px;
    border: 2px solid rgba(139, 117, 104, 0.16);
    border-radius: 12px;
    background: #fff;
    color: var(--game-ink);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.duration-btn.is-active {
    border-color: var(--game-accent);
    background: var(--game-accent-soft);
    color: var(--game-accent);
}

.setup-tip {
    margin: 12px 0 0;
    padding: 9px 12px;
    border-radius: 12px;
    background: rgba(246, 161, 60, 0.09);
    color: var(--game-muted);
    font-size: 0.72rem;
    line-height: 1.55;
}

.setup-actions {
    flex: 0 0 auto;
    margin-top: 2px;
    padding: 14px 0 0;
    border-top: 1px dashed rgba(139, 117, 104, 0.24);
    background: var(--game-panel);
    text-align: center;
}

.btn-start-game {
    width: 100%;
    padding: 12px 24px;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, #ffb347, var(--game-accent));
    color: #fff;
    font-size: 1.02rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    box-shadow: 0 10px 24px rgba(246, 161, 60, 0.36);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-start-game:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(246, 161, 60, 0.44);
    color: #fff;
}

.btn-start-game:active {
    transform: scale(0.98);
}

.setup-hint {
    margin: 10px 0 0;
    color: var(--game-muted);
    font-size: 0.72rem;
}

.setup-hint kbd {
    padding: 1px 5px;
    border-radius: 5px;
    background: #efe6de;
    color: var(--game-ink);
    font-size: 0.68rem;
}

/* ---------- pause / result ---------- */
.panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.panel-actions .btn {
    border-radius: 14px;
    font-weight: 700;
}

.panel-actions .btn-start-game {
    width: auto;
    flex: 1 1 100%;
}

.panel-actions .btn-outline-secondary {
    flex: 1 1 0;
    white-space: nowrap;
}

.result-score {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
    margin: 4px 0 14px;
    color: var(--game-ink);
}

.result-score strong {
    font-size: clamp(3rem, 8vw, 4.2rem);
    line-height: 1;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.result-score span {
    color: var(--game-muted);
    font-size: 1rem;
    font-weight: 700;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.result-grid > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 6px;
    border-radius: 14px;
    background: #fff;
    text-align: center;
    box-shadow: 0 4px 12px rgba(104, 69, 48, 0.06);
}

.result-grid small {
    color: var(--game-muted);
    font-size: 0.66rem;
    font-weight: 700;
}

.result-grid strong {
    color: var(--game-ink);
    font-size: 1.05rem;
    font-weight: 800;
}

.result-message {
    margin: 0 0 16px;
    color: var(--game-muted);
    font-size: 0.82rem;
    text-align: center;
}

/* ---------- countdown & toast ---------- */
.countdown-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    background: rgba(52, 35, 27, 0.18);
    pointer-events: none;
}

.countdown-number {
    display: grid;
    place-items: center;
    width: clamp(110px, 24vw, 170px);
    height: clamp(110px, 24vw, 170px);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: var(--game-accent);
    font-size: clamp(3.6rem, 10vw, 6rem);
    font-weight: 900;
    line-height: 1;
    box-shadow: 0 20px 50px rgba(54, 34, 24, 0.24);
    animation: countPop 0.7s cubic-bezier(0.18, 0.9, 0.28, 1.2);
}

@keyframes countPop {
    0% { transform: scale(0.5); opacity: 0; }
    45% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.game-toast {
    position: absolute;
    left: 50%;
    bottom: max(76px, calc(env(safe-area-inset-bottom) + 76px));
    z-index: 50;
    transform: translate(-50%, 12px);
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(53, 38, 31, 0.86);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    white-space: nowrap;
}

.game-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---------- help cards ---------- */
.game-help {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.game-help-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(104, 69, 48, 0.08);
}

.game-help-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: 13px;
    background: var(--game-accent-soft);
    color: var(--game-accent);
    font-size: 1.1rem;
}

/* ---------- responsive ---------- */
@media (min-width: 768px) {
    .color-picker {
        gap: 6px;
    }

    .color-swatch {
        width: 26px;
        height: 26px;
    }

    .species-picker {
        grid-template-columns: repeat(8, minmax(0, 1fr));
        gap: 6px;
    }

    .species-btn {
        padding: 7px 3px 6px;
        border-radius: 14px;
        font-size: 0.68rem;
    }

    .species-btn span {
        font-size: 1.22rem;
    }

    #setupForm .setup-section:nth-of-type(3) {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        column-gap: 22px;
        align-items: center;
    }

    #setupForm .setup-section:nth-of-type(3) .setup-section-title {
        grid-column: 1 / -1;
    }

    #setupForm .setup-section:nth-of-type(3) .speed-row {
        grid-column: 1;
        margin-bottom: 0;
    }

    #setupForm .setup-section:nth-of-type(3) .count-row {
        grid-column: 1;
        margin-bottom: 0;
    }

    #setupForm .setup-section:nth-of-type(3) .duration-wrap {
        grid-column: 2;
        grid-row: 2 / span 2;
        align-self: start;
        margin-top: 0;
    }

    #setupForm .setup-section:nth-of-type(3) .setup-tip {
        grid-column: 1 / -1;
    }

    #setupForm .setup-section:nth-of-type(3) .special-targets {
        grid-column: 1 / -1;
    }

    .target-style-row .size-row {
        flex: 0 1 300px;
    }
}

@media (max-height: 820px) and (min-width: 768px) {
    .setup-tip {
        display: none;
    }
}

@media (max-width: 991.98px) {
    .game-help {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767.98px) {
    .pet-game-heading {
        align-items: flex-start;
    }

    .pet-game-heading p {
        font-size: 0.9rem;
    }

    .game-top-fullscreen {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .game-stage {
        height: 70vh;
        min-height: 480px;
        border-radius: 20px;
    }

    .game-panel {
        padding: 18px;
        border-radius: 22px;
    }

    .setup-scroll {
        padding-right: 2px;
    }

    .profile-create-row {
        flex-wrap: wrap;
    }

    .profile-create-row .form-control {
        flex: 1 1 100%;
    }

    .profile-create-row .form-select {
        flex: 1 1 0;
    }

    .species-picker {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
    }

    .species-btn {
        padding: 7px 4px 6px;
        font-size: 0.7rem;
    }

    .hud-profile {
        padding: 6px 10px 6px 6px;
    }

    .hud-avatar {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }

    .hud-profile-text strong {
        max-width: 86px;
        font-size: 0.84rem;
    }

    .hud-stat {
        min-width: 96px;
        padding: 6px 10px 6px 8px;
        border-radius: 15px;
    }

    .hud-stat-icon {
        width: 27px;
        height: 27px;
        border-radius: 10px;
        font-size: 0.86rem;
    }

    .hud-stat-body strong {
        font-size: 1.1rem;
    }

    .hud-stat-body small {
        font-size: 0.56rem;
    }

    .game-home-btn {
        padding: 6px 10px;
        font-size: 0.66rem;
    }

    .game-icon-btn {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 420px) {
    .game-stage {
        height: 64vh;
        min-height: 440px;
    }

    .game-panel {
        padding: 14px;
    }

    .result-grid {
        gap: 6px;
    }

    .game-switch-label {
        font-size: 0.76rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .game-panel,
    .countdown-number,
    .hud-combo,
    .hud-stat--timer.is-warning .hud-stat-icon {
        animation: none;
    }
}
