@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;800;900&display=swap');

:root {
    --sand: #e9c25c;          /* золото храмовых рам */
    --sand-light: #fbeec2;    /* свет лампы на золоте */
    --sand-dark: #9a7a20;

    /* Сердолик -- основное действие. Тёмный низ держит контраст белого текста,
       светлый верх даёт яркость на лазуритовом фоне. */
    --carnelian-light: #f5a25f;
    --carnelian: #e2703c;
    --carnelian-deep: #b8431f;
    --carnelian-dark: #7d2a12;
    --carnelian-rgb: 226, 112, 60;

    /* Фаянс -- второстепенное действие и панели. */
    --faience-light: #7fd4cf;
    --faience: #3fa39c;
    --faience-deep: #226f6b;
    --faience-dark: #14514e;

    --nile: #3fa39c;          /* бирюза фаянса */
    --nile-dark: #14514e;
    --brick: #b8431f;         /* обожжённая охра */
    --bg-dark: #14203f;
    --bg-panel: rgba(20, 32, 62, 0.94);
    --bg-overlay: rgba(11, 19, 38, 0.82);
    --panel: rgba(18, 30, 58, 0.88);
    --panel-solid: rgba(26, 40, 74, 0.85);
    --text: #f7efdf;
    --text-dim: rgba(247, 239, 223, 0.62);
    --border: rgba(233, 194, 92, 0.34);
    --border-bright: rgba(233, 194, 92, 0.75);
    /* Рамки кнопок -- всегда с альфой 1: полупрозрачная рамка на кнопке
       читается как недоступная, а на светлом фоне пропадает совсем. */
    --btn-border: rgba(233, 194, 92, 1);
    --btn-border-bright: rgba(251, 238, 194, 1);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0e1730;
    font-family: 'Inter', sans-serif;
    color: var(--text);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    overscroll-behavior: none;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    background: #16233f;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--carnelian);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Game wrapper & board */
#game-wrapper {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#game-board {
    position: absolute;
    width: 960px;
    height: 540px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transform-origin: center center;
    background: linear-gradient(180deg, #1d2c56 0%, #0f1930 100%);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.scene {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

#scene-game {
    pointer-events: none;
}

#scene-game>* {
    pointer-events: auto;
}

/* MAIN MENU */
#scene-menu {
    background:
        linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.5)),
        url('../assets/egypt-cover-v1.webp') center/cover no-repeat;
}



.menu-title {
    font-size: 40px;
    font-weight: 900;
    letter-spacing: 1px;
    text-align: center;
    line-height: 1.1;
    background: linear-gradient(180deg, #f5e0a0 0%, #e8c36a 45%, #8a6a1a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 18px rgba(232, 195, 106, 0.6)) drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.9));
    margin-bottom: 40px;
    /* Двухчастное название длиннее прежнего: без рамки английский вариант
       («Ancient Egypt: The Feather of Truth») упирался в борта поля. */
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
    text-wrap: balance;
}

.menu-subtitle {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 3px;
    text-align: center;
    margin-bottom: 36px;
    color: #f3e2bd;
    filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.9));
}

/* BUTTONS */
.btn {
    min-width: 200px;
    padding: 13px 28px;
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1px;
    border: 2px solid var(--btn-border);
    color: var(--text);
    cursor: pointer;
    margin: 6px;
    transition: all 0.15s ease;
}

