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

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #e8e8e8;
    padding: 2rem;
}

.literacy-font {
    font-family: 'Andika', 'Comic Sans MS', cursive, sans-serif;
}

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

h1 {
    text-align: center;
    margin-bottom: 0.5rem;
    font-size: 2.2rem;
    background: linear-gradient(90deg, #f39c12, #e74c3c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    text-align: center;
    color: #888;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

/* Header with install button */
.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    flex-wrap: wrap;
}

.btn-install {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: none;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.btn-install:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.4);
}

.btn-install.visible {
    display: inline-flex;
}

@media (max-width: 500px) {
    .btn-install {
        margin-top: 0.5rem;
    }
}

.main-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 950px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.panel h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #f39c12;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: #aaa;
}

.input-group input[type="number"],
.input-group input[type="text"],
.input-group select {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group select {
    cursor: pointer;
}

.input-group select option {
    background: #1a1a2e;
    color: #fff;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #f39c12;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.2);
}

.grid-size-inputs {
    display: flex;
    gap: 1rem;
}

.grid-size-inputs .input-group {
    flex: 1;
    margin-bottom: 0;
}

/* Sound list display */
.sound-list-display {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 0.5rem;
    max-height: 80px;
    overflow-y: auto;
}

.sound-list-display::-webkit-scrollbar {
    width: 6px;
}

.sound-list-display::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.sound-list-display::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sound-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.sound-chip {
    padding: 0.2rem 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: 'Andika', 'Comic Sans MS', cursive, sans-serif;
    color: #aaa;
}

/* Options section */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.option-item:hover {
    background: rgba(0, 0, 0, 0.3);
}

.option-item.full-width {
    grid-column: 1 / -1;
}

.option-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #f39c12;
    cursor: pointer;
}

.option-item label {
    font-size: 0.85rem;
    color: #ccc;
    cursor: pointer;
    user-select: none;
}

.case-selector {
    display: flex;
    gap: 0.5rem;
}

.case-btn {
    flex: 1;
    padding: 0.6rem;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    color: #aaa;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.case-btn:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.case-btn.active {
    border-color: #f39c12;
    background: rgba(243, 156, 18, 0.15);
    color: #f39c12;
}

.case-btn .preview {
    font-family: 'Andika', 'Comic Sans MS', cursive, sans-serif;
    font-size: 1.1rem;
    display: block;
    margin-top: 0.25rem;
}

/* Phoneme input boxes */
.phoneme-entry {
    margin-bottom: 1rem;
}

.phoneme-boxes {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.phoneme-box {
    width: 36px;
    height: 40px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s;
    font-family: 'Andika', 'Comic Sans MS', cursive, sans-serif;
}

.phoneme-box:focus {
    outline: none;
    border-color: #f39c12;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.2);
    background: rgba(243, 156, 18, 0.1);
}

.phoneme-box.valid {
    border-color: #27ae60;
    background: rgba(39, 174, 96, 0.15);
}

.phoneme-box.invalid {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.15);
}

.phoneme-box::placeholder {
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.7rem;
}

.entry-hint {
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.5rem;
}

.entry-hint kbd {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-family: inherit;
    color: #aaa;
}

.validation-legend {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: #888;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-dot.valid {
    background: rgba(39, 174, 96, 0.5);
    border: 2px solid #27ae60;
}

.legend-dot.invalid {
    background: rgba(231, 76, 60, 0.5);
    border: 2px solid #e74c3c;
}

/* Word list */
.word-list {
    max-height: 180px;
    overflow-y: auto;
    margin-top: 1rem;
    padding-right: 0.5rem;
}

.word-list::-webkit-scrollbar {
    width: 6px;
}

.word-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.word-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.word-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
}

.word-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.word-item.has-warning {
    border-left: 3px solid #e74c3c;
}

