:root {
    --cream: #fff9e9;
    --ink: #49372a;
    --brown: #6d4933;
    --brown-dark: #4e3022;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    background: #263c3d;
    color: var(--ink);
    font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
}

.game-wrapper {
    position: fixed;
    inset: 0;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: #8ed9ec;
    touch-action: none;
}

#game-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.hidden {
    display: none !important;
}

.screen {
    position: absolute;
    z-index: 10;
    inset: 0;
    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(27, 46, 44, .32);
    backdrop-filter: blur(2px);
}

.screen-card {
    position: relative;
    width: min(430px, 94%);
    max-height: 94vh;
    padding: 28px 30px 24px;
    overflow: auto;
    text-align: center;
    border: 3px solid #75503a;
    border-radius: 25px;
    background: radial-gradient(circle at 15% 10%, rgba(255,255,255,.9), transparent 25%), var(--cream);
    box-shadow: 0 8px 0 #75503a, 0 22px 38px rgba(24,28,21,.32);
    animation: card-in .32s cubic-bezier(.2,1.35,.45,1);
}

.small-card { width: min(350px, 94%); }

@keyframes card-in {
    from { opacity: 0; transform: scale(.83) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.leaf {
    position: absolute;
    top: 13px;
    font-size: 30px;
    opacity: .75;
}

.leaf-left { left: 16px; transform: rotate(-22deg); }
.leaf-right { right: 16px; transform: rotate(22deg) scaleX(-1); }

.eyebrow {
    margin: 0 0 8px;
    color: #9c7045;
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: 1.5px;
}

h1,
h2 {
    margin: 0;
    color: var(--brown-dark);
    font-weight: 900;
    line-height: 1;
}

h1 {
    font-size: clamp(1.9rem, 5vw, 2.75rem);
    letter-spacing: -1.5px;
}

h2 { font-size: clamp(1.8rem, 5vw, 2.3rem); }

.tagline,
.card-copy {
    margin: 12px auto 15px;
    color: #745743;
    font-size: clamp(.88rem, 2.5vw, 1rem);
    line-height: 1.4;
}

.card-copy { margin-bottom: 8px; }

.mascot-preview {
    position: relative;
    width: 142px;
    height: 92px;
    margin: 2px auto 11px;
}

.preview-shadow {
    position: absolute;
    bottom: 5px;
    left: 15px;
    width: 110px;
    height: 15px;
    border-radius: 50%;
    background: rgba(93,57,31,.18);
}

.preview-capy {
    position: absolute;
    left: 17px;
    bottom: 9px;
    width: 110px;
    height: 70px;
    animation: preview-bounce 1.4s ease-in-out infinite;
}

@keyframes preview-bounce {
    50% { transform: translateY(-4px) rotate(-1deg); }
}

.preview-body {
    position: absolute;
    inset: 14px 0 0;
    border: 3px solid #65402d;
    border-radius: 48% 45% 42% 38%;
    background: radial-gradient(circle at 65% 24%, #c99870 0 4%, transparent 5%), linear-gradient(145deg,#bb825c,#855238);
}

.preview-body::after {
    position: absolute;
    top: 24px;
    right: -1px;
    width: 28px;
    height: 22px;
    content: "";
    border-radius: 46%;
    background: #d7a17a;
}

.ear {
    position: absolute;
    z-index: 2;
    top: 3px;
    width: 19px;
    height: 20px;
    border: 3px solid #65402d;
    border-radius: 50%;
    background: #a86949;
}

.ear-one { left: 54px; }
.ear-two { top: 6px; left: 80px; width: 16px; height: 17px; }

.preview-eye {
    position: absolute;
    z-index: 3;
    top: 32px;
    right: 21px;
    width: 9px;
    height: 11px;
    border-radius: 50%;
    background: #2d211b;
}

.preview-eye::after {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 3px;
    height: 3px;
    content: "";
    border-radius: 50%;
    background: white;
}

.preview-nose {
    position: absolute;
    z-index: 3;
    top: 51px;
    right: 4px;
    width: 10px;
    height: 7px;
    border-radius: 50%;
    background: #4a3027;
}

.preview-leg {
    position: absolute;
    z-index: -1;
    bottom: -2px;
    width: 17px;
    height: 27px;
    border: 3px solid #65402d;
    border-radius: 0 0 11px 11px;
    background: #9b6042;
}

.leg-one { left: 24px; }
.leg-two { right: 25px; }

.btn,
.btn-hud {
    border: 0;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.btn {
    width: 100%;
    min-height: 48px;
    margin: 8px 0;
    padding: 11px 16px;
    border: 3px solid #6c4732;
    border-radius: 14px;
    color: var(--brown-dark);
    font-size: .95rem;
}

.btn:active { transform: translateY(3px); }

.btn-primary {
    color: white;
    background: linear-gradient(#f59352,#e66c38);
    box-shadow: 0 5px 0 #ae4829;
}

.btn-secondary {
    background: #f3d890;
    box-shadow: 0 4px 0 #ba985a;
}

.btn-text {
    min-height: 35px;
    margin-top: 4px;
    padding: 6px;
    border: 0;
    background: transparent;
    color: #8a6248;
    font-size: .82rem;
    box-shadow: none;
}

.controls-hint {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px 13px;
    margin-top: 13px;
    color: #896b56;
    font-size: .72rem;
    line-height: 1.45;
}

.hud {
    position: absolute;
    z-index: 5;
    top: env(safe-area-inset-top);
    right: env(safe-area-inset-right);
    left: env(safe-area-inset-left);
    display: flex;
    justify-content: space-between;
    padding: 12px;
    pointer-events: none;
}

.hud > * { pointer-events: auto; }

.hud-left {
    display: flex;
    gap: 8px;
}

.btn-hud {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 2px solid #6e4a35;
    border-radius: 13px;
    background: rgba(255,249,233,.93);
    box-shadow: 0 3px 0 #6e4a35;
    color: #624431;
    font-size: 1.2rem;
}

.score-box {
    min-width: 92px;
    padding: 5px 12px 6px;
    border: 2px solid #6e4a35;
    border-radius: 13px;
    background: rgba(255,249,233,.93);
    box-shadow: 0 3px 0 #6e4a35;
    text-align: center;
}

.score-label {
    display: block;
    color: #956e4b;
    font-size: .58rem;
    font-weight: 900;
    letter-spacing: 1.4px;
}

.score-value {
    display: block;
    color: #cf5c33;
    font-size: 1.35rem;
    font-weight: 900;
    line-height: 1.1;
}

.card-icon {
    margin-bottom: 7px;
    font-size: 2.1rem;
}

.final-score {
    margin: 3px 0 0;
    color: #df6937;
    font-size: 3.3rem;
    font-weight: 900;
    line-height: 1;
}

.points-word {
    margin: 0 0 13px;
    color: #9d7658;
    font-size: .65rem;
    font-weight: 900;
    letter-spacing: 2px;
}

.rotate-screen {
    position: absolute;
    z-index: 100;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, rgba(33,66,70,.97), rgba(72,105,79,.97));
    text-align: center;
}

.rotate-card {
    max-width: 330px;
    padding: 28px 24px;
    border: 3px solid rgba(255,249,233,.9);
    border-radius: 24px;
    background: rgba(255,249,233,.96);
    box-shadow: 0 10px 0 rgba(34,49,38,.35);
}

.rotate-icon {
    margin-bottom: 12px;
    font-size: 3.5rem;
    animation: rotate-phone 1.7s ease-in-out infinite;
}

.rotate-card h2 {
    font-size: 1.5rem;
}

.rotate-card p {
    margin: 12px 0 0;
    color: #745743;
    line-height: 1.4;
}

@keyframes rotate-phone {
    50% { transform: rotate(90deg); }
}

@media (orientation: portrait) {
    .rotate-screen { display: flex; }
}

@media (max-height: 500px) and (orientation: landscape) {
    .screen-card {
        width: min(390px, 88vw);
        max-height: 90vh;
        padding: 15px 25px 12px;
    }

    .mascot-preview,
    .tagline,
    .controls-hint {
        display: none;
    }

    .eyebrow { margin-bottom: 5px; }
    .btn { min-height: 38px; margin: 5px 0; padding: 7px 12px; }
    .hud { padding: 8px 12px; }
    .btn-hud { width: 38px; height: 38px; }
}