/* === TRIANGLE SIMILARITY GAME STYLES === */

/* === CSS VARIABLES - RUSTIC NOTEBOOK THEME === */
:root {
    --notebook-bg: #f4f1e8;
    --paper-white: #fefcf7;
    --ink-dark: #2c1810;
    --ink-medium: #5d4037;
    --ink-light: #8d6e63;
    --accent-rust: #8b4513;
    --accent-warm: #d2691e;
    --line-blue: #4682b4;
    --highlight-yellow: #fff3cd;
    --shadow-brown: rgba(101, 67, 33, 0.2);
    --border-aged: #c8b99c;
}

/* === CORE LAYOUT === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: var(--notebook-bg);
    background-image: 
        linear-gradient(90deg, var(--border-aged) 1px, transparent 1px),
        linear-gradient(var(--border-aged) 1px, transparent 1px);
    background-size: 20px 20px;
    color: var(--ink-dark);
    position: fixed;
    width: 100%;
    height: 100%;
}

/* === MAIN GAME CONTAINER === */
.game-container {
    display: grid;
    grid-template-areas:
        "working working matching score"
        "working working selection selection";
    grid-template-columns: 1fr 1fr 200px 200px;
    grid-template-rows: 1fr 200px;
    gap: 20px;
    padding: 20px;
    height: 100vh;
    width: 100vw;
    box-sizing: border-box;
    background: var(--paper-white);
    border: 3px solid var(--accent-rust);
    border-radius: 15px;
    margin: 10px;
    box-shadow: 
        inset 0 0 20px var(--shadow-brown),
        0 8px 16px var(--shadow-brown);
    position: relative;
}

.game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 40px;
    width: 3px;
    height: 100%;
    background: var(--line-blue);
    opacity: 0.3;
}

/* === WORKING AREA === */
.working-area {
    grid-area: working;
    background: var(--paper-white);
    border: 2px solid var(--accent-rust);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: inset 0 0 10px var(--shadow-brown);
    position: relative;
}

.working-area::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(
        transparent,
        transparent 24px,
        var(--line-blue) 25px
    );
    opacity: 0.1;
    pointer-events: none;
}

.triangle-slot {
    flex: 1;
    border: 2px dashed var(--ink-light);
    border-radius: 8px;
    position: relative;
    background: var(--highlight-yellow);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px var(--shadow-brown);
}

.triangle-slot.has-triangle {
    border-color: var(--accent-rust);
    background: var(--paper-white);
    border-style: solid;
}

.slot-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: #999;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.5;
}

/* === NAVIGATION === */
.back-button {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid var(--container-border);
    background: var(--container-bg);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 1000;
}

.back-button:hover {
    border-color: var(--accent-color);
    background: var(--accent-light);
}

.back-button svg {
    width: 18px;
    height: 18px;
}

/* === MATCHING AREA === */
.matching-area {
    grid-area: matching;
    background: var(--container-bg);
    border: 2px solid var(--container-border);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.match-sequence {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
    letter-spacing: 2px;
}

/* === SCORE BOARD === */
.score-board {
    grid-area: score;
    background: var(--paper-white);
    border: 2px solid var(--accent-rust);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: inset 0 0 10px var(--shadow-brown);
    position: relative;
}

.score-display {
    font-size: 28px;
    font-weight: bold;
    color: var(--accent-rust);
    font-family: Georgia, serif;
    text-shadow: 1px 1px 2px var(--shadow-brown);
}

.found-similarities {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
}

.similarity-badge {
    background: var(--accent-rust);
    color: var(--paper-white);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
    font-family: Georgia, serif;
    box-shadow: 0 2px 4px var(--shadow-brown);
    border: 1px solid var(--ink-medium);
}

/* === SELECTION AREA === */
.selection-area {
    grid-area: selection;
    background: var(--paper-white);
    border: 2px solid var(--accent-rust);
    border-radius: 12px;
    padding: 15px;
    overflow-y: auto;
    box-shadow: inset 0 0 10px var(--shadow-brown);
    position: relative;
}

.selection-area::before {
    content: 'Available Triangles';
    position: absolute;
    top: -12px;
    left: 15px;
    background: var(--paper-white);
    padding: 0 8px;
    font-family: Georgia, serif;
    font-size: 14px;
    font-weight: bold;
    color: var(--ink-dark);
}

.no-triangles-message {
    text-align: center;
    color: #8b4513;
    font-size: 16px;
    font-weight: bold;
    padding: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    border: 2px dashed #8b4513;
}

.triangle-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    height: 100%;
    padding: 10px;
    align-content: flex-start;
}

