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

html {
    overflow: hidden;
    height: 100%;
}

body {
    font-family: 'Roboto Mono', monospace;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: #e0e0e0;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
}

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

header {
    margin-bottom: 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.title-section {
    flex: 1;
    min-width: 250px;
}

h1 {
    font-size: 2em;
    color: #4a9eff;
    text-shadow: 0 0 20px rgba(74, 158, 255, 0.5);
    margin-bottom: 5px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.subtitle {
    color: #888;
    font-size: 0.9em;
}

.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    font-family: 'Roboto Mono', monospace;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, #4a9eff 0%, #2575fc 100%);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

/* Modal header with settings */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-right: 40px;
    gap: 20px;
    flex-wrap: wrap;
}

.modal-header h2 {
    margin-bottom: 0;
    padding-right: 0;
}

.modal-toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: #888;
    font-size: 14px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    white-space: nowrap;
}

.modal-toggle-label input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #4a9eff;
}

.modal-toggle-label:hover {
    color: #4a9eff;
}

/* Hide numbers when checkbox is unchecked */
body.hide-numbers .cell,
body.hide-numbers .main-grid .cell.correct {
    color: transparent !important;
}

.message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    text-align: center;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 500;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    animation: slideDown 0.3s ease-out;
    max-width: 90%;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.message.success {
    background: rgba(56, 239, 125, 0.25);
    color: #38ef7d;
    border: 2px solid #38ef7d;
}

.message.error {
    background: rgba(239, 68, 68, 0.25);
    color: #ef4444;
    border: 2px solid #ef4444;
}

.loading-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
}

.loading-content {
    animation: fadeIn 0.5s ease-in;
}

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

.loading-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 30px;
    border: 4px solid #2d2d2d;
    border-top-color: #4a9eff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-state h2 {
    color: #4a9eff;
    font-size: 1.9em;
    margin-bottom: 10px;
}

.loading-state p {
    color: #888;
    font-size: 1.15em;
    transition: opacity 0.3s ease-in-out;
    min-height: 1.5em;
}

.loading-state p.fade-out {
    opacity: 0;
}

.main-grid-container,
.clues-container {
    margin-bottom: 30px;
}

.main-grid-container {
    margin-bottom: 30px;
}

