* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(255, 214, 140, 0.45), transparent 55%),
        linear-gradient(180deg, #f4a261 0%, #e76f51 42%, #6d4c41 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    color: #2b2118;
}

.game-container {
    background: rgba(255, 250, 244, 0.94);
    border-radius: 24px;
    box-shadow: 0 24px 70px rgba(60, 24, 8, 0.35);
    padding: 26px;
    max-width: 900px;
    width: 100%;
}

.game-header {
    text-align: center;
    margin-bottom: 16px;
}

.title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.game-header h1 {
    color: #c4452d;
    font-size: 2.2em;
    letter-spacing: -0.03em;
    margin-bottom: 0;
}

#btnFullscreen {
    border: 0;
    border-radius: 999px;
    min-height: 44px;
    min-width: 44px;
    padding: 10px 16px;
    font: inherit;
    font-size: 0.85em;
    font-weight: 700;
    color: #fff8ee;
    background: #2b2118;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#btnFullscreen:hover {
    background: #4a3728;
}

#btnFullscreen[aria-pressed="true"] {
    background: #c4452d;
    box-shadow: 0 0 0 3px rgba(255, 214, 102, 0.75);
}

.version {
    display: inline-block;
    margin-left: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #2b2118;
    color: #fff8ee;
    font-size: 0.38em;
    letter-spacing: 0.08em;
    vertical-align: middle;
}

.score-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 16px;
    font-size: 1.02em;
    font-weight: 700;
}

.score { color: #d9760a; }
.combo { color: #c4452d; }
.level { color: #2a6f97; }
.lives { color: #9b2226; }
.best { color: #495057; }

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 16px;
    background: #8ecae6;
    touch-action: none;
    user-select: none;
    cursor: crosshair;
}

.modes {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
}

.modes button {
    border: 0;
    border-radius: 999px;
    padding: 8px 16px;
    font: inherit;
    font-size: 0.92em;
    font-weight: 700;
    color: #fff8ee;
    background: #2b2118;
    cursor: pointer;
}

.modes button:hover:not(:disabled) {
    transform: translateY(-1px);
}

#btnCheer { background: #d6336c; }
#btnBenson { background: #364fc7; }
#btnSombrero { background: #2b8a3e; }

.modes button.on {
    box-shadow: 0 0 0 3px rgba(255, 214, 102, 0.95);
}

.modes button:disabled {
    opacity: 0.38;
    cursor: default;
}

.game-controls {
    text-align: center;
    margin-top: 12px;
    color: #5c4a3a;
    font-size: 0.95em;
    line-height: 1.45;
}

#message {
    margin-top: 6px;
    font-weight: 700;
    color: #c4452d;
    font-size: 1.05em;
}

.game-over {
    position: fixed;
    inset: 0;
    background: rgba(28, 16, 8, 0.78);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.game-over.hidden {
    display: none;
}

.game-over h2 {
    color: white;
    font-size: clamp(1.8rem, 4vw, 3rem);
    margin-bottom: 24px;
    text-align: center;
    padding: 0 20px;
}

#restartBtn {
    padding: 14px 36px;
    font: inherit;
    font-size: 1.15em;
    font-weight: 700;
    background: #f4a261;
    color: #2b2118;
    border: none;
    border-radius: 999px;
    cursor: pointer;
}

#restartBtn:hover {
    background: #ffd166;
}

.modes button,
#restartBtn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.rotate-overlay {
    display: none;
}

body.rotate .game-container,
body.rotate .game-over {
    display: none;
}

body.rotate .rotate-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 80vh;
    text-align: center;
    color: #fff8ee;
    padding: 24px;
}

.rotate-overlay h2 {
    font-size: 1.7em;
    letter-spacing: -0.02em;
}

.rotate-overlay p {
    max-width: 260px;
    line-height: 1.4;
    opacity: 0.9;
}

.rotate-phone {
    width: 64px;
    height: 110px;
    border: 5px solid #fff8ee;
    border-radius: 14px;
    position: relative;
    margin-bottom: 12px;
    animation: ldc-rotate 2.4s ease-in-out infinite;
}

.rotate-phone::after {
    content: "";
    position: absolute;
    bottom: 6px;
    left: 50%;
    width: 16px;
    height: 4px;
    margin-left: -8px;
    border-radius: 2px;
    background: #fff8ee;
}

@keyframes ldc-rotate {
    0%, 20% { transform: rotate(0deg); }
    50%, 75% { transform: rotate(-90deg); }
    100% { transform: rotate(0deg); }
}

body.phone {
    padding: 8px max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left));
    min-height: 100vh;
    min-height: 100dvh;
}

body.phone .game-container {
    display: grid;
    grid-template-columns: auto 170px;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
        "canvas header"
        "canvas modes"
        "canvas controls";
    gap: 8px 12px;
    width: auto;
    max-width: none;
    padding: 8px;
    border-radius: 16px;
}

body.phone #gameCanvas {
    grid-area: canvas;
    border-radius: 12px;
}

body.phone .game-header {
    grid-area: header;
    text-align: left;
    margin: 0;
}

body.phone .title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 6px;
}

body.phone .game-header h1 {
    font-size: 1em;
    margin-bottom: 0;
}

body.phone #btnFullscreen {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 0.78em;
}

body.phone .score-display {
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    font-size: 0.8em;
}

body.phone .modes {
    grid-area: modes;
    flex-direction: column;
    margin: 0;
    gap: 6px;
}

body.phone .modes button {
    padding: 9px 10px;
    font-size: 0.85em;
}

body.phone .game-controls {
    grid-area: controls;
    text-align: left;
    margin: 0;
    font-size: 0.78em;
}

body.phone .game-controls p:first-child {
    display: none;
}

@media (max-width: 700px) {
    body { padding: 10px; }
    .game-container { padding: 14px; }
    .game-header h1 { font-size: 1.45em; }
    .modes { flex-wrap: wrap; }
}

.game-container:fullscreen,
.game-container:-webkit-full-screen,
body.phone .game-container:fullscreen,
body.phone .game-container:-webkit-full-screen {
    max-width: none;
    width: 100%;
    height: 100%;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 16px 20px;
    background: rgba(255, 250, 244, 0.98);
    grid-template-columns: none;
    grid-template-areas: none;
}

.game-container:fullscreen #gameCanvas,
.game-container:-webkit-full-screen #gameCanvas {
    margin: 0 auto;
}

body.is-fullscreen {
    padding: 0;
}