.triangle-preview-btn {
    width: 80px;
    height: 80px;
    border: 2px solid var(--border-aged);
    border-radius: 8px;
    background: var(--highlight-yellow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 8px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px var(--shadow-brown);
}

.triangle-preview-btn:hover {
    border-color: var(--accent-rust);
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow-brown);
    background: var(--paper-white);
}

.triangle-preview-btn.disabled-triangle {
    opacity: 0.5;
    pointer-events: none;
    background: #f5f5f5;
}

.triangle-preview-svg {
    width: 100%;
    height: 100%;
    max-width: 60px;
    max-height: 60px;
}

/* === TRIANGLE SVG STYLING === */
.triangle-svg {
    width: 280px;
    height: 280px;
    pointer-events: all;
    filter: drop-shadow(2px 2px 4px var(--shadow-brown));
}

.triangle-side {
    stroke: var(--side-default);
    stroke-width: 3;
    fill: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.triangle-side.selected {
    stroke: var(--side-selected);
    stroke-width: 4;
}

.triangle-side.matched {
    stroke: var(--side-matched);
    stroke-width: 4;
}

.side-click-area {
    fill: transparent;
    stroke: transparent;
    stroke-width: 12;
    cursor: pointer;
}

.angle-arc {
    stroke: var(--angle-default);
    stroke-width: 2;
    fill: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.angle-arc.selected {
    stroke: var(--angle-selected);
    stroke-width: 3;
}

.angle-arc.matched {
    stroke: var(--angle-matched);
    stroke-width: 3;
}

.angle-click-area {
    fill: transparent;
    cursor: pointer;
}

.angle-mark {
    stroke: var(--angle-default);
    stroke-width: 1.5;
    transition: all 0.2s ease;
}

.angle-mark.selected {
    stroke: var(--angle-selected);
}

.angle-mark.matched {
    stroke: var(--angle-matched);
}

.centroid-click {
    fill: rgba(255, 107, 53, 0.3);
    stroke: #ff6b35;
    stroke-width: 2;
    cursor: pointer;
    transition: all 0.2s ease;
}

.centroid-click:hover {
    fill: rgba(255, 107, 53, 0.5);
}

/* === ROTATION CONTROLS === */
.rotate-btn {
    position: absolute;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 100;
}

.rotate-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

#rotate-left {
    bottom: 20px;
    left: 20px;
}

#rotate-right {
    bottom: 20px;
    left: 80px;
}

.score-display {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.score-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* === SELECTION AREA === */
.selection-area {
    grid-area: selection-area;
    background: var(--container-bg);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid var(--container-border);
}

.triangle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 10px;
    height: 100%;
}

