/* ==========================================
   貓咪瑪利歐 - 經典受折磨挑戰 遊戲包裝與樣式
   ========================================== */

:root {
    --primary-color: #c0392b;
    --primary-hover: #ab3326;
    --border-color: rgba(0, 0, 0, 0.08);
    --font-family: 'Outfit', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html, body {
    height: auto;
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    background-color: #f5f6f8;
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    user-select: none;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
}

/* 遊戲包裝結構 */
.app-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 93px);
    gap: 16px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.game-header .logo {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary-color);
    text-shadow: 1px 1px 0 #fff, 2px 2px 0 #000;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
}

.game-layout {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
}

.game-wrapper-box {
    position: relative;
    width: 480px;
    height: 420px;
    border-radius: 16px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    background-color: #282828;
    border: 4px solid #fff;
}

/* 手機端寬度響應式適配 */
@media (max-width: 520px) {
    .game-wrapper-box {
        width: 100%;
        height: auto;
        aspect-ratio: 480 / 580 !important; /* 手機端直接無條件留出 160px 的控制盤高度，防止按鍵被截斷 */
    }
}

/* 單手模式 (虛擬控制盤) 啟用時拉高 Canvas 高度 */
.game-wrapper-box.onehand-active {
    height: 580px; /* 大螢幕下的單手模式高度，多提供 160px 空間讓遊戲畫控制盤 */
}

/* 遊戲容器與 Canvas */
#container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#canvas {
    border: 0px none;
    outline: none;
    padding: 0;
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated; /* 像素風原汁原味 */
}

/* 遊戲標題與選單覆蓋層 */
#title {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #5d5c5c;
    z-index: 2;
}

#title header {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.titleimg {
    max-width: 90%;
    height: auto;
}

#title content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

#title footer {
    line-height: 50px;
    font-size: 14px;
    text-shadow: 0px 0px 5px #000;
    color: white;
}

#title footer a {
    color: #eee;
    text-decoration: none;
}

#title footer a:hover {
    color: #fff;
    text-decoration: underline;
}

/* 按鈕樣式 */
.btn {
    padding: 10px 45px;
    cursor: pointer;
    font-weight: bold;
    border-radius: 30px;
    border: 2px solid #000;
    font-size: 20px;
    transition: all 0.2s ease;
    text-align: center;
}

.btn-danger {
    color: #fff;
    background-color: var(--primary-color);
    box-shadow: 0 4px 0 #8a251b;
}

.btn-danger:hover {
    background-color: var(--primary-hover);
}

.btn-danger:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #8a251b;
}

.start-btn {
    width: 210px;
}

.btn-cancel {
    color: #333;
    background-color: #e6e6e6;
    box-shadow: 0 4px 0 #b3b3b3;
}

.btn-cancel:hover {
    background-color: #d9d9d9;
}

.btn-cancel:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #b3b3b3;
}

.setting-btn {
    font-size: 16px;
    width: 200px;
    padding: 8px 20px;
}

/* 遊戲彈窗 */
.window {
    position: absolute;
    left: 20px;
    right: 20px;
    top: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    max-width: 416px;
    width: calc(100% - 40px);
    margin: auto;
    background-color: #fff;
    border: 3px solid #000;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 5;
    overflow: hidden;
}

.window header {
    position: relative;
    padding: 12px 20px;
    background-color: #434a54;
    color: white;
    font-size: 22px;
    font-weight: bold;
    text-align: center;
}

.window content {
    position: relative;
    background-color: #FFF;
    flex: 1;
    font-size: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.window footer {
    position: relative;
    padding: 12px;
    background-color: #f5f6f8;
    text-align: center;
    border-top: 1px solid #ddd;
}

.mask {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.5);
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    z-index: -1;
}

/* 設置視窗中的多選框 */
#settings_window content {
    gap: 15px;
    align-items: stretch;
}

#settings_window content > div {
    display: flex;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
}

.checkboxFour {
    width: 34px;
    height: 34px;
    background: #ddd;
    border-radius: 100%;
    position: relative;
    box-shadow: 0px 1px 3px rgba(0,0,0,0.4);
    margin-right: 15px;
    flex-shrink: 0;
}

.checkboxFour input {
    display: none;
}

.checkboxFour label {
    display: block;
    width: 24px;
    height: 24px;
    border-radius: 100px;
    transition: all .3s ease;
    cursor: pointer;
    position: absolute;
    top: 5px;
    left: 5px;
    z-index: 1;
    background: #333;
    box-shadow: inset 0px 1px 3px rgba(0,0,0,0.5);
}

.checkboxFour input[type=checkbox]:checked + label {
    background: #26ca28;
}

.checkboxFourFront label {
    cursor: pointer;
}

/* 關閉按鈕 */
.close {
    position: absolute;
    width: 32px;
    height: 32px;
    background: #434a54;
    opacity: 0.6;
    display: inline-block;
    top: 8px;
    right: 8px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.close:hover {
    opacity: 1;
}

.close::before, .close::after {
    content: '';
    position: absolute;
    width: 80%;
    top: 50%;
    left: 10%;
    height: 4px;
    margin-top: -2px;
    border-radius: 2px;
    background: #ffffff;
}

.close::before {
    transform: rotate(45deg);
}

.close::after {
    transform: rotate(-45deg);
}

/* 排行榜覆蓋層 (與Flappy Bird風格一致但更精緻) */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: rgba(255, 255, 255, 0.98);
    border: 3px solid #000;
    border-radius: 16px;
    padding: 24px 20px;
    text-align: center;
    width: 100%;
    max-width: 280px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    animation: scale-up 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes scale-up {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.overlay-content h2 {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--primary-color);
    margin: 0 0 8px 0;
    text-shadow: 1px 1px 0 #fff, 2px 2px 0 #000;
}

.overlay-content .subtitle {
    font-size: 1.1rem;
    font-weight: 700;
    color: #374151;
    margin: 0 0 4px 0;
}

.overlay-content .death-info {
    font-size: 0.9rem;
    font-weight: 600;
    color: #7f8c8d;
    margin: 0 0 16px 0;
}

.new-record-panel {
    background: rgba(192, 57, 43, 0.05);
    border: 2px dashed var(--primary-color);
    border-radius: 12px;
    padding: 16px 12px;
    margin-bottom: 12px;
}

.new-record-panel.hidden {
    display: none;
}

.glow-text {
    font-weight: 900;
    color: var(--primary-color);
    font-size: 0.95rem;
    margin-bottom: 12px;
    text-shadow: 1px 1px 0 #fff;
}

#nickname-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    border: 2px solid #000;
    border-radius: 8px;
    background: #fff;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 12px;
    font-family: var(--font-family);
}

#nickname-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.primary-btn {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #000;
    background: var(--primary-color);
    color: #fff;
    font-weight: 900;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 0 #8a251b;
    transition: all 0.1s ease;
    font-family: var(--font-family);
}

.primary-btn:hover {
    background: var(--primary-hover);
}

.primary-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #8a251b;
}

/* 操作指南與說明 */
.game-instruction {
    text-align: center;
    font-size: 0.85rem;
    color: #555;
    line-height: 1.6;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.05);
    padding: 14px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}
