/* 페이지 스크롤 방지를 위한 추가 스타일 */
html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: 'Arial', sans-serif;
    margin: 0;
    background-color: #f0f0f0;
    color: #333;
    touch-action: manipulation; /* Prevents double-tap zoom on mobile */
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    max-width: 900px;
    width: 100%;
    box-sizing: border-box;
    height: 100%;
    max-height: 100vh;
    overflow: hidden;
}

h1 {
    color: #e74c3c;
    margin: 5px 0 10px 0;
    font-size: 1.6em;
}

.header-row,
.game-info {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 20px;
    font-size: 12px;
}

.game-info p {
    margin: 3px 6px;
}

.game-layout {
    display: flex;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    justify-content: center;
    gap: 15px;
    flex: 1;
    max-height: calc(100% - 160px); /* 헤더와 버튼 등 다른 요소의 높이 고려 */
}

.tetris-left {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.tetris-right {
    display: flex;
    flex-direction: column;
    width: 180px;
    flex-shrink: 0;
    justify-content: space-between;
    height: 100%;
}

.next-piece-section {
    flex: 1;
    min-height: 70px;
    max-height: 20%;
    background-color: #fff;
    border: 3px solid #333;
    border-radius: 5px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px;
    box-sizing: border-box;
}

.next-piece-title {
    font-weight: bold;
    margin-bottom: 5px;
}

#next-piece-canvas {
    background-color: transparent;
}

.module-section {
    flex: 2;
    min-height: 90px;
    background-color: #f0f0f0;
    /* border: 3px solid #333; */
    border: none;
    border-radius: 5px;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 10px;
    box-sizing: border-box;
}

#tetris-board {
    border: 3px solid #333;
    display: block;
    background-color: #e0e0e0;
    margin: 0;
    max-height: 100%;
    max-width: 100%;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
    width: 100%;
}

.option-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 20px;
    margin-bottom: 0;
    font-size: 0.95em;
}

.option-controls button,
.option-controls label,
.option-controls span {
    font-size: 0.95em;
}

.sound-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.sound-toggle input {
    cursor: pointer;
}

.controls button, #start-pause-btn {
    padding: 8px 12px;
    font-size: 1.1em;
    border: none;
    border-radius: 5px;
    background-color: #3498db;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.controls button:hover, #start-pause-btn:hover {
    background-color: #2980b9;
}

.controls button:active, #start-pause-btn:active {
    background-color: #1f6392;
}

.instructions {
    font-size: 0.8em;
    color: #777;
    width: 100%;
    text-align: center;
    margin: 5px 0;
}

/* 오디오 요소 숨기기 */
audio {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-container {
        padding: 5px;
        justify-content: flex-start;
    }
    
    h1 {
        font-size: 1.4em;
        margin: 5px 0;
    }
    
    .game-info {
        margin-bottom: 5px;
    }
    
    .game-layout {
        flex-direction: row;
        gap: 10px;
        max-height: calc(100% - 130px);
    }
    
    .tetris-right {
        width: 120px;
    }
    
    .next-piece-section {
        min-height: 70px;
    }
    
    .module-section {
        min-height: 90px;
    }
    
    .controls button, #start-pause-btn {
        padding: 6px 10px;
        font-size: 1em;
    }
    
    .instructions {
        font-size: 0.7em;
    }
    
    .hexagram-lines {
        gap: 3px;
    }
    
    .hexagram-line {
        height: 10px;
    }
}

@media (max-width: 480px) {
    .game-container {
        padding: 3px;
    }
    
    h1 {
        font-size: 1.2em;
        margin: 3px 0;
    }
    
    .game-info {
        font-size: 0.8em;
    }
    
    .game-info p {
        margin: 3px 6px;
    }
    
    .tetris-right {
        width: 100px;
    }
    
    .next-piece-section, .module-section {
        padding: 1px;
        min-height: 32px;
        margin-bottom: 2px;
        border: none;
    }
    
    .next-piece-title {
        font-size: 0.7em;
        margin-bottom: 2px;
    }
    
    #next-piece-canvas {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px;
        min-height: 40px;
    }
    
    .roulette-container {
        width: 48px;
        height: 48px;
        margin-bottom: 4px;
    }
    
    .result-box {
        width: 48px;
        font-size: 0.9em;
        margin-bottom: 4px;
        padding: 2px;
    }
    
    .result-display {
        font-size: 13px;
        padding: 2px;
    }
    
    .hexagram-container {
        padding: 2px;
        max-width: 70px;
        margin-bottom: 2px;
    }
    
    .hexagram-title-small {
        font-size: 8px;
        margin-top: 2px;
    }
    
    .hexagram-status {
        font-size: 9px;
        margin-bottom: 4px;
    }
    
    .hexagram-lines {
        gap: 2px;
        margin-bottom: 4px;
    }
    
    .hexagram-line {
        height: 8px;
    }
    
    .line-position {
        font-size: 7px;
        left: -12px;
    }
    
    .controls {
        gap: 5px;
    }
    
    .controls button {
        padding: 5px 8px;
        font-size: 0.9em;
    }
    
    .option-controls {
        font-size: 0.85em;
    }
    .option-controls button,
    .option-controls label,
    .option-controls span {
        font-size: 0.85em;
    }
}