.word-phonemes {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

.word-phoneme {
    padding: 0.25rem 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #ddd;
    font-family: 'Andika', 'Comic Sans MS', cursive, sans-serif;
}

.word-phoneme.invalid {
    background: rgba(231, 76, 60, 0.3);
    color: #e74c3c;
}

.btn {
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-remove {
    background: transparent;
    color: #888;
    padding: 0.3rem 0.6rem;
    font-size: 1.1rem;
}

.btn-remove:hover {
    color: #e74c3c;
}

.btn-primary {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    width: 100%;
    padding: 0.9rem;
    font-size: 1rem;
    margin-top: 0.5rem;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ddd;
    width: 100%;
    padding: 0.8rem;
    margin-top: 0.5rem;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-clear {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.btn-clear:hover {
    background: rgba(231, 76, 60, 0.3);
}

/* Grid Display */
.grid-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.puzzle-title {
    font-family: 'Andika', 'Comic Sans MS', cursive, sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #f39c12;
    text-align: center;
}

.word-search-grid {
    display: inline-grid;
    gap: 3px;
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.grid-cell {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    color: #ddd;
    transition: all 0.2s;
    cursor: default;
    user-select: none;
    font-family: 'Andika', 'Comic Sans MS', cursive, sans-serif;
}

.grid-cell.small-text {
    font-size: 0.7rem;
}

.grid-cell.highlight {
    background: rgba(46, 204, 113, 0.3);
    color: #2ecc71;
}

.grid-cell:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Word List Display */
.word-list-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    max-width: 600px;
    margin-bottom: 1rem;
}

.word-chip {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Andika', 'Comic Sans MS', cursive, sans-serif;
}

.word-chip:hover {
    background: rgba(243, 156, 18, 0.3);
}

.word-chip.found {
    background: rgba(46, 204, 113, 0.3);
    text-decoration: line-through;
}

/* Play Mode Styles */
.play-mode-container {
    text-align: center;
}

.play-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.play-stat {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    font-size: 1rem;
}

.play-stat-value {
    font-weight: bold;
    color: #f39c12;
}

.grid-cell.selected {
    background: rgba(52, 152, 219, 0.5) !important;
    color: white;
    transform: scale(1.05);
}

.grid-cell.play-mode {
    cursor: pointer;
}

.grid-cell.play-mode:hover {
    background: rgba(52, 152, 219, 0.3);
}

.grid-cell.found-word {
    background: rgba(46, 204, 113, 0.3);
    color: #2ecc71;
}

.play-complete {
    background: rgba(46, 204, 113, 0.2);
    border: 2px solid rgba(46, 204, 113, 0.4);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1rem 0;
    text-align: center;
}

.play-complete h3 {
    color: #2ecc71;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.play-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.btn-play {
    background: rgba(46, 204, 113, 0.8);
    color: white;
    padding: 0.7rem 1.5rem;
}

.btn-play:hover {
    background: #2ecc71;
}

.btn-share {
    background: rgba(52, 152, 219, 0.8);
    color: white;
    padding: 0.7rem 1.5rem;
}

.btn-share:hover {
    background: #3498db;
}

.btn-exit-play {
    background: rgba(231, 76, 60, 0.8);
    color: white;
    padding: 0.7rem 1.5rem;
}

.btn-exit-play:hover {
    background: #e74c3c;
}

/* Share Modal */
.share-modal-content {
    text-align: center;
}

.share-url-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    word-break: break-all;
    font-family: monospace;
    font-size: 0.85rem;
    color: #aaa;
    max-height: 100px;
    overflow-y: auto;
}

.share-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-copy {
    background: rgba(46, 204, 113, 0.8);
    color: white;
}

.btn-copy:hover {
    background: #2ecc71;
}

.btn-copy.copied {
    background: #27ae60;
}

/* Module Import/Export */
.module-import-export {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.btn-import, .btn-export {
    flex: 1;
    min-width: 120px;
}

.import-file-input {
    display: none;
}

/* Shared puzzle view mode */
.shared-puzzle-banner {
    background: rgba(52, 152, 219, 0.2);
    border: 1px solid rgba(52, 152, 219, 0.4);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.shared-puzzle-banner p {
    margin-bottom: 0.5rem;
    color: #3498db;
}

@media print {
    .play-stats,
    .play-buttons,
    .play-complete,
    .shared-puzzle-banner {
        display: none !important;
    }
}

/* Play mode - hide unnecessary UI */
body.play-mode-active header,
body.play-mode-active .main-layout > .panel:first-child,
body.play-mode-active #installBtn {
    display: none !important;
}

body.play-mode-active .main-layout {
    grid-template-columns: 1fr !important;
    max-width: 700px;
    margin: 0 auto;
}

body.play-mode-active .container {
    padding-top: 0;
}

body.play-mode-active .panel {
    padding: 1rem;
}

/* Messages */
.message {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
}

.message.error {
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid rgba(231, 76, 60, 0.4);
    color: #e74c3c;
}

.message.success {
    background: rgba(46, 204, 113, 0.2);
    border: 1px solid rgba(46, 204, 113, 0.4);
    color: #2ecc71;
}

.message.warning {
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid rgba(231, 76, 60, 0.4);
    color: #e74c3c;
}

/* Module Editor Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #1a1a2e;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: #f39c12;
    font-size: 1.2rem;
    margin: 0;
}

.modal-header .modal-brand {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(90deg, #f39c12, #e67e22);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-header .modal-brand span {
    font-weight: 400;
    opacity: 0.8;
}

.modal-close {
    background: transparent;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

.modal-close:hover {
    color: #e74c3c;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.module-list {
    margin-bottom: 1.5rem;
}

.module-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.module-list-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.module-list-item.selected {
    background: rgba(243, 156, 18, 0.2);
    border: 1px solid rgba(243, 156, 18, 0.4);
}

.module-list-item.builtin {
    /* Built-in modules now fully editable, same styling as custom */
}

.module-list-item .module-name {
    font-weight: 600;
    color: #ddd;
}

.module-list-item .module-count {
    font-size: 0.8rem;
    color: #888;
}

.module-list-item .module-actions {
    display: flex;
    gap: 0.5rem;
}

.module-list-item .btn-icon {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
    border-radius: 4px;
}

.module-list-item .btn-icon:hover {
    color: #f39c12;
    background: rgba(255, 255, 255, 0.1);
}

.module-list-item .btn-icon.delete:hover {
    color: #e74c3c;
}

.module-editor {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1.5rem;
}

.module-editor h4 {
    color: #f39c12;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.module-editor .input-group {
    margin-bottom: 1rem;
}

.module-editor .input-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: #aaa;
}

.module-editor .input-group input {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 1rem;
}

.module-editor .input-group input:focus {
    outline: none;
    border-color: #f39c12;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.2);
}

.module-editor textarea {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 0.9rem;
    font-family: 'Andika', 'Comic Sans MS', cursive, sans-serif;
    min-height: 100px;
    resize: vertical;
}

.module-editor textarea:focus {
    outline: none;
    border-color: #f39c12;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.2);
}

.module-editor .help-text {
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.4rem;
}

.btn-manage {
    background: rgba(155, 89, 182, 0.3);
    color: #bb8fce;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    margin-left: auto;
}

.btn-manage:hover {
    background: rgba(155, 89, 182, 0.5);
}

.btn-save {
    background: #27ae60;
    color: white;
}

.btn-save:hover {
    background: #2ecc71;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: #ddd;
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-new {
    background: rgba(52, 152, 219, 0.3);
    color: #5dade2;
    width: 100%;
    margin-bottom: 1rem;
}

.btn-new:hover {
    background: rgba(52, 152, 219, 0.5);
}

.btn-save-puzzle {
    flex: 1;
    background: rgba(46, 204, 113, 0.3);
    color: #2ecc71;
    padding: 0.6rem;
    font-size: 0.85rem;
}

.btn-save-puzzle:hover {
    background: rgba(46, 204, 113, 0.5);
}

.btn-load-puzzle {
    flex: 1;
    background: rgba(52, 152, 219, 0.3);
    color: #5dade2;
    padding: 0.6rem;
    font-size: 0.85rem;
}

.btn-load-puzzle:hover {
    background: rgba(52, 152, 219, 0.5);
}

.btn-new-puzzle {
    flex: 1;
    background: rgba(155, 89, 182, 0.3);
    color: #bb8fce;
    padding: 0.6rem;
    font-size: 0.85rem;
}

.btn-new-puzzle:hover {
    background: rgba(155, 89, 182, 0.5);
}

.saved-puzzle-list {
    max-height: 400px;
    overflow-y: auto;
}

.saved-puzzle-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.saved-puzzle-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.saved-puzzle-info {
    flex: 1;
}

.saved-puzzle-name {
    font-weight: 600;
    color: #ddd;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.saved-puzzle-meta {
    font-size: 0.8rem;
    color: #888;
}

.saved-puzzle-words {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 0.5rem;
}

.saved-puzzle-word {
    padding: 0.2rem 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: 'Andika', 'Comic Sans MS', cursive, sans-serif;
    color: #aaa;
}

.saved-puzzle-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
}

.saved-puzzle-actions .btn-icon {
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 0.5rem;
    font-size: 1.1rem;
    border-radius: 4px;
}

.saved-puzzle-actions .btn-icon:hover {
    color: #f39c12;
    background: rgba(255, 255, 255, 0.1);
}

.saved-puzzle-actions .btn-icon.delete:hover {
    color: #e74c3c;
}

.no-saved-puzzles {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.module-header-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Print styles */
.print-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.print-btn {
    background: rgba(52, 152, 219, 0.8);
    color: white;
    padding: 0.7rem 1.5rem;
}

.print-btn:hover {
    background: #3498db;
}

.print-btn.answer {
    background: rgba(155, 89, 182, 0.8);
}

.print-btn.answer:hover {
    background: #9b59b6;
}

@media print {
    @page {
        margin: 1.5cm;
    }

    body {
        background: white !important;
        color: black !important;
        padding: 0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .container {
        max-width: 100%;
    }

    .main-layout {
        display: block;
    }

    .panel:first-child,
    .print-buttons,
    .direction-info {
        display: none !important;
    }

    .panel:last-child {
        background: none;
        border: none;
        padding: 0;
    }

    .puzzle-title {
        color: black !important;
        font-size: 2rem;
        margin-bottom: 1.5rem;
    }

    .word-search-grid {
        background: none;
        padding: 0;
        gap: 2px;
        margin-bottom: 2rem;
    }

    .grid-cell {
        width: 36px;
        height: 36px;
        border: 1px solid #333;
        background: white !important;
        color: black !important;
        border-radius: 2px;
        font-size: 0.9rem;
    }

    .grid-cell.small-text {
        font-size: 0.6rem;
    }

    .grid-cell.highlight {
        background: #ddd !important;
        color: black !important;
    }

    .word-list-display {
        max-width: 100%;
        gap: 0.75rem;
    }

    .word-chip {
        border: 1px solid #333;
        background: white !important;
        color: black !important;
        padding: 0.4rem 0.8rem;
        font-size: 1rem;
    }

    .word-chip.found {
        background: #ddd !important;
    }

    h1, .subtitle {
        display: none;
    }
}

.direction-info {
    font-size: 0.75rem;
    color: #666;
    text-align: center;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

.preview-word {
    text-align: center;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-top: 0.5rem;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.preview-word .word-phoneme {
    font-size: 0.9rem;
}

.preview-word.empty {
    color: #555;
    font-size: 0.85rem;
}

/* Add Word button for mobile */
.btn-add-word {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
}

.btn-add-word:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.4);
}

.btn-add-word:active {
    transform: translateY(0);
}

.btn-add-word:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Mobile-specific hint styling */
.entry-hint .mobile-hint {
    display: none;
}

@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    .entry-hint .desktop-hint {
        display: none;
    }
    .entry-hint .mobile-hint {
        display: inline;
    }
}

.section-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 1.25rem 0;
}

/* ============================================
   STEPPED UI / ACCORDION STYLES
   ============================================ */

.main-layout.single-column {
    display: block;
    max-width: 600px;
    margin: 0 auto;
}

.config-panel {
    padding: 0;
    overflow: hidden;
}

.config-step {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.config-step:last-child {
    border-bottom: none;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.step-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.step-header.active {
    background: rgba(243, 156, 18, 0.1);
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: #888;
    flex-shrink: 0;
    transition: all 0.2s;
}

.step-header.active .step-number {
    background: #f39c12;
    color: #1a1a2e;
}

.step-header.completed .step-number {
    background: #27ae60;
    color: white;
}

.step-title {
    flex: 1;
}

.step-title h2 {
    font-size: 1rem;
    margin: 0;
    color: #ddd;
}

.step-header.active .step-title h2 {
    color: #f39c12;
}

.step-summary {
    font-size: 0.8rem;
    color: #666;
}

.step-toggle {
    width: 24px;
    height: 24px;
    color: #666;
    transition: transform 0.2s;
}

.step-toggle svg {
    width: 100%;
    height: 100%;
}

.step-header.active .step-toggle {
    transform: rotate(180deg);
    color: #f39c12;
}

.step-content {
    display: none;
    padding: 0 1.5rem 1.5rem 1.5rem;
    animation: slideDown 0.2s ease-out;
}

.step-content.active {
    display: block;
}

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

.step-content h3 {
    font-size: 0.95rem;
    color: #f39c12;
    margin: 1.25rem 0 0.75rem 0;
}

.step-content h3:first-child {
    margin-top: 0;
}

.step-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.btn-step-next {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    padding: 0.7rem 1.5rem;
    font-weight: 600;
    margin-left: auto;
}

.btn-step-next:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
}

/* Required field indicator */
.required {
    color: #e74c3c;
    font-weight: 600;
}

/* Help text */
.help-text {
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.4rem;
}

/* Word list header in step content */
.word-list-header {
    font-size: 0.95rem;
    color: #f39c12;
    margin: 1.25rem 0 0.5rem 0;
}

/* Generate preview */
.generate-preview {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.preview-item {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.preview-item:last-child {
    border-bottom: none;
}

.preview-label {
    color: #888;
    font-size: 0.85rem;
}

.preview-value {
    color: #ddd;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Generate requirements */
.generate-requirements {
    margin-bottom: 1rem;
}

.requirement {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    font-size: 0.85rem;
    color: #888;
}

.requirement.met {
    color: #27ae60;
}

.requirement.met .req-icon {
    color: #27ae60;
}

.req-icon {
    font-size: 1rem;
    color: #e74c3c;
    width: 20px;
    text-align: center;
}

/* Generate button */
.btn-generate {
    font-size: 1.1rem;
    padding: 1rem;
}

/* Saved puzzle actions inline */
.saved-puzzle-actions-inline {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: center;
}

.saved-puzzle-actions-inline .btn {
    flex: 1;
}

/* ============================================
   PUZZLE RESULT MODAL
   ============================================ */

.puzzle-result-modal {
    max-width: 90vw;
    max-height: 95vh;
    width: auto;
}

.puzzle-result-modal .modal-body {
    overflow: hidden;
    max-height: calc(95vh - 140px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.puzzle-result-modal #puzzleOutput {
    padding: 1rem;
    width: 100%;
    display: flex;
    justify-content: center;
}

/* Scalable puzzle wrapper */
.puzzle-scale-wrapper {
    transform-origin: top center;
    transition: transform 0.2s ease;
}

.puzzle-result-modal .grid-container {
    max-width: 100%;
}

.puzzle-result-modal .word-search-grid {
    max-width: 100%;
}

.puzzle-result-footer {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.puzzle-result-footer .btn {
    min-width: auto;
    padding: 0.6rem 1rem;
}

/* Hide the buttons in the puzzle output since they're in the modal footer */
.puzzle-result-modal .print-buttons {
    display: none;
}

/* Module header row adjustments */
.config-step .module-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.config-step .module-header-row label {
    font-size: 0.85rem;
    color: #aaa;
    margin: 0;
}

/* Override panel h2 margins in steps */
.config-step .step-content .input-group {
    margin-bottom: 1rem;
}

/* Responsive adjustments for stepped UI */
@media (max-width: 500px) {
    .main-layout.single-column {
        margin: 0;
    }

    .step-header {
        padding: 0.75rem 1rem;
    }

    .step-content {
        padding: 0 1rem 1rem 1rem;
    }

    .step-actions {
        flex-direction: column;
    }

    .btn-step-next {
        margin-left: 0;
        width: 100%;
    }

    .saved-puzzle-actions-inline {
        flex-direction: column;
    }

    .generate-preview .preview-item {
        flex-direction: column;
        gap: 0.2rem;
    }
}

/* Ensure modal works well on smaller screens */
@media (max-width: 768px) {
    .puzzle-result-modal {
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .puzzle-result-modal .modal-body {
        max-height: calc(100vh - 130px);
    }

    .puzzle-result-footer {
        padding: 0.75rem;
    }

    .puzzle-result-footer .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* Hide the right panel in the new layout */
.main-layout.single-column > .panel:last-child:not(.config-panel) {
    display: none;
}

/* Play mode adjustments for new layout */
body.play-mode-active .main-layout.single-column {
    max-width: 700px;
}

body.play-mode-active .config-panel {
    display: none;
}

/* Show puzzle output in play mode */
body.play-mode-active #puzzleOutput {
    display: block;
}

/* Create a container for play mode output outside the modal */
body.play-mode-active .puzzle-result-modal {
    display: none !important;
}

/* Play mode panel styling */
.play-mode-panel {
    max-width: 700px;
    margin: 0 auto;
}

#playModeOutput {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Shared puzzle banner in play mode */
body.play-mode-active .shared-puzzle-banner {
    display: block;
}

/* ============================================
   CREDITS SYSTEM STYLES
   ============================================ */

/* Header actions container */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Credits button in header */
.btn-credits {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-credits:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}

.btn-credits .credits-icon {
    font-size: 1rem;
}

.btn-credits .credits-count {
    font-weight: 700;
    font-size: 1rem;
}

.btn-credits .credits-label {
    font-weight: 400;
    opacity: 0.9;
}

/* Low credits warning state */
.btn-credits.low-credits {
    background: linear-gradient(135deg, #e67e22, #d35400);
    animation: pulse-warning 2s infinite;
}

.btn-credits.no-credits {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

@keyframes pulse-warning {
    0%, 100% { box-shadow: 0 0 0 0 rgba(230, 126, 34, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(230, 126, 34, 0); }
}

/* Purchase Modal Styles */
.purchase-modal {
    max-width: 700px;
}

.purchase-intro {
    text-align: center;
    color: #aaa;
    margin-bottom: 1.5rem;
}

/* Pricing Tiers Grid */
.pricing-tiers {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 600px) {
    .pricing-tiers {
        grid-template-columns: 1fr;
    }
}

.pricing-tier {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.pricing-tier:hover {
    border-color: rgba(243, 156, 18, 0.5);
    background: rgba(243, 156, 18, 0.1);
    transform: translateY(-2px);
}

.pricing-tier.popular {
    border-color: #f39c12;
    background: rgba(243, 156, 18, 0.15);
}

.tier-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    padding: 0.25rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tier-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ddd;
    margin-bottom: 0.5rem;
}

.tier-credits {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f39c12;
    margin-bottom: 0.25rem;
}

.tier-price {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.25rem;
}

.tier-per-credit {
    font-size: 0.8rem;
    color: #888;
}

/* Purchase Info Section */
.purchase-info {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 1rem;
    font-size: 0.9rem;
}

.purchase-info p {
    margin-bottom: 0.5rem;
    color: #ccc;
}

.purchase-info ul {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem 0;
}

.purchase-info li {
    padding: 0.25rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: #aaa;
}

.purchase-info li::before {
    content: '★';
    position: absolute;
    left: 0;
    color: #f39c12;
    font-size: 0.8rem;
}

.purchase-note {
    font-size: 0.8rem;
    color: #666 !important;
    margin-bottom: 0 !important;
}

/* Credit Toast Notifications */
.credit-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    font-size: 0.95rem;
    color: #ddd;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.credit-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.credit-toast-success {
    border-color: rgba(46, 204, 113, 0.5);
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.2), rgba(39, 174, 96, 0.2));
}

.credit-toast-warning {
    border-color: rgba(243, 156, 18, 0.5);
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.2), rgba(230, 126, 34, 0.2));
}

.credit-toast-error {
    border-color: rgba(231, 76, 60, 0.5);
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.2), rgba(192, 57, 43, 0.2));
}

/* Credit cost indicator on buttons */
.btn-with-cost {
    position: relative;
}

.btn-with-cost::after {
    content: attr(data-cost);
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    line-height: 1;
}

/* Hide credits button in play mode and print */
body.play-mode-active .btn-credits {
    display: none;
}

@media print {
    .btn-credits,
    .credit-toast,
    .purchase-modal {
        display: none !important;
    }
}

/* ============================================
   PRINT WATERMARK PROTECTION
   ============================================ */

/* Grid container needs relative positioning for watermark */
.grid-container {
    position: relative;
    overflow: visible;
}

/* Watermark - visible on screen by default, scales with grid */
.print-watermark {
    --grid-size: 500px; /* Default, overridden by inline style */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-25deg);
    z-index: 100;
    pointer-events: none;
    text-align: center;
    width: calc(var(--grid-size) * 1.4);
    height: calc(var(--grid-size) * 0.8);
}

.watermark-text {
    /* Font size scales with grid: ~10% of grid size, clamped between 2rem and 6rem */
    font-size: clamp(2rem, calc(var(--grid-size) * 0.12), 6rem);
    font-weight: 900;
    color: rgba(255, 255, 255, 0.18);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    white-space: nowrap;
    text-shadow:
        0 0 20px rgba(0, 0, 0, 0.4),
        0 0 40px rgba(0, 0, 0, 0.2);
    font-family: 'Andika', 'Comic Sans MS', cursive, sans-serif;
}

.watermark-subtext {
    font-size: clamp(0.7rem, calc(var(--grid-size) * 0.035), 1.5rem);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.14);
    margin-top: 0.5rem;
    letter-spacing: 0.1em;
}

/* When puzzle is unlocked (paid), hide watermark on screen */
.grid-container.puzzle-unlocked .print-watermark {
    display: none;
}

/* Print styles */
@media print {
    .watermark-text {
        color: rgba(180, 180, 180, 0.7);
        text-shadow: none;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .watermark-subtext {
        color: rgba(160, 160, 160, 0.6);
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Fade out grid when not unlocked */
    .grid-container:not(.puzzle-unlocked) .word-search-grid {
        opacity: 0.4;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .grid-container:not(.puzzle-unlocked) .word-list-display {
        opacity: 0.4;
    }

    /* When print is authorized via button, ensure watermark hidden */
    body.print-authorized .print-watermark {
        display: none !important;
    }

    body.print-authorized .word-search-grid {
        opacity: 1 !important;
    }

    body.print-authorized .word-list-display {
        opacity: 1 !important;
    }
}
