:root {
    --bg-beige: #f4f1ea;
    --primary-blue: #0072b1;
    --primary-hover: #005582;
    --text-dark: #333333;
    --text-light: #666666;
    --white: #ffffff;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    background-color: var(--bg-beige);
    color: var(--text-dark);
    font-family: var(--font-main);
    height: 100vh;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 500px;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    padding: 20px;
    background-color: var(--bg-beige);
    overflow-y: auto;
}

.screen.active { display: flex; }

/* --- HOME SCREEN UI --- */
.home-layout {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.main-title {
    font-size: 48px;
    font-weight: 800;
    color: var(--primary-blue);
    margin-bottom: 15px;
}

.subtitle {
    font-size: 18px;
    color: var(--text-light);
    margin-bottom: 40px;
    line-height: 1.5;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

/* --- SHINING BUTTON STYLE (Applied to Start, Next, and Home buttons) --- */
.start-btn {
    background: linear-gradient(135deg, #0099ff 0%, #0066ff 100%);
    color: white;
    font-size: 20px;
    font-weight: 700;
    padding: 16px 50px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 102, 255, 0.4); 
    margin-bottom: 50px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: auto; /* Default width */
}

.start-btn:active { 
    transform: scale(0.95);
    box-shadow: 0 4px 10px rgba(0, 102, 255, 0.4);
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(0, 102, 255, 0.5);
}

/* New class for smaller home button in game screen */
.small-home-btn {
    padding: 12px 40px;
    font-size: 18px;
    margin-bottom: 0;
}

/* Spacing between buttons on result screen */
.button-spacing {
    margin-bottom: 15px;
    width: 100%;
}

.how-to-title {
    font-size: 26px;
    font-weight: 800;
    color: black;
    margin-bottom: 20px;
}

.instruction-box {
    background: var(--white);
    border: 2px solid var(--primary-blue);
    border-radius: 12px;
    padding: 25px 30px; 
    max-width: 440px; 
    margin: 0 auto 50px auto;
    text-align: center;
}

.instruction-box p {
    font-size: 16px; 
    color: black;
    margin-bottom: 12px;
    font-weight: 600;
    line-height: 1.5;
}

.instruction-box p:last-child { margin-bottom: 0; }

.footer {
    font-size: 18px; 
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: black;
    margin-bottom: 20px;
}

.linkedin-link {
    color: var(--primary-blue);
    font-size: 26px; 
    text-decoration: none;
}

/* --- GAME SCREEN STYLES --- */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-top: 20px;
}

.difficulty-text {
    color: black;
    font-size: 24px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.timer-icon {
    font-size: 24px;
}

.timer-large {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-dark);
    font-variant-numeric: tabular-nums;
}

.board-wrapper {
    width: 100%;
    aspect-ratio: 1;
    position: relative;
    background: white;
    border: 4px solid var(--text-dark);
    border-radius: 8px;
    touch-action: none;
    margin-bottom: 20px;
}

.grid-base {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    width: 100%;
    height: 100%;
}

.cell { border: 1px solid #e0e0e0; }

.path-layer, .numbers-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}
.path-layer { z-index: 5; }
.numbers-layer { z-index: 10; display: grid; grid-template-columns: repeat(6, 1fr); }

.number-cell {
    display: flex; align-items: center; justify-content: center;
}

.num-circle {
    width: 65%; height: 65%;
    background: var(--text-dark);
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; 
    font-size: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.game-controls { display: flex; gap: 10px; margin-bottom: 20px; }
.control-btn {
    flex: 1; padding: 14px; border: none; border-radius: 8px;
    font-weight: bold; cursor: pointer; color: white;
    font-size: 16px;
    background-color: #999;
    transition: background-color 0.2s, transform 0.1s;
}
.control-btn:active { transform: scale(0.98); }
.control-btn.hint { background-color: #f59e0b; }

/* Container for the new Home button in game screen */
.game-footer-actions {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

/* --- RESULT SCREEN STYLES --- */
.result-layout {
    justify-content: center;
    align-items: center;
    background-color: rgba(244, 241, 234, 0.95);
    z-index: 100;
}

.result-box {
    background: var(--white);
    padding: 40px 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0,0,0,0.1);
    max-width: 420px;
    width: 90%;
    transform: translateY(0);
    animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-title {
    font-size: 36px;
    font-weight: 900;
    color: var(--primary-blue);
    margin-bottom: 30px;
    text-transform: uppercase;
    letter-spacing: -1px;
}

.stats-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-dark);
}

.stat-divider {
    width: 2px;
    height: 40px;
    background-color: #e0e0e0;
}

.feedback-text {
    font-size: 18px;
    color: var(--text-dark);
    margin-bottom: 30px;
    line-height: 1.5;
    font-weight: 500;
    min-height: 54px;
}

/* Ensures Next Puzzle button stretches on result screen */
#next-level-btn { width: 100%; margin-bottom: 0; }

/* --- HINT VISUALS --- */
.hint-line {
    stroke: #ff9100;
    stroke-width: 14px;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    opacity: 0.6;
    pointer-events: none;
    animation: hintPulse 1.0s infinite alternate;
}

@keyframes hintPulse {
    from { opacity: 0.4; stroke-width: 12px; }
    to { opacity: 0.8; stroke-width: 16px; }
}

.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}