.btn-primary {
    background: linear-gradient(180deg, var(--carnelian) 0%, var(--carnelian-deep) 100%);
    border-color: var(--btn-border-bright);
    /* Тень под текстом обязательна: белый по светлой розе иначе теряется. */
    text-shadow: 0 1px 2px rgba(86, 30, 10, 0.6);
    box-shadow: 0 0 22px rgba(var(--carnelian-rgb), 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-primary:hover {
    background: linear-gradient(180deg, var(--carnelian-light) 0%, #c25423 100%);
    box-shadow: 0 0 34px rgba(var(--carnelian-rgb), 0.5);
    transform: scale(1.04);
}

.btn-secondary {
    background: linear-gradient(180deg, rgba(63, 163, 156, 0.86) 0%, rgba(23, 90, 88, 0.94) 100%);
    text-shadow: 0 1px 2px rgba(6, 38, 40, 0.55);
}

.btn-secondary:hover {
    background: linear-gradient(180deg, rgba(122, 205, 199, 0.94) 0%, rgba(34, 111, 107, 0.96) 100%);
    box-shadow: 0 0 24px rgba(63, 163, 156, 0.45);
    transform: scale(1.03);
}

.btn:active {
    transform: scale(0.97) !important;
}

.btn-back {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 40px;
    height: 40px;
    padding: 8px;
    border: 2px solid var(--btn-border);
    border-radius: 10px;
    background: linear-gradient(180deg, var(--faience) 0%, var(--faience-dark) 100%);
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-back svg {
    width: 22px;
    height: 22px;
    color: #f5e6c8;
}

.btn-back:hover {
    background: linear-gradient(180deg, var(--faience-light) 0%, var(--faience-deep) 100%);
    transform: scale(1.08);
}

.btn-back:active {
    transform: scale(0.95) !important;
}

.scene-header {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
    margin: 0;
    padding: 12px 0 8px;
}

/* LEVELS GRID */
#scene-levels {
    background:
        linear-gradient(rgba(12, 22, 44, 0.62), rgba(12, 22, 44, 0.62)),
        url('../assets/menubg.webp') center/cover no-repeat;
    justify-content: flex-start;
    padding-top: 8px;
}

#levels-grid {
    display: grid;
    grid-template-columns: repeat(5, 152px);
    grid-template-rows: repeat(4, 88px);
    gap: 10px;
    justify-content: center;
}

.level-card {
    position: relative;
    width: 152px;
    height: 80px;
    border: 2px solid #3c5c86;
    border-radius: 10px;
    background: var(--panel-solid);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 12px 10px 6px;
    gap: 2px;
    text-align: center;
    overflow: hidden;
}

.level-card:hover {
    border-color: var(--sand);
    transform: scale(1.04);
}

.level-card.locked {
    opacity: 0.3;
    cursor: default;
}

.level-card.locked:hover {
    border-color: #3c5c86;
    transform: none;
}

.level-card.current {
    border-color: var(--carnelian);
    box-shadow: 0 0 14px rgba(var(--carnelian-rgb), 0.55);
}

.level-card.boss {
    border-color: #e8663a;
    background: rgba(112, 44, 22, 0.85);
}

.level-num {
    font-size: 16px;
    color: var(--sand);
    font-weight: 800;
    line-height: 1.2;
}

.level-name {
    font-size: 10px;
    color: #fff;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
    line-height: 1.2;
    max-width: 100%;
    word-wrap: break-word;
    text-align: center;
}

.level-stars {
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1px;
}

.level-stars .star {
    color: var(--sand);
    font-size: 8px;
}

.level-stars .star.empty {
    color: #4a3f28;
}

/* DIARY */
#scene-diary {
    background:
        linear-gradient(rgba(12, 22, 44, 0.62), rgba(12, 22, 44, 0.62)),
        url('../assets/menubg.webp') center/cover no-repeat;
}

.diary-book {
    display: flex;
    width: 860px;
    height: 400px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), inset 0 0 0 2px rgba(180, 140, 80, 0.2);
}

.diary-page {
    flex: 1;
    padding: 28px 24px;
    position: relative;
    overflow-y: auto;
}