/* ---- 룰렛/주역점 UI 및 언어 선택 버튼 스타일 추가 ---- */
.language-selector {
    display: flex;
    align-items: center;
    margin-left: auto;
    margin-bottom: 10px;
}
.language-buttons {
    display: flex;
    background-color: #f0f0f0;
    border-radius: 20px;
    padding: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.lang-btn {
    padding: 4px 8px;
    border-radius: 16px;
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 28px;
    text-align: center;
    color: #666;
}
.lang-btn.active {
    background-color: #fff;
    color: #5B9BFF;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.roulette-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 200px;
}
.result-box {
    width: 100px;
    padding: 5px;
    margin-bottom: 10px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    text-align: center;
}
.result-display {
    font-size: 20px;
    font-weight: bold;
    padding: 5px;
    background-color: #e6f0ff;
    border-radius: 8px;
}
.roulette-container {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 10px;
}
.roulette {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #ccc;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.pointer {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 10px solid #ff0000;
    z-index: 10;
}
.center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #333;
    z-index: 5;
}
.hexagram-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 200px;
}
.hexagram-container {
    width: 100%;
    max-width: 180px;
    margin-bottom: 10px;
    padding: 15px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.hexagram-status {
    text-align: center;
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
    font-weight: bold;
}
.hexagram-lines {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 15px;
}
.hexagram-line {
    width: 100%;
    height: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px dashed #ddd;
    border-radius: 4px;
    position: relative;
    transition: all 0.3s;
}
.hexagram-line.highlighted {
    background-color: #fffacd;
    border: 2px solid #ffd700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}
.yang-line {
    width: 80%;
    height: 4px;
    background-color: #333;
}
.yin-line {
    width: 80%;
    height: 4px;
    display: flex;
    justify-content: space-between;
}
.yin-line-part {
    width: 40%;
    height: 4px;
    background-color: #333;
}
.line-position {
    position: absolute;
    left: -20px;
    font-size: 10px;
    color: #888;
}

/* ---- 모달 팝업(중앙 오버레이) 스타일 추가 ---- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}
.modal-overlay[style*="display: flex"] {
    display: flex !important;
}
.modal {
    background-color: white;
    padding: 24px;
    border-radius: 16px;
    max-width: 520px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}
.modal-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 18px;
    color: #464646;
    text-align: center;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}
.modal-content {
    margin-bottom: 24px;
}
.modal-footer {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* 로딩 오버레이 항상 숨김 기본값 */
.loading {
    display: none;
}

/* ---- 모달 내부 스타일 및 질문 선택 등 ---- */
.question-item {
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
    background: #fff;
}
.question-item:hover {
    background-color: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}
.question-item.selected {
    background-color: #e6f0ff;
    border-color: #5B9BFF;
    box-shadow: 0 2px 5px rgba(91, 155, 255, 0.2);
}
.info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    margin-bottom: 20px;
    font-size: 15px;
}
.info-label {
    font-weight: bold;
    color: #555;
}
.modal-footer button {
    padding: 8px 16px;
    font-size: 14px;
    background-color: #5B9BFF;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(91, 155, 255, 0.3);
}
.modal-footer button:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}
.modal-footer button:hover:enabled {
    background-color: #4285f4;
}
.modal-footer button:active {
    background-color: #1a5edb;
    transform: scale(0.95);
    box-shadow: 0 0 0 3px #5B9BFF33;
    transition: all 0.1s;
}

/* ---- 모달 내 괘(육효) 표시 스타일 ---- */
.hexagram-image-container {
    flex: 0.8;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.hexagram-image {
    width: 100%;
    max-width: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    background-color: white;
    border-radius: 12px;
}
.modal-hexagram-lines {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px auto;
    width: 90%;
    max-width: 180px;
}
.modal-hexagram-lines .hexagram-line {
    height: 15px;
    border: 1px dashed #ddd;
    border-radius: 2px;
}
.modal-hexagram-name {
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    margin-top: 10px;
    color: #4285f4;
}

/* ---- 주역점 해석 모달 소제목/키워드 스타일 ---- */
.interpretation-section-title {
    font-weight: bold;
    margin-bottom: 8px;
    color: #5B9BFF;
    font-size: 16px;
}
.keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}
.keyword-tag {
    background: linear-gradient(135deg, #5B9BFF, #4285f4);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 14px;
    color: white;
    box-shadow: 0 2px 5px rgba(91, 155, 255, 0.3);
    transition: all 0.2s;
    margin-bottom: 4px;
}
.keyword-tag:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(66, 133, 244, 0.4);
}

