* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f5f5f7;
    color: #333;
}

.game-wrap {
    max-width: 420px;
    margin: 0 auto;
    padding: 24px 16px 120px;
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-header h1 {
    margin: 0 0 6px;
    font-size: 2em;
    color: #764ba2;
    letter-spacing: 0.04em;
}

.game-header p {
    margin: 0;
    color: #666;
    font-size: 0.95em;
}

#puzzle-date {
    font-weight: 600;
    color: #667eea;
}

.hub-wrap {
    max-width: 440px;
    margin: 0 auto;
    padding: 32px 16px 80px;
}

.hub-card {
    background: #fff;
    border-radius: 14px;
    padding: 28px 24px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.hub-card h2 {
    margin: 0 0 16px;
    color: #764ba2;
    font-size: 1.75em;
}

.hub-card p {
    text-align: left;
    line-height: 1.55;
    color: #555;
    margin: 0 0 14px;
}

.hub-cta-label {
    font-weight: 700;
    color: #333;
    margin-top: 20px !important;
}

.difficulty-ctas {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 12px 0 20px;
}

.difficulty-cta {
    display: block;
    text-decoration: none;
    text-align: center;
}

.hub-info-link {
    color: #667eea;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.95em;
}

.hub-info-link:hover {
    text-decoration: underline;
}

.scenario-back {
    display: block;
    text-align: center;
    margin-bottom: 12px;
    color: #667eea;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.9em;
}

.scenario-back:hover {
    text-decoration: underline;
}

.status-bar {
    text-align: center;
    margin-bottom: 14px;
}

#solution-badge {
    display: inline-block;
    background: #fff;
    border: 2px solid #764ba2;
    color: #764ba2;
    font-weight: 700;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.95em;
    margin-bottom: 8px;
}

#progress {
    margin: 0;
    color: #555;
    font-weight: 600;
}

#found-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    min-height: 28px;
    margin: 10px 0 16px;
}

.found-chip {
    background: #28a745;
    color: #fff;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.9em;
    letter-spacing: 0.06em;
}

#submit-btn {
    display: block;
    width: 100%;
    max-width: 320px;
    margin: 0 auto 16px;
    padding: 14px;
    font-size: 1.05em;
    font-weight: 800;
    letter-spacing: 0.08em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

#submit-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#submit-btn:not(:disabled):active {
    transform: scale(0.98);
}

.cell.input.found-col {
    background: #d4edda;
    border-color: #28a745;
}

#grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 0 auto 16px;
    max-width: 320px;
}

.cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45em;
    font-weight: 700;
    border-radius: 8px;
    border: 2px solid transparent;
    user-select: none;
    text-transform: uppercase;
}

.cell.disabled {
    visibility: hidden;
    pointer-events: none;
}

.cell.clue {
    background: #fff;
    border-color: #ddd;
    color: #333;
    cursor: default;
}

.cell.throughline-row {
    background: #f3edff;
}

.cell.input {
    background: #fff;
    border-color: #764ba2;
    color: #333;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(118, 75, 162, 0.15);
}

.cell.input.active {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.25);
}

.cell.input.filled {
    background: #fff;
}

.cell.win {
    background: #28a745;
    border-color: #1e7e34;
    color: #fff;
    animation: pop 0.35s ease;
}

@keyframes pop {
    0% { transform: scale(0.92); }
    60% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

#message {
    text-align: center;
    min-height: 1.4em;
    margin-bottom: 12px;
    font-weight: 600;
    color: #dc3545;
}

#message.success {
    color: #28a745;
}

.hidden-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    height: 0;
    width: 0;
}

#keyboard {
    display: grid;
    gap: 6px;
    max-width: 360px;
    margin: 0 auto;
}

.kb-row {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.kb-key {
    min-width: 32px;
    height: 48px;
    padding: 0 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    font-weight: 700;
    font-size: 1em;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.kb-key:active {
    transform: scale(0.96);
    background: #f0f0f0;
}

.kb-key.wide {
    min-width: 56px;
    font-size: 0.85em;
}

#info-link {
    display: block;
    text-align: center;
    margin-top: 20px;
    color: #667eea;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

#info-link:hover {
    text-decoration: underline;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 10001;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

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

.modal {
    background: #fff;
    border-radius: 14px;
    padding: 28px 24px;
    max-width: 440px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.modal h2 {
    margin: 0 0 12px;
    color: #764ba2;
}

.modal p, .modal li {
    text-align: left;
    line-height: 1.55;
    color: #555;
}

.modal ul {
    padding-left: 1.2em;
}

.modal-btn {
    margin-top: 20px;
    padding: 14px 28px;
    font-size: 1.05em;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.modal-btn:hover {
    opacity: 0.92;
}

.win-stats {
    margin: 16px 0;
    text-align: center;
    background: #f8f8fa;
    border-radius: 8px;
    padding: 12px 16px;
}

.win-verticals {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.win-vertical-word {
    font-weight: 600;
    font-size: 1.15em;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #333;
}

.win-throughline-letter {
    display: inline-block;
    margin: 0 1px;
    padding: 2px 7px;
    border-radius: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.35);
}

.win-throughline-answer {
    font-weight: 800;
    font-size: 1.05em;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #764ba2;
    margin-bottom: 8px;
}

.win-solution-block {
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e0e0e6;
}

.win-solution-block:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.win-other-tiers {
    margin-bottom: 16px;
}

.win-other-label {
    text-align: center;
    margin: 0 0 10px;
    font-weight: 600;
    color: #555;
    font-size: 0.95em;
}

.win-tier-btn {
    display: block;
    text-decoration: none;
    margin-bottom: 8px;
}

.win-tier-btn:last-child {
    margin-bottom: 0;
}

#win-actions .modal-btn#share-btn {
    margin-top: 0;
}

@media (max-width: 380px) {
    .cell { font-size: 1.2em; }
    .kb-key { min-width: 28px; height: 44px; }
}