.diary-page-left {
    background: linear-gradient(135deg, #f5e6c8 0%, #e8d5a8 50%, #dcc898 100%);
    color: #2a1a08;
    border-right: none;
    display: flex;
    flex-direction: column;
}

.diary-spine {
    width: 16px;
    background: linear-gradient(90deg, #8a6a3a, #a0804a, #8a6a3a);
    box-shadow: inset 2px 0 4px rgba(0, 0, 0, 0.3), inset -2px 0 4px rgba(0, 0, 0, 0.3);
}

.diary-page-right {
    background: linear-gradient(225deg, #f5e6c8 0%, #e8d5a8 50%, #dcc898 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.diary-chapter {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #8a6a3a;
    margin-bottom: 4px;
}

.diary-level-name {
    font-size: 20px;
    font-weight: 900;
    color: #3a2a10;
    margin-bottom: 14px;
    border-bottom: 2px solid rgba(138, 106, 58, 0.3);
    padding-bottom: 10px;
}

.diary-text {
    font-size: 14px;
    line-height: 1.7;
    color: #3a2a10;
    font-style: italic;
}

.diary-text .diary-speaker {
    font-weight: 800;
    font-style: normal;
    color: #5a3a10;
    display: block;
    margin-top: 10px;
}

.diary-text .diary-speaker:first-child {
    margin-top: 0;
}

.diary-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid rgba(138, 106, 58, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.diary-locked {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.diary-locked.show {
    display: flex;
}

.diary-lock-icon {
    font-size: 48px;
    margin-bottom: 12px;
    filter: grayscale(0.5);
}

.diary-lock-msg {
    font-size: 16px;
    font-weight: 700;
    color: #8a6a3a;
    margin-bottom: 16px;
}

.diary-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 14px;
}

.diary-page-num {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
    min-width: 100px;
    text-align: center;
}

.diary-play-btn {
    margin-top: 16px;
    align-self: center;
}

.btn-sm {
    min-width: 120px;
    padding: 8px 16px;
    font-size: 13px;
}

/* STORY SCREEN */
#scene-story {
    background: linear-gradient(180deg, #16254a 0%, #22376a 50%, #16254a 100%);
}

.story-box {
    width: 860px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.story-image {
    width: 720px;
    height: 320px;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid rgba(233, 194, 92, 0.34);
    background: var(--panel);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.story-text-area {
    width: 720px;
    min-height: 80px;
    background: rgba(18, 30, 58, 0.92);
    border: 1px solid rgba(233, 194, 92, 0.24);
    border-radius: 10px;
    padding: 14px 20px;
}

.story-speaker {
    font-size: 14px;
    font-weight: 800;
    color: var(--sand);
    margin-bottom: 6px;
}

.story-text {
    font-size: 14px;
    line-height: 1.5;
    color: #f2e7d3;
}

.story-buttons {
    display: flex;
    gap: 12px;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 38px;
    background: linear-gradient(180deg, rgba(22, 36, 68, 0.95), rgba(14, 24, 46, 0.88));
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 16px;
    border-bottom: 1px solid rgba(233, 194, 92, 0.3);
    z-index: 10;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 16px;
    font-weight: 700;
}

.hud-icon {
    font-size: 18px;
}

.hud-icon-moves {
    color: #6ab4e8;
}

.hud-icon-score {
    color: var(--sand);
}

#hud-level-name {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
    pointer-events: none;
    white-space: nowrap;
}

.hud-right {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.hud-btn {
    padding: 4px 10px;
    background: rgba(34, 111, 107, 0.75);
    border: 1px solid var(--btn-border);
    border-radius: 5px;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.hud-btn-help {
    /* Справка должна находиться взглядом сразу: её ищут в момент растерянности. */
    font-size: 14px;
    line-height: 1;
    padding: 4px 11px;
    color: var(--sand-light);
    border-color: var(--btn-border-bright);
}

.hud-btn:hover {
    background: rgba(63, 163, 156, 0.85);
    border-color: var(--border-bright);
}

/* GOALS BAR */
#goals-bar {
    position: absolute;
    top: 42px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 10;
}

.goal-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--panel);
    border: 1px solid rgba(233, 194, 92, 0.26);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
}

.goal-item.done {
    opacity: 0.5;
    text-decoration: line-through;
}

.goal-icon {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: rgba(127, 212, 207, 0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* RESULT */
#scene-result {
    background: var(--bg-overlay);
}

.result-title {
    font-size: 40px;
    font-weight: 900;
    letter-spacing: 2px;
    background: linear-gradient(180deg, #f5e0a0 0%, #e8c36a 50%, #8a6a1a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.result-title.defeat {
    background: linear-gradient(180deg, #f7b083 0%, #e0663a 50%, #8a3312 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#result-stars {
    display: flex;
    gap: 8px;
    font-size: 40px;
    margin-bottom: 10px;
}

#result-stars .star-full {
    color: var(--sand);
}

#result-stars .star-empty {
    color: #4a3f28;
}

#result-subtitle {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 16px;
}

.result-buttons {
    display: flex;
    gap: 12px;
}

/* PAUSE */
#scene-pause {
    background: var(--bg-overlay);
}

.pause-title {
    font-size: 36px;
    font-weight: 900;
    color: #fff;
    margin-bottom: 20px;
}

/* BOSS HP BAR */
#boss-bar {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 20px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid var(--carnelian-dark);
    border-radius: 10px;
    overflow: hidden;
    z-index: 15;
    display: none;
}

#boss-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--carnelian-deep), var(--carnelian-light));
    transition: width 0.3s ease;
    border-radius: 8px;
}

#boss-bar-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* TUTORIAL TIP */
#tip-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 18, 36, 0.74);
    animation: tipFade 0.22s ease;
}

