/**
 * Main styles - Base typography, layout, and global styles
 */

/* Fonts are imported in variables.css */


/* CSS Custom Properties */
:root {
    --font-amarillo: "Amarillo", "Inter", sans-serif;
    
    /* Theme colors will be set dynamically by ThemeManager */
    /* Default values as fallback */
    --bg-primary: #c0c0c0;
    --bg-secondary: #f0f0f0;
    --bg-tertiary: #fff;
    --text-primary: #000;
    --text-secondary: #666;
    --border-color: #000;
    --line-color: #2c2c2c;
    --hover-bg: #e0e0e0;
    --active-bg: #d0d0d0;
    --success-color: #4CAF50;
    --error-color: #f44336;
    --warning-color: #ff9800;
    
    /* Font variables with CJK support */
    --font-primary: "Courier New", "Noto Sans SC", "Noto Sans JP", "Noto Sans KR", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Malgun Gothic", monospace;
    --font-heading: var(--font-amarillo, "AmarilloUSAF"), "Noto Sans SC", "Noto Sans JP", "Noto Sans KR", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Malgun Gothic", sans-serif;
}

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

/* Disable zoom and touch gestures globally */
html {
    touch-action: manipulation; /* Prevents pinch-to-zoom */
    -ms-touch-action: manipulation;
    -webkit-touch-callout: none; /* Prevents callout menu on iOS */
    -webkit-user-select: none; /* Prevents text selection */
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    font-family: var(--font-primary);
    font-size: .9em;
    line-height: 1.25;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-secondary);
    touch-action: manipulation; /* Disable pinch-to-zoom */
    -webkit-touch-callout: none; /* Disable iOS callout menu */
    -ms-touch-action: manipulation; /* IE/Edge support */
}

/* Allow text selection in specific areas where needed */
input, textarea, .selectable-text {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

/* Extra zoom prevention for canvas and interactive elements */
canvas, #gameCanvas {
    touch-action: none !important; /* Prevents all touch gestures on canvas */
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    user-select: none !important;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px; /* Normal padding since footer flows naturally */
}

header {
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    padding: 10px;
    margin-bottom: 15px;
}

/* Title styles */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-size: 1.2em;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

header h1 {
    font-family: var(--font-heading);
    font-size: 1.2em;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    text-shadow: none;
    text-transform: none;
    letter-spacing: normal;
}

/* Regular text styles */
p {
    font-family: var(--font-primary);
    font-size: .9em;
    color: var(--text-secondary);
    margin: 0;
}

header p {
    font-family: var(--font-primary);
    font-size: .9em;
    color: var(--text-secondary);
    margin: 0;
}

.controls {
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* Ensure canvas control buttons have consistent dimensions across all languages */
.controls .btn {
    width: 210px !important;
    min-height: 60px !important;
    height: auto !important;
    padding: 12px 8px !important;
    font-size: 14px !important;
    line-height: 1.3 !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    text-align: center !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}

.instructions {
    background: var(--bg-tertiary);
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 0;
    box-shadow: none;
}

.instructions h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.instructions ul {
    list-style-type: none;
    padding-left: 0;
}

.instructions li {
    padding: 8px 0;
    padding-left: 20px;
    position: relative;
}

.instructions li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--chevron-color);
    font-weight: bold;
}

/* Welcome Screen Styles */
.welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    min-height: 600px; /* Prevent content from being pushed too high */
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between; /* Space between content and footer */
    z-index: 2000;
    overflow-y: auto; /* Allow scrolling if content is too tall */
}

.welcome-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90%;
    flex: 1;
    justify-content: center;
    min-height: 400px; /* Ensure minimum space for content */
    padding-top: 20px; /* Prevent content from hitting the very top */
}

/* Language dropdown - Terminal/Retro Theme */
.language-dropdown {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 3000;
    font-family: var(--font-primary);
}

.language-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: var(--text-primary);
    font-family: var(--font-primary);
    min-width: 50px;
}

