/* Base Styles and Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

/* Responsive height management for iframe vs full browser */
#gameContainer {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* Full browser detection */
@media (min-height: 500px) {
    #gameContainer {
        height: 90vh;
    }
}

/* Tooltip Styles */
.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    max-width: 200px;
    text-align: center;
}

.tooltip.show {
    opacity: 1;
}

/* Game Header */
.game-header {
    background: linear-gradient(90deg, #4CAF50, #45a049);
    color: white;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: help;
}

.shop-name {
    font-weight: bold;
    font-size: 16px;
}

.coins {
    font-weight: bold;
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
}

/* Main Game Layout */
.game-main {
    flex: 1;
    display: grid;
    grid-template-columns: 200px 1fr 180px;
    gap: 8px;
    padding: 8px;
    overflow: hidden;
}

/* Panel Styles */
.left-panel, .right-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    background: #e3f2fd;
    padding: 8px 12px;
    font-weight: bold;
    color: #1976d2;
    border-bottom: 1px solid #bbdefb;
    cursor: help;
    font-size: 14px;
}

/* Orders List */
.orders-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.order-card {
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.order-card:hover {
    border-color: #4CAF50;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
    transform: translateY(-2px);
}

.order-card.active {
    border-color: #4CAF50;
    background: #f1f8e9;
}

.customer-info {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.customer-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 8px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.customer-name {
    font-weight: bold;
    font-size: 12px;
    color: #333;
}

.project-type {
    font-size: 11px;
    color: #666;
    margin-bottom: 6px;
}

.shape-preview {
    width: 60px;
    height: 40px;
    margin: 6px auto;
    border: 2px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #333;
}

.shape-preview.rectangle {
    border-radius: 4px;
}

.shape-preview.square {
    width: 40px;
    height: 40px;
    border-radius: 4px;
}

.shape-preview.triangle {
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-bottom: 35px solid #333;
    border: none;
    background: none;
}

.dimensions {
    font-size: 10px;
    color: #555;
    text-align: center;
}

.reward {
    background: #fff3e0;
    color: #f57c00;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: bold;
    text-align: center;
    margin-top: 4px;
}

/* Center Panel - Work Area */
.center-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.work-area {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}

.welcome-message {
    text-align: center;
    color: #666;
}

.welcome-message h3 {
    color: #333;
    margin-bottom: 8px;
}

/* Project Work Area */
.project-workspace {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.project-header {
    background: #e8f5e8;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.project-title {
    font-weight: bold;
    color: #2e7d32;
    margin-bottom: 4px;
}

.project-description {
    font-size: 12px;
    color: #555;
}

.shape-workspace {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #fafafa;
    border-radius: 8px;
    margin-bottom: 16px;
}

.shape-display {
    position: relative;
    cursor: pointer;
}

.shape-display.rectangle {
    border: 3px solid #333;
    border-radius: 4px;
    background: rgba(76, 175, 80, 0.1);
}

.shape-display.square {
    border: 3px solid #333;
    border-radius: 4px;
    background: rgba(76, 175, 80, 0.1);
}

.shape-display.triangle {
    width: 0;
    height: 0;
    border-left: 60px solid transparent;
    border-right: 60px solid transparent;
    border-bottom: 100px solid rgba(76, 175, 80, 0.3);
    position: relative;
}

.dimension-label {
    position: absolute;
    background: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    color: #333;
    border: 1px solid #ddd;
}

.measuring-tape {
    position: absolute;
    border: 2px dashed #ff9800;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.measuring-tape.active {
    opacity: 1;
}

.calculation-area {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.calculation-input {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.calculation-input label {
    font-weight: bold;
    min-width: 80px;
    font-size: 12px;
}

.calculation-input input {
    flex: 1;
    padding: 6px 8px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.calculation-input input:focus {
    border-color: #4CAF50;
    outline: none;
}

.submit-area {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.btn-primary {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
    font-size: 12px;
}

.btn-primary:hover {
    background: #45a049;
}

.btn-secondary {
    background: #757575;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
    font-size: 12px;
}

.btn-secondary:hover {
    background: #616161;
}

/* Tools Panel */
.tools-panel {
    background: #f5f5f5;
    padding: 8px;
    display: flex;
    gap: 8px;
    justify-content: center;
    border-top: 1px solid #e0e0e0;
}

.tool-btn {
    background: white;
    border: 2px solid #ddd;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
}

.tool-btn:hover {
    border-color: #4CAF50;
    background: #f1f8e9;
    transform: translateY(-2px);
}

/* Right Panel - Status */
.status-info {
    padding: 12px;
    flex: 1;
}

.satisfaction {
    margin-bottom: 16px;
}

.satisfaction span {
    font-size: 12px;
    font-weight: bold;
    color: #333;
}

.satisfaction-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    margin: 4px 0;
    overflow: hidden;
}

.satisfaction-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 4px;
    transition: width 0.5s;
    width: 85%;
}

.completed-orders {
    background: #e3f2fd;
    padding: 8px;
    border-radius: 6px;
    text-align: center;
    margin-bottom: 16px;
    font-size: 12px;
    font-weight: bold;
    color: #1976d2;
}

.difficulty-selector {
    font-size: 12px;
}

.difficulty-selector label {
    font-weight: bold;
    color: #333;
    display: block;
    margin-bottom: 4px;
}

.difficulty-selector select {
    width: 100%;
    padding: 6px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 11px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: relative;
    max-width: 90%;
    max-height: 80%;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 10px;
}

.close:hover {
    color: black;
}

/* Calculator Modal */
.calculator {
    max-width: 300px;
}

.calculator-display {
    margin-bottom: 16px;
}

.calculator-display input {
    width: 100%;
    padding: 12px;
    font-size: 18px;
    text-align: right;
    border: 2px solid #ddd;
    border-radius: 6px;
}

.calculator-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.calculator-buttons button {
    padding: 12px;
    font-size: 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: #f5f5f5;
    transition: background 0.3s;
}

.calculator-buttons button:hover {
    background: #e0e0e0;
}

.calculator-buttons .equals {
    background: #4CAF50;
    color: white;
    grid-row: span 2;
}

.calculator-buttons .zero {
    grid-column: span 2;
}

/* Formula Helper Modal */
.formula-helper {
    max-width: 500px;
}

.formula-item {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding: 16px;
    background: #f9f9f9;
    border-radius: 8px;
}

.shape-visual {
    width: 60px;
    height: 60px;
    margin-right: 20px;
    border: 3px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shape-visual.rectangle {
    border-radius: 4px;
    background: rgba(76, 175, 80, 0.1);
}

.shape-visual.square {
    border-radius: 4px;
    background: rgba(76, 175, 80, 0.1);
}

.shape-visual.triangle {
    width: 0;
    height: 0;
    border-left: 30px solid transparent;
    border-right: 30px solid transparent;
    border-bottom: 50px solid rgba(76, 175, 80, 0.3);
    border: none;
    background: none;
}

.formula-text h4 {
    color: #333;
    margin-bottom: 8px;
}

.formula-text p {
    margin: 4px 0;
    font-family: monospace;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
}

/* Feedback Modal */
.feedback {
    max-width: 400px;
    text-align: center;
}

.feedback-success {
    color: #4CAF50;
}

.feedback-error {
    color: #f44336;
}

.feedback h3 {
    margin-bottom: 16px;
}

.feedback p {
    margin-bottom: 12px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .game-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }
    
    .left-panel, .right-panel {
        max-height: 120px;
    }
    
    .orders-list {
        display: flex;
        gap: 8px;
        overflow-x: auto;
    }
    
    .order-card {
        min-width: 140px;
        margin-bottom: 0;
    }
    
    .modal-content {
        margin: 10% auto;
        max-width: 95%;
    }
    
    .tool-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Touch-friendly adjustments */
@media (pointer: coarse) {
    .tool-btn, .btn-primary, .btn-secondary {
        min-height: 44px;
        min-width: 44px;
    }
    
    .order-card {
        padding: 16px;
    }
    
    .calculation-input input {
        min-height: 44px;
    }
}