:root {
    --bg: #F5F2EC;
    --surface: #FAFAF8;
    --ink: #2C2825;
    --ink-2: #7A736C;
    --accent: #B8916A;
    --border: #E2DCD3;
    --ground: #D4CEC4;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'DM Mono', monospace;
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at 20% 50%, rgba(184,145,106,0.06) 0%, transparent 60%),
        radial-gradient(circle at 80% 20%, rgba(44,40,37,0.04) 0%, transparent 50%);
    color: var(--ink);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

#game-container {
    position: relative;
    width: min(800px, 98vw, calc(90vh * 2));
    aspect-ratio: 2 / 1;
    background: var(--surface);
    border-radius: 16px;
    overflow: hidden;
    box-shadow:
        0 2px 1px rgba(44,40,37,0.04),
        0 8px 32px rgba(44,40,37,0.08),
        0 24px 64px rgba(44,40,37,0.06);
    border: 1px solid var(--border);
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

#title {
    font-family: 'Playfair Display', serif;
    font-size: 1.9rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 8px;
    letter-spacing: 4px;
    text-transform: uppercase;
}

#score-board, #high-score-board {
    position: absolute;
    top: 18px;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 1px;
    padding: 5px 11px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: rgba(250,250,248,0.92);
}

#score-board  { right: 18px; color: var(--ink); }
#high-score-board { left: 18px; color: var(--ink-2); }

#start-screen, #game-over-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: var(--surface);
    padding: 36px 44px;
    border-radius: 14px;
    border: 1px solid var(--border);
    pointer-events: auto;
    width: 80%;
    max-width: 380px;
    transition: all 0.28s ease;
    box-shadow: 0 4px 32px rgba(44,40,37,0.08);
}

.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -46%) scale(0.97);
}

h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--ink);
    letter-spacing: 1px;
}

p {
    margin-bottom: 22px;
    color: var(--ink-2);
    font-size: 0.78rem;
    letter-spacing: 0.4px;
    line-height: 1.8;
}

button {
    background: var(--ink);
    color: var(--surface);
    border: none;
    padding: 11px 30px;
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 50px;
    cursor: pointer;
    transition: opacity 0.18s, transform 0.18s;
    font-family: 'DM Mono', monospace;
    letter-spacing: 2px;
    text-transform: uppercase;
}

button:hover {
    opacity: 0.72;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
    opacity: 0.88;
}

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

#start-button {
    animation: pulse 2.8s infinite ease-in-out;
}

/* ── 旋轉提示 ─────────────────────── */
#rotate-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 1000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

#rotate-overlay .rotate-icon {
    font-size: 3.5rem;
    animation: rotate-hint 1.5s ease-in-out infinite;
}

#rotate-overlay p {
    font-size: 0.9rem;
    color: var(--ink-2);
    margin: 0;
    line-height: 2;
}

@keyframes rotate-hint {
    0%, 100% { transform: rotate(0deg); }
    50%       { transform: rotate(90deg); }
}

/* ── 手機直式：顯示旋轉提示 ──────── */
@media (orientation: portrait) and (max-width: 768px) {
    #rotate-overlay { display: flex; }
}

/* ── 手機直式 ────────────────────── */
@media (orientation: portrait) and (max-width: 600px) {
    #game-container { width: 100vw; border-radius: 0; }
    #ui-layer { padding: 10px; }
    #title { font-size: 1.3rem; margin-bottom: 4px; }
    #score-board, #high-score-board { font-size: 0.65rem; padding: 4px 8px; top: 10px; }
    h2 { font-size: 1.2rem; margin-bottom: 8px; }
    p { font-size: 0.72rem; margin-bottom: 12px; }
    button { padding: 9px 22px; font-size: 0.68rem; }
    #start-screen, #game-over-screen { padding: 20px; width: 88%; }
}

/* ── 手機橫式 ────────────────────── */
@media (orientation: landscape) and (max-height: 500px) {
    body { align-items: center; }
    #game-container { width: min(98vw, calc(86vh * 2)); border-radius: 10px; }
    #ui-layer { padding: 8px; }
    #title { font-size: 1.05rem; margin-bottom: 3px; }
    #score-board, #high-score-board { font-size: 0.62rem; padding: 3px 7px; top: 8px; }
    h2 { font-size: 0.95rem; margin-bottom: 6px; }
    p { font-size: 0.68rem; margin-bottom: 8px; }
    button { padding: 7px 18px; font-size: 0.64rem; }
    #start-screen, #game-over-screen { padding: 12px; width: 80%; }
}
