* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    color: #2a2255;
    background: linear-gradient(180deg, #070b22 0%, #1b1550 50%, #3d2578 100%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Утилита скрытия: !important, чтобы не перебивалась display: grid/flex у других классов */
.hidden {
    display: none !important;
}


/* =========================
   BACKGROUND: звёздная ночь
   ========================= */

.background {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: -1;
}

/* Три слоя звёзд разного размера и скорости мерцания */
.stars {
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 50%;
    background: transparent;
    animation: twinkle 4s ease-in-out infinite;
}

.stars-s { width: 1px; height: 1px; box-shadow: 663px 1941px #fff, 308px 808px #fff, 1333px 98px #fff, 148px 1681px #fff, 1097px 192px #fff, 748px 1193px #fff, 118px 1863px #fff, 1039px 439px #fff, 76px 176px #fff, 888px 856px #fff, 143px 492px #fff, 185px 1128px #fff, 869px 121px #fff, 1693px 1158px #fff, 253px 1940px #fff, 457px 1291px #fff, 1284px 1193px #fff, 1940px 126px #fff, 1181px 1199px #fff, 812px 101px #fff, 1999px 452px #fff, 95px 1140px #fff, 1758px 272px #fff, 593px 858px #fff, 295px 1107px #fff, 241px 1169px #fff, 631px 1147px #fff, 1671px 1396px #fff, 370px 211px #fff, 1191px 1169px #fff, 1308px 384px #fff, 762px 199px #fff, 1121px 1458px #fff, 128px 1155px #fff, 122px 1267px #fff, 421px 1016px #fff, 1393px 1088px #fff, 875px 1591px #fff, 643px 953px #fff, 1199px 1891px #fff, 928px 740px #fff, 613px 508px #fff, 1626px 368px #fff, 1431px 1597px #fff, 499px 167px #fff, 1176px 614px #fff, 1075px 1013px #fff, 1792px 703px #fff, 1493px 919px #fff, 589px 1247px #fff, 149px 241px #fff, 1048px 856px #fff, 337px 1550px #fff, 700px 311px #fff, 1911px 1001px #fff, 863px 80px #fff, 1970px 1368px #fff, 158px 1565px #fff, 1142px 1173px #fff, 1616px 1792px #fff, 1675px 642px #fff, 696px 1423px #fff, 717px 1217px #fff, 1017px 1187px #fff, 1632px 934px #fff, 140px 1720px #fff, 191px 1934px #fff, 552px 970px #fff, 1427px 1360px #fff, 133px 124px #fff, 1497px 1436px #fff, 634px 1325px #fff, 1183px 1395px #fff, 1683px 912px #fff, 582px 1467px #fff, 790px 1816px #fff, 1369px 710px #fff, 46px 1926px #fff, 945px 727px #fff, 344px 1251px #fff, 239px 1011px #fff, 120px 446px #fff, 1573px 588px #fff, 264px 1512px #fff, 507px 814px #fff, 800px 1877px #fff, 1784px 1016px #fff, 165px 340px #fff, 919px 822px #fff, 1125px 569px #fff, 1809px 280px #fff, 1677px 881px #fff, 1769px 1126px #fff, 570px 1446px #fff, 850px 734px #fff, 1398px 1810px #fff, 779px 1961px #fff, 472px 309px #fff, 169px 360px #fff, 309px 475px #fff, 1348px 477px #fff, 24px 993px #fff, 1702px 1206px #fff, 373px 538px #fff, 577px 8px #fff, 298px 858px #fff, 1094px 756px #fff, 1248px 1159px #fff, 652px 1951px #fff, 257px 1414px #fff, 1759px 1055px #fff, 1946px 1264px #fff, 1341px 1384px #fff, 1515px 110px #fff, 935px 1842px #fff, 1783px 1597px #fff, 1949px 1791px #fff, 1393px 1634px #fff, 1145px 803px #fff, 815px 817px #fff, 807px 212px #fff, 986px 1299px #fff, 820px 127px #fff, 390px 137px #fff, 427px 902px #fff, 332px 225px #fff, 696px 1230px #fff, 107px 209px #fff, 0px 1160px #fff, 309px 1098px #fff, 207px 1943px #fff, 744px 1256px #fff, 52px 144px #fff, 1790px 425px #fff, 1257px 770px #fff, 304px 1299px #fff, 516px 1956px #fff, 711px 1233px #fff, 745px 971px #fff, 251px 236px #fff, 1738px 999px #fff, 954px 983px #fff, 990px 638px #fff, 175px 295px #fff, 209px 1535px #fff, 701px 1516px #fff, 542px 980px #fff, 1697px 1417px #fff, 330px 1057px #fff, 47px 420px #fff, 1947px 1949px #fff, 1081px 740px #fff, 300px 1413px #fff, 1112px 1872px #fff, 55px 1552px #fff, 1081px 610px #fff, 1316px 1768px #fff, 186px 1425px #fff, 1731px 534px #fff, 1061px 751px #fff; animation-duration: 5s; }
.stars-m { width: 2px; height: 2px; box-shadow: 1860px 342px #fff, 728px 1580px #fff, 456px 1090px #fff, 1109px 1595px #fff, 1029px 675px #fff, 1303px 456px #fff, 1255px 1661px #fff, 1614px 1553px #fff, 1746px 399px #fff, 1650px 490px #fff, 1675px 820px #fff, 1515px 1645px #fff, 464px 409px #fff, 1060px 1009px #fff, 728px 1497px #fff, 59px 57px #fff, 1618px 572px #fff, 967px 530px #fff, 396px 1418px #fff, 1239px 1958px #fff, 705px 915px #fff, 1655px 1919px #fff, 1480px 715px #fff, 1955px 1995px #fff, 746px 164px #fff, 451px 209px #fff, 464px 962px #fff, 402px 691px #fff, 418px 988px #fff, 1278px 1843px #fff, 1249px 1721px #fff, 3px 981px #fff, 1862px 1337px #fff, 704px 1637px #fff, 1317px 173px #fff, 1709px 1352px #fff, 245px 1863px #fff, 795px 1602px #fff, 1457px 1536px #fff, 408px 979px #fff, 1820px 365px #fff, 888px 1616px #fff, 1302px 680px #fff, 177px 1640px #fff, 1937px 1989px #fff, 1478px 810px #fff, 948px 822px #fff, 1522px 1939px #fff, 173px 1484px #fff, 325px 348px #fff, 260px 56px #fff, 309px 1209px #fff, 1853px 953px #fff, 1651px 1343px #fff, 299px 1252px #fff, 1692px 1220px #fff, 971px 1346px #fff, 1919px 717px #fff, 319px 1123px #fff, 1122px 268px #fff, 43px 29px #fff, 1637px 1988px #fff, 1487px 1330px #fff, 210px 1078px #fff, 1534px 1912px #fff, 285px 888px #fff, 1785px 398px #fff, 1691px 1789px #fff, 432px 57px #fff, 515px 435px #fff;  animation-duration: 3.5s; animation-delay: 1s; }
.stars-l { width: 3px; height: 3px; box-shadow: 599px 1026px #fff, 492px 1564px #fff, 1201px 667px #fff, 531px 1114px #fff, 858px 1708px #fff, 268px 124px #fff, 1863px 1515px #fff, 724px 1838px #fff, 938px 1356px #fff, 1194px 1669px #fff, 1851px 1058px #fff, 861px 1693px #fff, 1879px 1798px #fff, 1027px 267px #fff, 1089px 310px #fff, 1072px 1045px #fff, 38px 1787px #fff, 901px 1590px #fff, 375px 1246px #fff, 8px 1589px #fff, 1636px 306px #fff, 352px 289px #fff, 969px 1267px #fff, 1485px 246px #fff;  animation-duration: 2.6s; animation-delay: 0.5s; }

@keyframes twinkle {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

/* Луна с мягким свечением */
.moon {
    position: absolute;
    top: 9%;
    right: 10%;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fffdf0, #f3e9b8 60%, #d9cc8f);
    box-shadow:
        0 0 40px 10px rgba(255,245,200,0.35),
        0 0 120px 40px rgba(255,245,200,0.15);
    animation: moonGlow 6s ease-in-out infinite;
}

@keyframes moonGlow {
    0%, 100% { box-shadow: 0 0 40px 10px rgba(255,245,200,0.35), 0 0 120px 40px rgba(255,245,200,0.15); }
    50%      { box-shadow: 0 0 55px 14px rgba(255,245,200,0.5),  0 0 140px 50px rgba(255,245,200,0.22); }
}

/* Падающие звёзды: редко и в разное время */
.shooting {
    position: absolute;
    width: 140px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, rgba(255,255,255,0), #fff);
    opacity: 0;
    transform: rotate(35deg);
    animation: shoot 9s ease-in infinite;
}

.shooting.s1 { top: 8%;  left: 15%; animation-delay: 2s; }
.shooting.s2 { top: 20%; left: 55%; animation-delay: 6s;  animation-duration: 12s; }
.shooting.s3 { top: 4%;  left: 75%; animation-delay: 10s; animation-duration: 15s; }

@keyframes shoot {
    0%   { opacity: 0; transform: translate(0, 0) rotate(35deg); }
    3%   { opacity: 1; }
    10%  { opacity: 0; transform: translate(360px, 250px) rotate(35deg); }
    100% { opacity: 0; transform: translate(360px, 250px) rotate(35deg); }
}

@media (prefers-reduced-motion: reduce) {
    .stars, .moon, .shooting { animation: none; }
    .shooting { display: none; }
}


/* =========================
   SCREEN
   ========================= */

.screen {
    width: min(1050px, calc(100% - 30px));
    margin: 50px auto;
    padding: 30px;
    background: rgba(255,255,255,0.72);
    border: 1px solid rgba(255,255,255,0.9);
    border-radius: 22px;
    box-shadow:
        0 20px 60px rgba(20,10,70,0.25),
        inset 0 1px white;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}


/* =========================
   LOGO
   ========================= */

.logo {
    text-align: center;
    margin-bottom: 35px;
}

.logo-icon {
    width: 70px;
    height: 70px;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 35px;
    background: linear-gradient(145deg, #ffffff, #cdbdff);
    box-shadow:
        0 8px 20px rgba(30,15,90,0.2),
        inset 0 2px white;
}

.logo h1 {
    margin: 12px 0 4px;
    font-size: 34px;
    color: #5b3fc4;
}

.logo p {
    margin: 0;
    color: #7a6fa8;
}


/* =========================
   PET SELECTION
   ========================= */

.pet-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 300px));
    justify-content: center;
    gap: 25px;
    max-width: 1000px;
    margin: auto;
}

.pet-card {
    padding: 25px;
    text-align: center;
    background: linear-gradient(
        145deg,
        rgba(255,255,255,0.95),
        rgba(236,230,255,0.85)
    );
    border: 2px solid rgba(140,110,230,0.4);
    border-radius: 18px;
    transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
    box-shadow: 0 8px 20px rgba(30,15,90,0.12);
}

.pet-card:hover {
    transform: translateY(-6px);
    border-color: #8b6cf0;
    box-shadow: 0 15px 30px rgba(30,15,90,0.2);
}

.pet-image {
    height: 230px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

.pet-image img {
    max-width: 100%;
    max-height: 220px;
    object-fit: contain;
    image-rendering: auto;
}

.pet-card h2 {
    margin: 10px 0 15px;
    color: #5b3fc4;
}


/* =========================
   BUTTON
   ========================= */

.select-button,
#change-pet,
#start-button {
    border: 0;
    padding: 11px 25px;
    border-radius: 10px;
    color: white;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    background: linear-gradient(180deg, #a58bff, #5b3fd1);
    box-shadow:
        inset 0 1px rgba(255,255,255,0.8),
        0 4px 10px rgba(30,15,90,0.2);
    transition: filter 0.2s, transform 0.2s;
}

.select-button:hover,
#change-pet:hover,
#start-button:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}


/* =========================
   PET SCREEN
   ========================= */

.pet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.pet-header h1 {
    margin: 0;
    color: #5b3fc4;
}

.pet-header p {
    margin: 5px 0 0;
    color: #7a6fa8;
}


/* =========================
   PET
   ========================= */

.pet-area {
    text-align: center;
    padding: 20px;
}

.pet-display {
    position: relative;
    width: 350px;
    max-width: 100%;
    height: 300px;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pet-display img {
    position: relative;
    z-index: 2;
    max-width: 320px;
    max-height: 280px;
    object-fit: contain;
    animation: petFloat 3s ease-in-out infinite;
}

.pet-glow {
    position: absolute;
    width: 230px;
    height: 90px;
    bottom: 20px;
    border-radius: 50%;
    background: rgba(150,110,255,0.22);
    filter: blur(15px);
}

@keyframes petFloat {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

#pet-message {
    margin: 5px 0 20px;
    color: #5b4aa8;
}


/* =========================
   STATS
   ========================= */

.stats {
    max-width: 650px;
    margin: auto;
    display: grid;
    gap: 13px;
}

.stat {
    background: rgba(255,255,255,0.65);
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(140,120,220,0.3);
}

.stat-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: bold;
}

.progress {
    height: 12px;
    background: #ddd5f5;
    border-radius: 20px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 80%;
    border-radius: 20px;
    background: linear-gradient(90deg, #a98bff, #6a49e0);
    transition: width 0.4s;
}


/* =========================
   ACTIONS
   ========================= */

.actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 650px;
    margin: 25px auto 15px;
}

.actions button {
    padding: 14px 8px;
    border: 1px solid #b9a6f0;
    border-radius: 12px;
    cursor: pointer;
    color: #4a3a9a;
    font-weight: bold;
    font-family: inherit;
    background: linear-gradient(180deg, #ffffff, #ece6ff);
    box-shadow: 0 4px 10px rgba(30,15,90,0.12);
    transition: transform 0.2s, background 0.2s;
}

.actions button:hover {
    transform: translateY(-2px);
    background: linear-gradient(180deg, #ffffff, #d9ceff);
}

.actions button span {
    display: block;
    margin-top: 5px;
}


/* =========================
   COINS
   ========================= */

.coins {
    text-align: center;
    margin-top: 20px;
    font-size: 18px;
    font-weight: bold;
    color: #5b4aa8;
}


/* =========================
   MOBILE
   ========================= */

@media (max-width: 700px) {

    .screen {
        margin: 15px auto;
        padding: 20px;
    }

    .pet-selection {
        grid-template-columns: 1fr;
    }

    .pet-display {
        width: 100%;
        height: 250px;
    }

    .actions {
        grid-template-columns: repeat(3, 1fr);
    }

    .pet-header {
        align-items: flex-start;
        gap: 15px;
    }

    #change-pet {
        padding: 9px 12px;
        font-size: 11px;
    }
}


/* =========================
   ИМЯ ПИТОМЦА
   ========================= */

.name-box {
    max-width: 420px;
    margin: auto;
    text-align: center;
}

.name-preview img {
    max-width: 100%;
    max-height: 220px;
    border-radius: 18px;
    object-fit: contain;
}

.name-box h2 {
    margin: 15px 0 5px;
    color: #5b3fc4;
}

.name-box p {
    margin: 0 0 15px;
    color: #7a6fa8;
}

#name-input {
    width: 100%;
    margin-bottom: 18px;
    padding: 13px 16px;
    font: inherit;
    font-size: 18px;
    text-align: center;
    color: #2a2255;
    background: rgba(255,255,255,0.9);
    border: 2px solid rgba(140,110,230,0.5);
    border-radius: 12px;
    outline: none;
}

#name-input:focus {
    border-color: #8b6cf0;
    box-shadow: 0 0 0 3px rgba(59,184,234,0.25);
}

/* =========================
   НАСТРОЕНИЕ И РЕАКЦИИ
   ========================= */

.mood {
    display: inline-block;
    margin-bottom: 10px;
    padding: 6px 18px;
    font-weight: bold;
    color: #4a3a9a;
    background: rgba(255,255,255,0.85);
    border: 1px solid rgba(140,120,220,0.5);
    border-radius: 20px;
}

.mood.happy { color: #1a8a4a; border-color: #7fd9a3; }
.mood.sad   { color: #4a6fa5; border-color: #9db8e0; }
.mood.sleepy{ color: #7a5fb0; border-color: #c2b0e6; }
.mood.angry { color: #c0392b; border-color: #f0a79f; }

.pet-display img {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.pet-display img.poke {
    animation: pokeJump 0.35s ease-out;
}

@keyframes pokeJump {
    0%   { transform: translateY(0) scale(1); }
    40%  { transform: translateY(-18px) scale(1.05); }
    100% { transform: translateY(0) scale(1); }
}

.progress-fill.low {
    background: linear-gradient(90deg, #ffb27a, #e8553d);
}


/* =========================
   ВКЛАДКИ
   ========================= */

.tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(140,120,220,0.35);
}

.tab {
    padding: 10px 16px;
    font: inherit;
    font-weight: bold;
    color: #4a3a9a;
    cursor: pointer;
    background: rgba(255,255,255,0.7);
    border: 1px solid #b9a6f0;
    border-radius: 10px;
}

.tab.active {
    color: white;
    background: linear-gradient(180deg, #a58bff, #5b3fd1);
    border-color: transparent;
}

.tabs .coins {
    margin: 0 0 0 auto;
}

.section-title {
    margin: 22px 0 10px;
    text-align: center;
    color: #5b3fc4;
}

/* =========================
   ЕДА И МАГАЗИН
   ========================= */

.food-img {
    position: relative;
    width: 100%;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 44px;
    overflow: hidden;
    border-radius: 10px;
}

.food-img img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.shop-list,
.inv-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    max-width: 650px;
    margin: auto;
}

.shop-item,
.inv-item {
    padding: 12px;
    text-align: center;
    background: rgba(255,255,255,0.75);
    border: 1px solid rgba(140,120,220,0.4);
    border-radius: 14px;
}

.shop-item h3 { margin: 10px 0 4px; color: #5b3fc4; font-size: 16px; }
.shop-item p { margin: 0 0 4px; font-size: 13px; }
.shop-item small { display: block; margin-bottom: 10px; color: #7a6fa8; }

.buy,
.small-btn {
    padding: 9px 14px;
    font: inherit;
    font-weight: bold;
    color: white;
    cursor: pointer;
    background: linear-gradient(180deg, #a58bff, #5b3fd1);
    border: 0;
    border-radius: 10px;
}

.buy { width: 100%; }

.buy:disabled {
    cursor: not-allowed;
    filter: grayscale(0.8);
    opacity: 0.55;
}

.inv-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font: inherit;
    color: #4a3a9a;
    cursor: pointer;
}

.inv-item:hover { background: #fff; }
.inv-item .food-img { height: 60px; font-size: 32px; }
.inv-empty { grid-column: 1 / -1; margin: 0; text-align: center; color: #7a6fa8; }

/* =========================
   ИГРЫ
   ========================= */

.games-menu {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 15px;
    max-width: 650px;
    margin: auto;
}

.game-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 22px 12px;
    font: inherit;
    color: #4a3a9a;
    cursor: pointer;
    background: linear-gradient(145deg, rgba(255,255,255,0.95), rgba(236,230,255,0.85));
    border: 2px solid rgba(140,110,230,0.4);
    border-radius: 16px;
    transition: transform 0.2s;
}

.game-card:hover { transform: translateY(-4px); border-color: #8b6cf0; }
.game-card span { font-size: 42px; }
.game-card small { color: #7a6fa8; }

.game-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 380px;
    margin: 0 auto 12px;
    font-weight: bold;
}

.game-board { text-align: center; }

.game-board canvas {
    display: block;
    max-width: 100%;
    margin: auto;
    border: 2px solid #b9a6f0;
    border-radius: 12px;
    touch-action: none;
}

.pad {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
}

.pad button {
    width: 50px;
    height: 46px;
    font-size: 18px;
    cursor: pointer;
    color: #4a3a9a;
    background: linear-gradient(180deg, #fff, #ece6ff);
    border: 1px solid #b9a6f0;
    border-radius: 10px;
}

.game-info {
    max-width: 420px;
    margin: 14px auto 0;
    text-align: center;
    color: #5b4aa8;
}

.game-info .small-btn { margin-left: 6px; }

.memory {
    display: grid;
    grid-template-columns: repeat(4, 70px);
    gap: 8px;
    justify-content: center;
}

.mem-card {
    height: 70px;
    font-size: 30px;
    cursor: pointer;
    background: linear-gradient(180deg, #ffffff, #ece6ff);
    border: 1px solid #b9a6f0;
    border-radius: 12px;
}

.mem-card.open { background: #fff7d6; }
.mem-card.done { background: #d4f5df; border-color: #7fd9a3; }

/* =========================
   УВЕДОМЛЕНИЕ
   ========================= */

.toast {
    position: fixed;
    left: 50%;
    bottom: 30px;
    padding: 12px 22px;
    font-weight: bold;
    color: white;
    pointer-events: none;
    background: rgba(50,30,120,0.92);
    border-radius: 25px;
    opacity: 0;
    transform: translate(-50%, 20px);
    transition: opacity 0.25s, transform 0.25s;
}

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


/* =========================
   ВИДЕО И ПЕРЕЗАРЯДКА
   ========================= */

.pet-display video {
    position: relative;
    z-index: 2;
    max-width: 320px;
    max-height: 280px;
    object-fit: contain;
    cursor: pointer;
    animation: petFloat 3s ease-in-out infinite;
}

.pet-display video.poke {
    animation: pokeJump 0.35s ease-out;
}

.actions button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
    filter: grayscale(0.6);
    transform: none;
}

.actions button:disabled:hover {
    transform: none;
    background: linear-gradient(180deg, #ffffff, #ece6ff);
}


/* =========================
   ШАПКА, ВОЗРАСТ, ЗВУК
   ========================= */

.header-btns {
    display: flex;
    align-items: center;
    gap: 8px;
}

#sound-toggle {
    border: 0;
    padding: 9px 13px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 10px;
    background: linear-gradient(180deg, #a58bff, #5b3fd1);
    box-shadow: inset 0 1px rgba(255,255,255,0.8), 0 4px 10px rgba(30,15,90,0.2);
}

.age-line {
    margin: -2px 0 10px;
    font-size: 13px;
    font-weight: bold;
    color: #7a6fa8;
}

/* =========================
   БОЛЕЗНЬ
   ========================= */

.mood.sick { color: #2f8a4f; border-color: #9fd89a; }

.pet-display.sick img,
.pet-display.sick video {
    filter: saturate(0.55) hue-rotate(50deg) brightness(0.93);
}

.pet-display.sick::after {
    content: "🤒";
    position: absolute;
    top: 6px;
    right: 24px;
    z-index: 3;
    font-size: 40px;
    animation: sickWobble 1.8s ease-in-out infinite;
}

@keyframes sickWobble {
    0%, 100% { transform: rotate(-8deg); }
    50%      { transform: rotate(8deg) translateY(-4px); }
}

/* =========================
   ВКЛАДКИ: ТОЧКА-УВЕДОМЛЕНИЕ
   ========================= */

.tab { position: relative; }

.tab.dot::after {
    content: "";
    position: absolute;
    top: -4px;
    right: -4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff5a6a;
    border: 2px solid #fff;
}

/* =========================
   ЕЖЕДНЕВНАЯ НАГРАДА
   ========================= */

.daily-head {
    margin: 0 0 14px;
    text-align: center;
    font-weight: bold;
    color: #5b4aa8;
}

.daily-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 8px;
    max-width: 650px;
    margin: 0 auto 18px;
}

.day {
    padding: 8px 4px;
    text-align: center;
    font-size: 12px;
    color: #4a3a9a;
    background: rgba(255,255,255,0.75);
    border: 1px solid rgba(140,120,220,0.4);
    border-radius: 12px;
}

.day b { display: block; font-size: 16px; }
.day.mid { background: #fff4d6; }
.day.big { background: #ffe3cc; }
.day.claimed { opacity: 0.55; background: #d9f2e0; border-color: #7fd9a3; }

.day.today {
    border: 2px solid #8b6cf0;
    box-shadow: 0 0 0 4px rgba(139,108,240,0.25);
}

.buy.big {
    display: block;
    width: auto;
    min-width: 220px;
    margin: 0 auto;
    padding: 12px 24px;
}

/* =========================
   ДОСТИЖЕНИЯ
   ========================= */

.ach-head {
    margin: 0 0 14px;
    text-align: center;
    font-weight: bold;
    color: #5b4aa8;
}

.ach-list {
    display: grid;
    gap: 10px;
    max-width: 650px;
    margin: auto;
}

.ach {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255,255,255,0.7);
    border: 1px solid rgba(140,120,220,0.35);
    border-radius: 14px;
}

.ach.done { background: rgba(255,248,214,0.9); border-color: #f0cf6a; }

.ach-icon { width: 40px; font-size: 30px; text-align: center; }
.ach-body { flex: 1; min-width: 0; }
.ach-body b { display: block; color: #4a3a9a; }
.ach-body small { display: block; margin: 2px 0 6px; color: #7a6fa8; }
.progress.small { height: 8px; }

.ach-side {
    text-align: right;
    font-size: 14px;
    font-weight: bold;
    color: #4a3a9a;
    white-space: nowrap;
}

.ach-side span { display: block; font-size: 12px; font-weight: normal; color: #7a6fa8; }


/* =========================
   СКИНЫ
   ========================= */

.skins-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    max-width: 650px;
    margin: auto;
}

.skin-item {
    padding: 12px;
    text-align: center;
    background: rgba(255,255,255,0.75);
    border: 1px solid rgba(140,120,220,0.4);
    border-radius: 14px;
}

.skin-item.worn {
    border: 2px solid #8b6cf0;
    box-shadow: 0 0 0 3px rgba(139,108,240,0.2);
}

/* картинка 1:1; пока файла нет, показывается шляпа */
.skin-img {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 56px;
    background: linear-gradient(145deg, #ece6ff, #d9ceff);
    border-radius: 12px;
}

.skin-img img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.skin-item h3 { margin: 10px 0 2px; font-size: 16px; color: #5b3fc4; }
.skin-item small { display: block; margin-bottom: 10px; color: #7a6fa8; }

.buy.alt {
    color: #4a3a9a;
    background: linear-gradient(180deg, #ffffff, #e0d6ff);
    border: 1px solid #b9a6f0;
}

/* =========================
   БАЗА ДЛЯ МОБИЛЬНОЙ ВЕРСИИ
   ========================= */

button {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.header-coins { display: none; }

.tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tab i { font-style: normal; }

/* длинные уведомления не сжимаются в узкую колонку */
.toast {
    width: max-content;
    max-width: 90vw;
    text-align: center;
}

/* =========================
   МОБИЛЬНАЯ ВЕРСИЯ (телефоны)
   ========================= */

@media (max-width: 700px) {

    /* место под нижнюю панель */
    body { padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }

    /* backdrop-filter ломает position: fixed внутри, поэтому на телефоне его нет */
    .screen {
        width: calc(100% - 16px);
        margin: 8px auto;
        padding: 14px 12px;
        border-radius: 18px;
        background: rgba(255,255,255,0.94);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    /* ---- Экран выбора питомца: по 2 в ряд ---- */
    .logo { margin-bottom: 16px; }
    .logo-icon { width: 52px; height: 52px; font-size: 26px; }
    .logo h1 { font-size: 26px; }

    .pet-selection { grid-template-columns: 1fr 1fr; gap: 12px; }
    .pet-card { padding: 12px; }
    .pet-image { height: 140px; margin-bottom: 8px; }
    .pet-image img { max-height: 130px; }
    .pet-card h2 { margin: 6px 0 10px; font-size: 16px; }
    .select-button { padding: 9px 18px; }

    /* ---- Шапка в одну строку ---- */
    .pet-header { align-items: center; gap: 8px; margin-bottom: 10px; }
    .pet-header h1 { font-size: 20px; line-height: 1.1; }
    .pet-header p { margin: 2px 0 0; font-size: 12px; }
    .header-btns { gap: 6px; }

    .header-coins {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 6px 10px;
        font-size: 14px;
        font-weight: bold;
        color: #4a3a9a;
        background: rgba(255,255,255,0.9);
        border: 1px solid #b9a6f0;
        border-radius: 20px;
    }

    #sound-toggle { padding: 7px 10px; font-size: 14px; }
    #change-pet { padding: 8px 10px; font-size: 12px; }
    .hide-sm { display: none; }
    .tabs .coins { display: none; }

    /* ---- Нижняя панель вкладок ---- */
    .tabs {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        gap: 2px;
        margin: 0;
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
        background: rgba(255,255,255,0.96);
        border-top: 1px solid rgba(140,120,220,0.35);
        border-bottom: 0;
        box-shadow: 0 -4px 16px rgba(20,10,70,0.18);
    }

    .tab {
        flex-direction: column;
        justify-content: center;
        gap: 2px;
        padding: 6px 1px;
        font-size: 9.5px;
        border: 0;
        border-radius: 12px;
        background: transparent;
    }

    .tab i { font-size: 20px; line-height: 1; }
    .tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .tab.active { color: #fff; background: linear-gradient(180deg, #a58bff, #5b3fd1); }
    .tab.dot::after { top: 2px; right: 20%; }

    .toast { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }

    /* ---- Экран питомца: всё главное видно сразу ---- */
    #view-home { display: flex; flex-direction: column; }
    #view-home > * { width: 100%; }
    #view-home .pet-area { order: 0; }
    #view-home .stats    { order: 1; }
    #view-home .actions  { order: 2; }
    #view-home .section-title { order: 3; }
    #view-home .inv-list { order: 4; }

    .pet-area { padding: 2px 0 8px; }
    .mood { margin-bottom: 4px; padding: 4px 14px; font-size: 13px; }
    .age-line { margin: 0 0 6px; font-size: 11px; }

    /* картинка подстраивается под высоту экрана и не налезает на текст */
    .pet-display { width: 100%; height: auto; min-height: 0; }
    .pet-display img,
    .pet-display video {
        max-width: 100%;
        max-height: 34vh;
        max-height: 34svh;
    }
    .pet-glow { width: 60%; bottom: 6px; }

    #pet-message {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 2.6em;
        margin: 8px 0 4px;
        font-size: 16px;
    }

    /* статы 2×2 */
    .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat { padding: 7px 10px; }
    .stat-top { margin-bottom: 5px; font-size: 12px; }
    .progress { height: 9px; }

    .actions { gap: 8px; margin: 12px auto 4px; }
    .actions button { padding: 10px 4px; font-size: 13px; }

    .section-title { margin: 14px 0 8px; font-size: 15px; }

    /* рюкзак — лента, которую листают пальцем вбок */
    .inv-list {
        display: flex;
        gap: 10px;
        padding-bottom: 6px;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
    }
    .inv-item { flex: 0 0 104px; scroll-snap-align: start; }
    .inv-empty { flex: 1; }

    /* ---- Магазин, игры, награды, достижения ---- */
    .shop-list { grid-template-columns: 1fr 1fr; gap: 10px; }
    .skins-list { grid-template-columns: 1fr 1fr; gap: 10px; }
    .skin-item { padding: 10px; }
    .skin-item .buy { padding: 9px 4px; font-size: 13px; white-space: nowrap; }

    .games-menu { grid-template-columns: 1fr 1fr; gap: 10px; }
    .game-card { padding: 16px 8px; text-align: center; }
    .game-card small { font-size: 11px; }

    .game-top { max-width: none; }
    .game-board canvas { max-height: 48vh; max-height: 48svh; width: auto; }
    .pad { gap: 6px; }
    .pad button { width: 52px; height: 52px; font-size: 20px; }
    .game-info { font-size: 13px; }

    .daily-grid { grid-template-columns: repeat(5, 1fr); gap: 6px; }
    .day { padding: 6px 2px; font-size: 11px; }
    .day b { font-size: 14px; }

    .ach { gap: 10px; padding: 8px 10px; }
    .ach-icon { width: 32px; font-size: 26px; }
}
