/* General Styling */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: #f8f8f8;
    color: #333;
    margin: 0;
    padding: 2rem;
    width: 100%;
    height: auto;
    overflow-y: hidden !important;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 50px; 
}

/* Controls Panel */
.controls-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 2rem;
    margin-bottom: 2rem;
}

.header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.logo {
    height: 80px;
}

h1 {
    font-size: 2rem;
    color: #2d3748;
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.settings-column, .words-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Form Elements */
label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #4a5568;
}

input[type="text"], input[type="number"], select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #f7f1f0;
    border-radius: 8px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: #f15f44;
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background-color: #fffbfa;
    border: 2px solid #f7f1f0;
    border-radius: 8px;
    cursor: pointer;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #f15f44;
}

.checkbox-title {
    font-weight: 600;
}

.checkbox-desc {
    font-size: 0.9rem;
    color: #665855;
}

/* Word List */
.word-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.word-list-container {
    border: 2px solid #f7f1f0;
    border-radius: 8px;
    padding: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
    background-color: #fffbfa;
}

.word-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
    padding: 0.5rem;
    border: 1px solid #f7f1f0;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.word-item:last-child {
    margin-bottom: 0;
}

/* Buttons */
button {
    cursor: pointer;
    border-radius: 8px;
    border: none;
    transition: background-color 0.2s;
}

.icon-btn {
    background: linear-gradient(135deg, #f15f44 0%, #ff6b6b 100%);
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    padding: 0 1rem;
}

.icon-btn:hover {
    background: linear-gradient(135deg, #d1402b 0%, #e04040 100%);
}

.text-btn {
    background: none;
    color: #f15f44;
    font-size: 0.8rem;
}

.text-btn:hover {
    text-decoration: underline;
}

.remove-word-btn {
    background: none;
    color: #f15f44;
}

.generate-btn {
    width: 100%;
    background: linear-gradient(90deg, #f15f44, #ff6b6b);
    color: white;
    padding: 1rem;
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.generate-btn:hover {
    background: linear-gradient(90deg, #d1402b, #e04040);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Maze Output Area */
.maze-output-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 2rem;
}

.maze-grid-wrapper {
    display: grid;
    padding: 5px;
    background-color: #f0f0f0;
    border-radius: 4px;
    gap: 1px;
  }

  .grid-label {
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: #555;
    background-color: transparent; 
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
  }

  .maze-grid {
    display: contents;
  }

.maze-grid-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.maze-grid {
    display: grid;
    gap: 0;
    border: 2px solid black;
}

.maze-cell {
    width: 70px;
    height: 70px;
    background-color: white;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.8rem;
    padding: 4px;
    border: 1px solid #ccc;
}

.maze-cell span {
    /* Wrap long words */
    word-wrap: break-word; 
    /* clamp font size: min 10px, preferred based on viewport/cell, max 14px */
    font-size: clamp(10px, 1.5vw, 14px); 
    line-height: 1.1;
    max-width: 100%;
}

.cell-masked {
    background-color: #f8f9fa; /* Same as body bg to look transparent */
    /* OR use a pattern */
    background-image: radial-gradient(#cbd5e0 1px, transparent 1px);
    background-size: 4px 4px;
}

/* Cell Colors */
.cell-entrance { background-color: #dcfce7; font-weight: bold; }
.cell-exit { background-color: #fef9c3; font-weight: bold; }
.cell-treasure { background-color: #fcd34d; font-weight: bold; color: #78350f; }
.cell-key { background-color: #dbeafe; font-weight: bold; color: #1e3a8a; }
.cell-hint { background-color: #fee2e2; font-weight: bold; color: #991b1b; }

.cell-portal { 
    background-color: #e9d5ff; /* Light Purple */
    font-weight: bold; 
    color: #6b21a8; /* Dark Purple text */
    border: 2px dashed #a855f7 !important; /* Dashed border to indicate magic/teleport */
}

/* Cell Walls */
.wall-top { border-top: 4px solid black !important; }
.wall-right { border-right: 4px solid black !important; }
.wall-bottom { border-bottom: 4px solid black !important; }
.wall-left { border-left: 4px solid black !important; }

/* Legend & Section Titles */
.section-title {
    text-align: center;
    margin-bottom: 1.5rem;
}
.section-title h2 { margin: 0.5rem 0; color: #2d3748; }
.section-title p { margin: 0; color: #718096; }

.legend {
    background-color: #fffbfa;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.legend h3 { margin-top: 0; }
.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.legend-swatch {
    width: 24px;
    height: 24px;
    border: 2px solid #4a5568;
}

/* Download Button */
.download-btn {
    background: linear-gradient(90deg, #f15f44, #ff6b6b);
    color: white;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 1rem auto 0;
}
.download-btn:hover {
    background: linear-gradient(90deg, #d1402b, #e04040);
}


/* Print Styles */
@media print {
    body {
        padding: 0;
        background-color: white;
    }
    .no-print {
        display: none !important;
    }
    .maze-output-panel {
        display: block !important;
        box-shadow: none;
        border-radius: 0;
        padding: 0;
    }
    .container {
        max-width: 100%;
    }
    @page {
        margin: 1cm;
        size: landscape;
    }
@media print {
    .cell-portal {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}