.language-selector:hover,
.language-selector:focus {
    background: var(--text-primary);
    color: var(--bg-tertiary);
    outline: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.language-selector:hover .globe-icon,
.language-selector:focus .globe-icon {
    fill: var(--bg-tertiary, #fff);
}

.globe-icon {
    width: 16px;
    height: 16px;
    fill: var(--text-primary, currentColor);
    flex-shrink: 0;
    transition: fill 0.2s ease;
}

.current-language-indicator {
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-primary, monospace);
    color: var(--text-secondary, #666);
    letter-spacing: 0.5px;
    margin-left: 2px;
    transition: color 0.2s ease;
}

.language-selector:hover .current-language-indicator,
.language-selector:focus .current-language-indicator {
    color: var(--bg-tertiary, #fff);
}

.dropdown-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease, color 0.2s ease;
    color: var(--text-primary, currentColor);
}

.dropdown-arrow svg {
    width: 12px;
    height: 12px;
    transition: inherit;
}

.language-selector:hover .dropdown-arrow,
.language-selector:focus .dropdown-arrow {
    color: var(--bg-tertiary, #fff);
}

.language-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.language-options {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 2px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 0;
    box-shadow: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all 0.2s ease;
    min-width: 100%;
}

.language-dropdown.open .language-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.language-option {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-primary);
}

.language-option:last-child {
    border-bottom: none;
}

.language-option:hover,
.language-option:focus {
    background: var(--hover-bg);
    outline: none;
}

.language-code {
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-primary, monospace);
    color: var(--text-primary, currentColor);
    letter-spacing: 0.5px;
    transition: color 0.2s ease;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .language-dropdown {
        top: 15px;
        right: 15px;
    }
    
    .language-selector {
        padding: 6px 10px;
        font-size: 13px;
        min-width: 45px;
    }
    
    .globe-icon {
        width: 14px;
        height: 14px;
    }
    
    .current-language-indicator {
        font-size: 9px;
    }
    
    .language-code {
        font-size: 11px;
    }
    
    .language-option {
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .language-dropdown {
        top: 10px;
        right: 10px;
    }
    
    .language-selector {
        padding: 5px 8px;
        font-size: 12px;
        min-width: 40px;
    }
    
    .globe-icon {
        width: 12px;
        height: 12px;
    }
    
    .current-language-indicator {
        font-size: 8px;
    }
    
    .language-code {
        font-size: 10px;
    }
    
    .language-option {
        padding: 6px 8px;
    }
}

.welcome-content {
    text-align: center;
    color: var(--text-primary);
    max-width: 700px;
    padding: 40px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 0;
    box-shadow: none;
}

.welcome-content h1 {
    font-family: var(--font-heading);
    font-size: 2em;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 20px;
    text-shadow: none;
}

/* Instructions section */
.instructions-section {
    margin: 30px 0;
    text-align: left;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.instructions-container {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 0;
}

.instructions-header {
    padding: 15px;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
}

.instructions-header:hover {
    background: var(--hover-bg);
}

.instructions-header h2 {
    font-family: var(--font-heading);
    font-size: 1.4em;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.chevron {
    color: var(--chevron-color);
    transition: transform 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chevron svg {
    color: var(--chevron-color);
    stroke: var(--chevron-color);
}

.instructions-content {
    padding: 0;
}

.instructions-content ul {
    list-style-type: none;
    padding-left: 0;
    margin: 15px;
}

.instructions-content li {
    padding: 8px 0;
    padding-left: 20px;
    position: relative;
    font-family: var(--font-primary);
    color: var(--text-secondary);
}

.instructions-content li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--chevron-color);
    font-weight: bold;
}

.instruction-block {
    margin: 0;
    padding: 10px 15px;
}

.instruction-block h3 {
    font-family: var(--font-heading);
    font-size: 1em;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.instruction-block p {
    font-family: var(--font-primary);
    font-size: .8em;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
}

.instruction-block p strong {
    color: var(--text-primary);
    font-weight: bold;
}

.welcome-message {
    margin: 30px 0;
    font-family: var(--font-primary);
    font-size: .9em;
    color: var(--text-secondary);
    line-height: 1.6;
}

.welcome-message p {
    margin: 15px 0;
}

#dayNumber {
    font-weight: bold;
    color: var(--success-color);
    font-size: 22px;
}

.welcome-buttons {
    margin-top: 40px;
    display: grid;
    grid-template-columns: 200px 200px; /* Fixed button widths */
    grid-template-rows: auto auto;
    row-gap: 12px;
    column-gap: 12px;
    justify-content: center; /* Center the entire grid */
    align-items: start;
    /* Isolate from parent container changes */
    position: relative;
    z-index: 1;
}

/* Ensure buttons have consistent sizing within the grid */
.welcome-buttons .btn {
    width: 200px !important; /* Fixed width to prevent any stretching */
    max-width: 200px !important; /* Force maximum width */
    height: auto !important;
    min-height: 54px !important; /* Consistent height */
    padding: 8px 10px !important; /* Reduced padding for longer text */
    box-sizing: border-box !important;
    font-size: 0.82em !important; /* Consistent smaller font for all buttons to fit longest translations */
    line-height: 1.1 !important; /* Tight line height */
    white-space: normal !important; /* Allow text wrapping */
    word-wrap: break-word !important;
    hyphens: auto !important;
    text-align: center !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important; /* Prevent any overflow */
}



.welcome-footer {
    position: relative;
    text-align: center;
    font-family: var(--font-primary);
    font-size: 0.85em;
    color: var(--text-secondary);
    padding: 10px 20px;
    flex-shrink: 0; /* Don't shrink the footer */
}

.welcome-footer p {
    margin: 0;
}

.welcome-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.welcome-footer a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* Mars Yard theme - red Instagram link hover */
.theme-mars .welcome-footer a:hover {
    color: #ff0000;
}

/* Mars Yard theme - red line count in main menu */
.theme-mars .welcome-message strong {
    color: #ff0000;
}

/* Matrix theme - green line count in main menu */
.theme-matrix .welcome-message strong {
    color: #00ff41;
}

/* Matrix theme - green footer link hover in welcome screen */
.theme-matrix .welcome-footer a:hover {
    color: #00ff41;
}

.welcome-stats {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 14px;
    opacity: 0.9;
}

.welcome-stats span {
    font-weight: bold;
    color: var(--success-color);
}

/* Push-up Challenge Styles */
.pushup-challenge {
    text-align: center;
}

.pushup-challenge h2 {
    font-family: var(--font-heading);
    font-size: 1.2em;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.pushup-challenge p {
    margin: 10px 0;
    line-height: 1.4;
}

.pushup-input {
    margin: 30px 0;
}

.pushup-input label {
    display: block;
    margin-bottom: 10px;
    font-family: var(--font-primary);
    font-size: .9em;
    color: var(--text-secondary);
}

.pushup-input input {
    width: 50px;
    padding: 4px 0;
    font-size: .9em;
    font-weight: normal;
    text-align: left;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font-primary);
    outline: none;
    caret-color: var(--text-primary);
    margin-left: 0;
}

/* Style the number input spinners */
.pushup-input input[type="number"] {
    -moz-appearance: textfield; /* Firefox - hide spinners */
    appearance: textfield; /* Standard property for compatibility */
}

.pushup-input input[type="number"]::-webkit-outer-spin-button,
.pushup-input input[type="number"]::-webkit-inner-spin-button {
    height: 20px;
    width: 16px;
    margin: 0;
    opacity: 0.4;
    background: transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.pushup-input input[type="number"]::-webkit-outer-spin-button:hover,
.pushup-input input[type="number"]::-webkit-inner-spin-button:hover {
    opacity: 1;
    background: transparent !important;
    background-color: transparent !important;
}

.pushup-input input[type="number"]::-webkit-outer-spin-button:active,
.pushup-input input[type="number"]::-webkit-inner-spin-button:active {
    opacity: 1;
    background: transparent;
    transform: scale(0.95);
}

.pushup-input input:focus {
    outline: none;
    background: transparent;
}



.pushup-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: nowrap;
    align-items: center;
}

/* Ensure consistent button ordering: secondary (back/cancel) on left, primary (action) on right */
.pushup-buttons .btn.secondary {
    order: 1;
}

.pushup-buttons .btn.primary {
    order: 2;
}

/* Options Screen Styles */
.options-section {
    margin: 30px 0;
    text-align: left;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.setting-group {
    margin-bottom: 25px;
    padding: 15px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 0;
}

.setting-group label {
    display: block;
    font-family: var(--font-heading);
    font-size: 1em;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.setting-group input[type="range"] {
    width: 100%;
    margin: 10px 0;
    accent-color: var(--border-color);
}

.setting-group input[type="color"] {
    width: 60px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: 0;
    background: none;
    cursor: pointer;
}



.setting-group span {
    font-family: var(--font-primary);
    font-size: .9em;
    color: var(--text-secondary);
    margin-left: 10px;
}



.options-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* Ensure consistent button ordering: secondary (back) on left, primary (save) on right */
.options-buttons .btn.secondary {
    order: 1;
}

.options-buttons .btn.primary {
    order: 2;
}

.pushup-question {
    font-family: var(--font-primary);
    font-size: .9em;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.pushup-explanation {
    font-family: var(--font-primary);
    font-size: .9em;
    color: var(--text-secondary);
    margin: 0;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px; /* Normal padding since footer flows naturally */
    }
    
    header h1 {
        font-size: 20px;
    }
    
    .controls {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    .controls .btn {
        width: 190px !important;
        min-width: 190px !important;
        min-height: 58px !important;
        font-size: 13px !important;
        padding: 10px 6px !important;
    }
    
    .welcome-content {
        padding: 30px 20px;
        margin: 20px;
    }
    
    /* Welcome container - footer now flows naturally, no extra padding needed */
    
    .welcome-content h1 {
        font-size: 28px;
    }
    
    .welcome-message {
        font-size: 16px;
    }
    
    .welcome-buttons {
        grid-template-columns: 1fr;
        row-gap: 10px;
        column-gap: 0;
    }
    
    .welcome-buttons .btn {
        width: 180px !important;
        font-size: 0.78em !important; /* Consistent font size for all buttons on tablet */
        padding: 8px 8px !important; /* Consistent padding for all buttons */
    }
    
    .welcome-footer {
        font-size: 0.8em;
        padding: 8px 15px;
    }
    
    .btn.large {
        min-width: 200px;
        font-size: 16px;
    }
}

/* Footer Styles */
.app-footer {
    position: relative;
    padding: 20px 20px 10px 20px;
    text-align: center;
    font-family: var(--font-primary);
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-top: auto;
}

.app-footer p {
    margin: 0;
}

.app-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.app-footer a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* Mars Yard theme - red Instagram link hover */
.theme-mars .app-footer a:hover {
    color: #ff0000;
}

/* Matrix theme - green footer link hover in main app */
.theme-matrix .app-footer a:hover {
    color: #00ff41;
}

/* Remove padding since footer now flows naturally */

/* Prevent overflow in game interface entirely */
#gameContainer {
    overflow: visible; /* Allow icons to be visible outside bounds */
    height: 100vh;
    box-sizing: border-box;
}

/* Ensure all game content fits within viewport with fixed positioning when shrinking */
.game-layout {
    height: 100vh;
    min-height: 500px; /* Prevent game UI from being pushed above viewport */
    overflow: visible; /* Allow icons to be visible outside bounds */
    padding-top: 10px; /* Ensure content doesn't hit the very top */
}

#game-main {
    overflow: visible; /* Allow icons to be visible outside bounds */
    height: 100%;
    min-height: 450px; /* Maintain minimum height for game content */
    display: flex;
    flex-direction: column;
}

/* Prevent overflow when game is active and hide footer */
body.game-active {
    overflow: hidden;
}

body.game-active .app-footer {
    display: none;
}

@media (max-width: 480px) {
    .instructions {
        padding: 15px;
    }
    
    .welcome-buttons .btn {
        width: 160px !important;
        font-size: 0.75em !important; /* Consistent font size for all buttons on mobile */
        padding: 6px 8px !important; /* Consistent padding for all buttons */
    }
    
    .welcome-footer {
        font-size: 0.75em;
        padding: 8px 15px;
    }
    
    .app-footer {
        padding: 8px 15px;
        font-size: 0.8em;
    }
    
    /* Footer now flows naturally, no body padding needed */
    
    .welcome-footer {
        font-size: 0.8em;
        padding: 8px 15px;
    }
}

/* CJK language specific font and typography adjustments */
body:lang(zh) {
    --font-primary: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "SimHei", monospace;
    --font-heading: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "SimHei", sans-serif;
}

body:lang(ja) {
    --font-primary: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", monospace;
    --font-heading: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
}

body:lang(ko) {
    --font-primary: "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", "Nanum Gothic", "Dotum", monospace;
    --font-heading: "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", "Nanum Gothic", "Dotum", sans-serif;
}

/* CJK specific typography improvements */
body:lang(zh) .btn,
body:lang(ja) .btn,
body:lang(ko) .btn {
    word-break: keep-all;
    overflow-wrap: break-word;
    line-height: 1.4;
}

/* Better spacing for CJK characters */
body:lang(zh) h1,
body:lang(ja) h1,
body:lang(ko) h1 {
    letter-spacing: 0.02em;
}

body:lang(zh) p,
body:lang(ja) p,
body:lang(ko) p {
    line-height: 1.6;
}