@keyframes tipFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes tipPop {
    from { transform: scale(0.9); }
    to { transform: scale(1); }
}

.tip-card {
    width: 580px;
    background: linear-gradient(180deg, rgba(26, 42, 78, 0.98) 0%, rgba(16, 26, 50, 0.99) 100%);
    border: 2px solid var(--btn-border);
    border-radius: 14px;
    padding: 18px 22px 16px;
    box-shadow: 0 16px 52px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.14);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 11px;
    animation: tipPop 0.26s cubic-bezier(0.2, 1.4, 0.5, 1);
}

.tip-head {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
}

.tip-icon {
    width: 58px;
    height: 58px;
    flex-shrink: 0;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-bright);
    overflow: hidden;
}

.tip-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tip-speaker {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--carnelian-light);
    text-transform: uppercase;
}

.tip-title {
    font-size: 21px;
    font-weight: 800;
    color: var(--sand);
    line-height: 1.15;
}

.tip-text {
    width: 100%;
    text-align: left;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
}

.tip-rule {
    width: 100%;
    text-align: left;
    font-size: 13px;
    line-height: 1.45;
    color: var(--sand-light);
    background: rgba(233, 194, 92, 0.1);
    border-left: 3px solid var(--sand);
    border-radius: 0 8px 8px 0;
    padding: 8px 12px;
}

/* SHOP */
#scene-shop {
    background:
        linear-gradient(rgba(12, 22, 44, 0.68), rgba(12, 22, 44, 0.68)),
        url('../assets/menubg.webp') center/cover no-repeat;
    justify-content: flex-start;
    padding-top: 8px;
    gap: 16px;
}

.shop-status {
    color: var(--text-dim);
    font-size: 14px;
    text-align: center;
}

#shop-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 640px;
}