.triangle-preview-btn {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border: 2px solid var(--container-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 8px;
}

.triangle-preview-btn:hover {
    border-color: var(--accent-color);
    background: var(--accent-light);
}

.triangle-preview-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.triangle-preview-btn.selected {
    border-color: var(--accent-color);
    background: var(--accent-light);
}

.triangle-preview-svg {
    width: 80%;
    height: 80%;
    pointer-events: none;
}

/* === ROTATION CONTROLS === */
.rotation-area {
    grid-area: rotation-area;
    background: var(--container-bg);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid var(--container-border);
}

.rotate-btn {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    background: #f8f9fa;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    border: 2px solid var(--container-border);
    transition: all 0.2s ease;
}

.rotate-btn:hover {
    border-color: var(--accent-color);
    background: var(--accent-light);
}

.rotate-btn:active {
    transform: scale(0.95);
}

.rotate-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* === TRIANGLE RENDERING === */
.triangle-svg {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80%;
    height: 80%;
    transform: translate(-50%, -50%);
    max-width: 250px;
    max-height: 250px;
    cursor: pointer;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.triangle-svg.selected-for-rotation {
    filter: drop-shadow(0 0 8px rgba(255, 152, 0, 0.6));
}

.triangle-side {
    stroke: var(--side-default);
    stroke-width: 2;
    fill: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.triangle-side:hover {
    stroke: var(--accent-color);
    stroke-width: 3;
}

.triangle-side.selected {
    stroke: var(--side-selected);
    stroke-width: 4;
}

.triangle-side.matched {
    stroke: var(--side-matched) !important;
    stroke-width: 4px !important;
    cursor: not-allowed !important;
}

.triangle-angle {
    fill: none;
    stroke: var(--angle-default);
    stroke-width: 1.5;
    cursor: pointer;
    transition: all 0.2s ease;
}

.triangle-angle:hover {
    stroke: var(--accent-color);
    stroke-width: 2;
}

.triangle-angle.selected {
    stroke: var(--angle-selected);
    stroke-width: 3;
}

.triangle-angle.matched {
    stroke: var(--angle-matched) !important;
    stroke-width: 3px !important;
    cursor: not-allowed !important;
}

/* === ANGLE ARCS === */
.angle-arc {
    fill: none;
    stroke: var(--angle-default);
    stroke-width: 1.5;
    pointer-events: none;
}

.angle-arc.selected {
    stroke: var(--angle-selected);
    stroke-width: 2.5;
}

.angle-arc.matched {
    stroke: var(--angle-matched) !important;
    stroke-width: 2.5px !important;
}

.angle-click-area {
    fill: transparent;
    stroke: transparent;
    cursor: pointer;
    transition: all 0.2s;
    pointer-events: all;
}

.angle-click-area:hover {
    fill: rgba(255, 107, 53, 0.15);
    stroke: rgba(255, 107, 53, 0.3);
    stroke-width: 1;
}

.angle-click-area.matched {
    cursor: not-allowed !important;
}

/* === VERTEX LABELS === */
.vertex-label {
    font-family: 'Arial', sans-serif;
    font-weight: bold;
    font-size: 16px;
    fill: var(--text-primary);
    pointer-events: none;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

/* === CENTROID CLICK AREA === */
.centroid-click {
    fill: rgba(33, 150, 243, 0.4);
    stroke: #2196F3;
    stroke-width: 1.5;
    cursor: pointer;
    transition: all 0.2s;
    pointer-events: all;
}

.centroid-click:hover {
    fill: rgba(33, 150, 243, 0.6);
    stroke-width: 2;
}

.triangle-svg.selected-for-rotation .centroid-click {
    fill: rgba(255, 152, 0, 0.7);
    stroke: #FF9800;
    stroke-width: 2;
}

/* === POPUP STYLES === */
.billy-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.billy-popup-content {
    background: var(--container-bg);
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

.billy-popup img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    margin-bottom: 20px;
    border: 3px solid var(--side-matched);
}

.billy-popup p {
    font-size: 1.2rem;
    line-height: 1.6;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.billy-popup button {
    background: var(--side-matched);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.billy-popup button:hover {
    background: #45a049;
    transform: translateY(-2px);
}

/* === MOBILE ORIENTATION === */
.rotate-message {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background-main);
    z-index: 1000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
}

.phone-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    color: var(--angle-default);
}

.rotate-message p {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    max-width: 80%;
    line-height: 1.5;
}

@media (max-height: 500px) and (orientation: landscape) {
    .rotate-message {
        display: none !important;
    }
    
    .game-container {
        display: grid !important;
    }
}

@media (max-width: 768px) and (orientation: portrait) {
    .rotate-message {
        display: flex;
    }
    
    .game-container {
        display: none !important;
    }
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* === SIMILARITY POPUP STYLES === */
.similarity-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 2px solid #fff;
}

.popup-title {
    color: #fff;
    font-size: 24px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.popup-image {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 20px auto;
    display: block;
    border: 3px solid #fff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.popup-text {
    color: #fff;
    font-size: 16px;
    line-height: 1.6;
    margin: 20px 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.popup-close {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.popup-close:hover {
    background: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}

/* Mobile landscape enforcement */
@media screen and (max-width: 768px) and (orientation: portrait) {
    body::before {
        content: "Please rotate your device to landscape mode for the best experience";
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.9);
        color: white;
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 9999;
        font-size: 18px;
        text-align: center;
        padding: 20px;
        box-sizing: border-box;
    }
}