.grid-with-share {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.share-button-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-share {
    background: linear-gradient(135deg, #4a9eff 0%, #2575fc 100%);
    color: white;
    white-space: nowrap;
}

.grid {
    display: grid;
    gap: 4px;
    background: #1a1a1a;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
}

.main-grid {
    grid-template-columns: repeat(4, 1fr);
    max-width: 280px;
    margin: 0 auto;
}

.main-grid .cell {
    aspect-ratio: 1;
    background: #1a1a1a;
    border: 2px solid #2d2d2d;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8em;
    font-weight: bold;
    color: #555;
    min-height: 60px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.main-grid .cell:hover {
    background: #252525;
    border-color: #4a9eff;
    transform: scale(1.05);
}

.main-grid .cell.active {
    background: #6366f1;
    border-color: #818cf8;
    color: #e0e7ff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.main-grid .cell.correct {
    background: #059669 !important;
    border-color: #34d399 !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(52, 211, 153, 0.4) !important;
}

.clues-wrapper {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
}

.clue-container {
    background: #252525;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.clue-header {
    text-align: center;
    margin-bottom: 10px;
    color: #888;
    font-weight: 600;
}

.clue-count {
    font-size: 1.2em;
    transition: color 0.3s ease;
    font-weight: 600;
}

.clue-count-satisfied {
    color: #38ef7d;
}

.clue-count-too-low {
    color: #4a9eff;
}

.clue-count-too-high {
    color: #f59e0b;
}

.clue-grid {
    grid-template-columns: repeat(4, 1fr);
    padding: 5px;
}

.clue-grid .cell {
    aspect-ratio: 1;
    background: #0d0d0d;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1em;
    color: #444;
    min-height: 40px;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    cursor: pointer;
}

/* Clue pattern cell (blue) - where the clue has a 1 */
.clue-grid .cell.clue-highlight {
    background: #334155;
    color: #cbd5e1;
    font-weight: bold;
}

/* User's answer cell (gray) - where user placed a 1 */
.clue-grid .cell.user-active {
    background: #2a2a2a;
    color: #888888;
}

/* Overlap cell (green) - where both clue AND user have 1 */
.clue-grid .cell.clue-highlight.user-active {
    background: #047857;
    color: #a7f3d0;
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.35);
    font-weight: bold;
}

/* 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.8);
    backdrop-filter: blur(5px);
    overflow-y: auto;
}

.modal-content {
    background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    color: #e0e0e0;
    position: relative;
}

.modal-content h2 {
    color: #4a9eff;
}

.modal-content h3 {
    color: #667eea;
    margin-top: 20px;
    margin-bottom: 10px;
}

.instructions {
    line-height: 1.5;
}

.instructions ul,
.instructions ol {
    margin-left: 30px;
    margin-top: 10px;
}

.instructions li {
    margin-bottom: 8px;
}

.instructions p {
    margin-bottom: 10px;
}

/* Demo cells styling */
.demo-cells-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.demo-section-header {
    color: #888;
    font-size: 0.9em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 10px;
    margin-bottom: 5px;
}

.demo-section-header:first-child {
    margin-top: 0;
}

.demo-cell-row {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px;
    background: rgba(74, 158, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(74, 158, 255, 0.15);
}

.demo-cell-container {
    flex-shrink: 0;
}

.demo-cell-container .clue-count {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    padding: 10px 15px;
    background: rgba(26, 26, 26, 0.6);
    border-radius: 8px;
    font-size: 1.3em;
}

.demo-grid {
    grid-template-columns: 1fr;
    padding: 6px;
    min-width: 60px;
}

/* Base demo cell styles (main grid style) */
.demo-grid:not(.clue-demo) .cell {
    aspect-ratio: 1;
    background: #1a1a1a;
    border: 2px solid #2d2d2d;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    font-weight: bold;
    color: #555;
    min-height: 50px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Active cell in demo (main grid active style) */
.demo-grid:not(.clue-demo) .cell.active {
    background: #6366f1;
    border-color: #818cf8;
    color: #e0e7ff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Correct cell in demo (main grid correct style) */
.demo-grid:not(.clue-demo) .cell.correct {
    background: #059669 !important;
    border-color: #34d399 !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(52, 211, 153, 0.4) !important;
}

/* Base clue demo cell styles */
.demo-grid.clue-demo .cell {
    aspect-ratio: 1;
    background: #0d0d0d;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
    color: #444;
    min-height: 50px;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Clue pattern cell (blue) - where the clue has a 1 */
.demo-grid.clue-demo .cell.clue-highlight {
    background: #334155;
    color: #cbd5e1;
    font-weight: bold;
}

/* User's answer cell (gray) - where user placed a 1 */
.demo-grid.clue-demo .cell.user-active {
    background: #2a2a2a;
    color: #888888;
}

/* Overlap cell (green) - where both clue AND user have 1 */
.demo-grid.clue-demo .cell.clue-highlight.user-active {
    background: #047857;
    color: #a7f3d0;
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.35);
    font-weight: bold;
}

.demo-cell-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.demo-cell-label strong {
    color: #4a9eff;
    font-size: 1em;
}

.demo-cell-label span {
    color: #888;
    font-size: 0.9em;
}

/* Example section styles */
.example-grids {
    display: flex;
    gap: 30px;
    justify-content: center;
    align-items: flex-start;
    margin: 20px 0;
    flex-wrap: wrap;
}

.example-grid-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.example-grid-title {
    color: #888;
    font-size: 0.9em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.example-clue-header {
    text-align: center;
    margin-top: 5px;
}

.example-clue-header .clue-count {
    font-size: 1.2em;
    padding: 8px 12px;
}

.example-main-grid {
    grid-template-columns: repeat(4, 1fr);
    max-width: 240px;
}

.example-main-grid .cell {
    aspect-ratio: 1;
    background: #1a1a1a;
    border: 2px solid #2d2d2d;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    font-weight: bold;
    color: #555;
    min-height: 50px;
}

.example-main-grid .cell.active {
    background: #6366f1;
    border-color: #818cf8;
    color: #e0e7ff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.example-clue-grid {
    grid-template-columns: repeat(4, 1fr);
    max-width: 240px;
}

.example-clue-grid .cell {
    aspect-ratio: 1;
    background: #0d0d0d;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
    color: #444;
    min-height: 50px;
}

.example-clue-grid .cell.clue-highlight {
    background: #334155;
    color: #cbd5e1;
    font-weight: bold;
}

.example-clue-grid .cell.user-active {
    background: #2a2a2a;
    color: #888888;
}

.example-clue-grid .cell.clue-highlight.user-active {
    background: #047857;
    color: #a7f3d0;
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.35);
    font-weight: bold;
}

.example-explanation {
    background: rgba(74, 158, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(74, 158, 255, 0.15);
    padding: 15px;
    margin-top: 10px;
}

.example-explanation p {
    margin-bottom: 10px;
}

.example-explanation ul {
    margin-left: 20px;
}

.example-explanation li {
    margin-bottom: 8px;
    color: #ccc;
}

/* Summary section styles */
.summary-section {
    background: rgba(102, 126, 234, 0.08);
    border-radius: 8px;
    border: 2px solid rgba(102, 126, 234, 0.25);
    padding: 20px;
    margin-top: 15px;
}

.summary-section p {
    margin-bottom: 10px;
}

.summary-section ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.summary-section li {
    margin-bottom: 8px;
    color: #ccc;
}

.summary-section .encouragement {
    margin-top: 15px;
    margin-bottom: 0;
    padding-top: 15px;
    border-top: 1px solid rgba(102, 126, 234, 0.25);
    color: #4a9eff;
    font-style: italic;
    text-align: center;
    line-height: 1.6;
}

/* Modal footer styles */
.modal-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid rgba(74, 158, 255, 0.2);
    text-align: center;
}

.modal-footer p {
    color: #888;
    font-size: 0.9em;
    margin-bottom: 0;
}

.modal-footer strong {
    color: #4a9eff;
    font-weight: 600;
}

/* Share modal styles */
.share-modal-content {
    margin-top: 20px;
}

.share-modal-content p {
    color: #ccc;
    margin-bottom: 15px;
}

.share-link-container {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.share-link-input {
    flex: 1;
    padding: 12px 16px;
    background: #1a1a1a;
    border: 2px solid #2d2d2d;
    border-radius: 8px;
    color: #4a9eff;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9em;
    transition: border-color 0.3s ease;
}

.share-link-input:focus {
    outline: none;
    border-color: #4a9eff;
}

.share-link-container .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.close {
    color: #888;
    position: sticky;
    top: 0;
    float: right;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
    line-height: 1;
    z-index: 1;
}

.close:hover {
    color: #4a9eff;
}

/* Modal responsive styles */
@media (max-width: 768px) {
    .modal {
        padding: 10px;
    }

    .modal-content {
        margin: 2% auto;
        padding: 25px 20px;
        width: 95%;
        max-height: 90vh;
    }

    .modal-content h2 {
        font-size: 1.5em;
    }

    .modal-content h3 {
        font-size: 1.2em;
    }
}

@media (max-width: 480px) {
    .modal {
        padding: 5px;
    }

    .modal-content {
        margin: 0;
        padding: 20px 15px;
        width: 100%;
        max-height: 95vh;
        border-radius: 8px;
    }

    .modal-content h2 {
        font-size: 1.3em;
        margin-bottom: 15px;
    }

    .modal-content h3 {
        font-size: 1.1em;
        margin-top: 15px;
    }

    .instructions {
        font-size: 0.95em;
    }

    .close {
        font-size: 28px;
    }

    .demo-cell-row {
        gap: 12px;
        padding: 10px;
    }

    .demo-grid {
        min-width: 50px;
    }

    .demo-grid.clue-demo .cell {
        min-height: 40px;
        font-size: 1.1em;
    }

    .demo-grid:not(.clue-demo) .cell {
        min-height: 40px;
        font-size: 1.3em;
    }

    .demo-cell-label strong {
        font-size: 0.9em;
    }

    .demo-cell-label span {
        font-size: 0.85em;
    }

    .example-grids {
        gap: 20px;
    }

    .example-main-grid,
    .example-clue-grid {
        max-width: 200px;
    }

    .example-main-grid .cell {
        font-size: 1.3em;
        min-height: 42px;
    }

    .example-clue-grid .cell {
        font-size: 1.1em;
        min-height: 42px;
    }

    .example-explanation {
        padding: 12px;
        font-size: 0.9em;
    }

    .share-link-container {
        flex-direction: column;
    }

    .share-link-input {
        font-size: 0.8em;
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .clues-wrapper {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .title-section {
        text-align: center;
        width: 100%;
    }

    .controls {
        justify-content: center;
        width: 100%;
    }

    h1 {
        font-size: 2em;
    }

    .clues-wrapper {
        grid-template-columns: repeat(2, 1fr);
    }

    .main-grid .cell {
        font-size: 1.5em;
        min-height: 60px;
    }
}

@media (max-width: 480px) {
    .clues-wrapper {
        grid-template-columns: 1fr;
    }

    .controls {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        width: 100%;
    }
}

/* Beta Banner */
.beta-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(74, 158, 255, 0.15);
    border-top: 2px solid #4a9eff;
    backdrop-filter: blur(10px);
    z-index: 998;
    animation: slideUp 0.4s ease-out;
}

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

.beta-banner.hidden {
    animation: slideDownOut 0.3s ease-in forwards;
}

@keyframes slideDownOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(100%);
    }
}

.beta-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 12px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.beta-banner-text {
    color: #4a9eff;
    font-size: 0.9em;
    font-weight: 500;
}

.beta-banner-dismiss {
    background: transparent;
    border: none;
    color: #4a9eff;
    cursor: pointer;
    font-size: 0.85em;
    text-decoration: underline;
    transition: all 0.2s ease;
    font-family: 'Roboto Mono', monospace;
    padding: 0;
    flex-shrink: 0;
}

.beta-banner-dismiss:hover {
    color: #6eb4ff;
    text-decoration: none;
}

@media (max-width: 768px) {
    .beta-banner-content {
        padding: 10px 15px;
    }

    .beta-banner-text {
        font-size: 0.85em;
    }

    .beta-banner-dismiss {
        font-size: 0.8em;
    }
}