.shop-card {
    background: linear-gradient(180deg, rgba(22, 36, 68, 0.88) 0%, rgba(14, 24, 46, 0.95) 100%);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.shop-card:hover {
    border-color: var(--border-bright);
    box-shadow: 0 6px 20px rgba(var(--carnelian-rgb), 0.3);
}

.shop-card-owned {
    border-color: var(--sand);
    background: linear-gradient(180deg, rgba(32, 54, 96, 0.94) 0%, rgba(20, 34, 64, 0.96) 100%);
    box-shadow: 0 0 24px rgba(232, 195, 106, 0.4), inset 0 0 14px rgba(232, 195, 106, 0.08);
}

.shop-card-owned .shop-card-title {
    color: var(--sand-light);
    text-shadow: 0 0 10px rgba(232, 195, 106, 0.45), 0 1px 2px rgba(0, 0, 0, 0.6);
}

.shop-card-owned .shop-card-desc {
    color: var(--sand-light);
}

.shop-card-img {
    width: 85px;
    height: 85px;
    object-fit: contain;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.shop-card-img-placeholder {
    background: linear-gradient(135deg, rgba(233, 194, 92, 0.16), rgba(var(--carnelian-rgb), 0.18));
    border: 1px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.shop-bonus {
    font-size: 32px;
    font-weight: 900;
    background: linear-gradient(180deg, #f5e0a0 0%, #e8c36a 50%, #c8a030 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 8px rgba(232, 195, 106, 0.4));
    line-height: 1.1;
}

.shop-card-body {
    text-align: left;
    flex: 1;
    min-width: 0;
}

.shop-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--sand);
    margin-bottom: 2px;
    line-height: 1.2;
}

.shop-card-desc {
    font-size: 12px;
    color: #fff;
    line-height: 1.3;
}

.shop-card-buy {
    min-width: 96px;
    padding: 8px 14px;
    font-size: 13px;
    flex-shrink: 0;
}

.shop-card-buy:disabled {
    opacity: 0.55;
    cursor: default;
    transform: none !important;
    box-shadow: none;
    background: linear-gradient(180deg, rgba(70, 64, 52, 0.72) 0%, rgba(44, 40, 32, 0.82) 100%);
    border-color: rgba(176, 164, 130, 1);
}

/* Кнопка «Куплено» — премиальный золотой вид */
.shop-card-owned .shop-card-buy:disabled {
    opacity: 1;
    background: linear-gradient(180deg, #f5e0a0 0%, #e8c36a 45%, #8a6a1a 100%);
    border-color: #f5e0a0;
    color: #2a1808;
    font-weight: 800;
    letter-spacing: 1px;
    text-shadow: 0 1px 0 rgba(255, 240, 180, 0.5);
    box-shadow:
        0 0 20px rgba(232, 195, 106, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        inset 0 -1px 0 rgba(80, 50, 0, 0.35);
}/* Portrait layout uses a 420px-wide logical board; canvas and touch input share its coordinates. */
#game-board.portrait .scene{padding-left:16px;padding-right:16px}
.portrait #scene-menu{background-position:center}
.portrait .menu-title{font-size:34px;line-height:1.2;width:100%;max-width:380px;margin-bottom:36px}
.portrait .btn{min-width:260px;padding:14px 20px;font-size:19px}
.portrait .btn-sm{min-width:140px;font-size:16px;padding:12px 18px}
.portrait .scene-header{font-size:28px;padding:14px 0 20px;margin:0}
.portrait .btn-back{left:12px;top:14px;width:44px;height:44px}
.portrait #scene-levels{padding-top:16px;padding-bottom:18px}
.portrait #levels-grid{width:100%;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:none;grid-auto-rows:94px;gap:10px;overflow-y:auto;min-height:0;padding:4px 2px 18px;touch-action:pan-y}
.portrait .level-card{width:100%;height:94px;padding:8px 4px}
.portrait .level-name{font-size:11px;line-height:1.15}
.portrait .story-box{width:100%;max-height:calc(100% - 40px);overflow-y:auto;touch-action:pan-y;gap:14px}
.portrait .story-image{width:100%;height:240px;flex-shrink:0}
.portrait .story-text-area{width:100%;padding:18px;min-height:110px}
.portrait .story-speaker{font-size:17px}.portrait .story-text{font-size:18px;line-height:1.5}
.portrait .story-buttons{width:100%;justify-content:center;flex-shrink:0}
.portrait #hud{height:100px;padding:36px 12px 8px;gap:14px}
.portrait .hud-item{font-size:20px;gap:5px}
.portrait #hud-level-name{top:12px;font-size:16px;max-width:calc(100% - 24px);overflow:hidden;text-overflow:ellipsis}
.portrait .hud-right{gap:7px}
.portrait .hud-btn{min-width:44px;height:44px;padding:8px;font-size:18px;display:flex;align-items:center;justify-content:center}
.portrait #goals-bar{top:108px;left:14px;right:14px;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.portrait .goal-item{min-width:0;font-size:14px;min-height:32px;padding:5px 8px;gap:6px}
.portrait .goal-icon{width:24px;height:24px;flex-shrink:0}
.portrait .tip-card{width:calc(100% - 24px);max-height:calc(100% - 36px);overflow-y:auto;touch-action:pan-y;padding:18px;gap:14px}
.portrait .tip-text,.portrait .tip-rule{font-size:17px;line-height:1.45}
.portrait .tip-title{font-size:22px}
.portrait .result-title{font-size:36px;text-align:center}
.portrait #result-subtitle{max-width:100%;text-align:center;font-size:17px}
.portrait .result-buttons{flex-direction:column;gap:12px}
.portrait .diary-book{width:100%;height:auto;max-height:calc(100% - 100px);overflow-y:auto;flex-direction:column;touch-action:pan-y}
.portrait .diary-page{flex:none;padding:20px}.portrait .diary-spine{display:none}
.portrait .diary-page-right{padding:14px}.portrait .diary-image{max-width:100%;height:auto;max-height:180px;object-fit:cover}
.portrait .diary-text{font-size:16px;line-height:1.5}.portrait .diary-nav{gap:10px;margin:12px 0}
.portrait #scene-shop{padding-top:18px;justify-content:flex-start}
.portrait #shop-grid{width:100%;padding:8px 0;max-height:none;min-height:0;overflow-y:auto;touch-action:pan-y}
.portrait .shop-card{padding:10px;gap:10px;flex-wrap:wrap}.portrait .shop-card-img{width:62px;height:62px}
.portrait .shop-card-buy{width:100%;min-width:0;font-size:16px}.portrait .shop-card-title{font-size:17px}