#spinButton {
    display: none !important;
}

.hexagram-title-small {
    display: block;
    font-size: 11px;
    font-weight: normal;
    font-style: normal;
    color: #e74c3c;
    text-align: center;
    margin-top: 4px;
    letter-spacing: 0.5px;
}

/* ---- 게임 오버 모달 스타일 ---- */
.gameover-modal {
    border-top: 8px solid #e74c3c;
    box-shadow: 0 12px 32px rgba(231, 76, 60, 0.15);
    text-align: center;
    animation: popIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.gameover-icon {
    font-size: 48px;
    margin-bottom: 18px;
    animation: shake 0.7s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
.gameover-score {
    font-size: 1.3em;
    font-weight: bold;
    color: #e74c3c;
    margin-bottom: 10px;
}
.gameover-desc {
    color: #888;
    font-size: 1em;
    margin-bottom: 10px;
}
#gameOverRestartButton {
    background: linear-gradient(90deg, #e74c3c, #ff7675);
    color: #fff;
    font-weight: bold;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 1.1em;
    border: none;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.12);
    transition: background 0.2s, transform 0.1s;
}
#gameOverRestartButton:hover {
    background: linear-gradient(90deg, #ff7675, #e74c3c);
    transform: scale(1.05);
}
@keyframes popIn {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-8px); }
    40%, 60% { transform: translateX(8px); }
}
/* ---- 시스템 알림 모달 스타일 ---- */
.system-alert-modal {
    border-top: 6px solid #5B9BFF;
    box-shadow: 0 8px 24px rgba(91, 155, 255, 0.13);
    text-align: center;
    animation: popIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.system-alert-modal.info {
    border-top-color: #5B9BFF;
}
.system-alert-modal.error {
    border-top-color: #e74c3c;
}
.system-alert-modal.warn {
    border-top-color: #f4d35e;
}
.system-alert-modal .system-alert-icon {
    font-size: 36px;
    margin-bottom: 12px;
}
#systemAlertConfirmButton {
    background: linear-gradient(90deg, #5B9BFF, #4285f4);
    color: #fff;
    font-weight: bold;
    border-radius: 8px;
    padding: 8px 22px;
    font-size: 1em;
    border: none;
    box-shadow: 0 2px 8px rgba(91, 155, 255, 0.12);
    transition: background 0.2s, transform 0.1s;
}
#systemAlertConfirmButton:hover {
    background: linear-gradient(90deg, #4285f4, #5B9BFF);
    transform: scale(1.04);
}

.language-guide-row {
    margin: 0 auto 4px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}
.language-guide-group {
    display: flex;
    align-items: center;
    gap: 12px;
}
.guide-btn {
    padding: 4px 12px;
    border-radius: 16px;
    border: none;
    background: linear-gradient(90deg, #5B9BFF, #4285f4);
    color: #fff;
    font-weight: bold;
/*  font-size: 0.95em;  */
    font-size: 12px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(91, 155, 255, 0.10);
    transition: background 0.2s, transform 0.1s;
    outline: none;
}
.guide-btn:hover, .guide-btn:focus {
    background: linear-gradient(90deg, #4285f4, #5B9BFF);
    transform: scale(1.04);
}

.game-guide-modal {
    border-top: 6px solid #5B9BFF;
    box-shadow: 0 8px 24px rgba(91, 155, 255, 0.13);
    text-align: center;
    animation: popIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    padding-bottom: 18px;
}
#gameGuideModalTitle {
    font-size: 22px;
    font-weight: bold;
    color: #4285f4;
    margin-bottom: 12px;
}
#gameGuideModalContent {
    font-size: 1.08em;
    color: #444;
    text-align: left;
    margin: 0 auto 18px auto;
    max-width: 420px;
    line-height: 1.7;
    padding: 0 4px;
}
#gameGuideConfirmButton {
    background: linear-gradient(90deg, #5B9BFF, #4285f4);
    color: #fff;
    font-weight: bold;
    border-radius: 8px;
    padding: 8px 22px;
    font-size: 1em;
    border: none;
    box-shadow: 0 2px 8px rgba(91, 155, 255, 0.12);
    transition: background 0.2s, transform 0.1s;
    outline: none;
}
#gameGuideConfirmButton:hover {
    background: linear-gradient(90deg, #4285f4, #5B9BFF);
    transform: scale(1.04);
}

.game-footer {
    text-align: center;
}
.footer-nav {
    font-size: 12px;
    text-align: center;
}