/* ── Griddle — styles ──────────────────────────────────────────────────────── */

:root {
    --g-green:   #6aaa64;
    --g-yellow:  #c9b458;
    --g-blue:    #4a90d9;
    --g-gray:    #787c7e;
    --g-empty:   #ffffff;
    --g-border:  #d3d6da;
    --g-solved:  #f0f8f0;
    --g-text:    #1a1a1b;
    --g-radius:  6px;
    --cell-size:  clamp(48px, 11vw, 62px);
    --label-size: 22px;
}

/* ── Splash screen ───────────────────────────────────────────────────────────── */

#griddle-splash {
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    transition: opacity 0.4s ease;
}

#griddle-splash-inner {
    text-align: center;
    max-width: 420px;
    width: 100%;
}

/* Title: row of coloured letter tiles */
#griddle-splash-title {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.title-letter {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.9rem;
    font-weight: 800;
    border-radius: var(--g-radius);
    color: #fff;
    opacity: 0;
    transform: scale(0.5);
    animation: splash-tile-in 0.35s ease-out forwards;
}

.title-letter.green  { background: var(--g-green);  }
.title-letter.yellow { background: var(--g-yellow); }
.title-letter.blue   { background: var(--g-blue);   }
.title-letter.gray   { background: var(--g-gray);   }

/* Stagger each title tile */
#griddle-splash-title .title-letter:nth-child(1) { animation-delay: 0.05s; }
#griddle-splash-title .title-letter:nth-child(2) { animation-delay: 0.12s; }
#griddle-splash-title .title-letter:nth-child(3) { animation-delay: 0.19s; }
#griddle-splash-title .title-letter:nth-child(4) { animation-delay: 0.26s; }
#griddle-splash-title .title-letter:nth-child(5) { animation-delay: 0.33s; }
#griddle-splash-title .title-letter:nth-child(6) { animation-delay: 0.40s; }
#griddle-splash-title .title-letter:nth-child(7) { animation-delay: 0.47s; }

@keyframes splash-tile-in {
    0%   { opacity: 0; transform: scale(0.4) rotateY(90deg); }
    65%  { transform: scale(1.12) rotateY(0deg); }
    100% { opacity: 1; transform: scale(1) rotateY(0deg); }
}

/* Decorative 5×5 grid */
#griddle-splash-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    max-width: 200px;
    margin: 0 auto 1.5rem;
}

.splash-cell {
    aspect-ratio: 1;
    border-radius: 5px;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.splash-cell.shown { opacity: 1; transform: scale(1); }

.splash-cell.green  { background: var(--g-green);  }
.splash-cell.yellow { background: var(--g-yellow); }
.splash-cell.blue   { background: var(--g-blue);   }
.splash-cell.gray   { background: var(--g-gray);   }
.splash-cell.empty  { background: var(--g-empty);  border: 2px solid var(--g-border); }

/* Streak */
#griddle-splash-streak {
    font-size: 1rem;
    font-weight: 700;
    color: var(--g-green);
    margin: 0 0 1rem;
    min-height: 1.4rem;
}

/* Tagline */
#griddle-splash-tagline {
    font-size: 0.95rem;
    font-weight: 700;
    color: #555;
    margin: 0 0 1rem;
    letter-spacing: 0.01em;
}

/* Welcome blurb */
#griddle-splash-welcome {
    font-size: 0.88rem;
    color: #555;
    line-height: 1.65;
    margin: 0 0 1.75rem;
}

/* Play button */
#griddle-splash-btn {
    display: inline-block;
    padding: 14px 40px;
    font-size: 1.05rem;
    font-weight: 700;
    background: var(--g-green);
    color: #fff;
    border: none;
    border-radius: var(--g-radius);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    margin-bottom: 1.5rem;
}

#griddle-splash-btn:hover {
    background: #4e9b59;
    transform: translateY(-1px);
}

/* Creator credit */
#griddle-splash-credit {
    font-size: 0.75rem;
    color: #bbb;
    margin: 0;
    letter-spacing: 0.04em;
}

#griddle-splash-credit a {
    color: #bbb;
    text-decoration: underline;
    text-underline-offset: 2px;
}

#griddle-splash-credit a:hover {
    color: #888;
}

/* ── App wrapper ─────────────────────────────────────────────────────────────── */

#griddle-app {
    font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
    max-width: 500px;
    margin: 0 auto;
    padding: 1rem 0.5rem 2rem;
    color: var(--g-text);
    user-select: none;
}

/* ── 5×5 Grid ────────────────────────────────────────────────────────────────── */

#griddle-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin-bottom: 14px;
}

.griddle-row {
    display: flex;
    gap: 5px;
}

/* ── Row / column number labels ──────────────────────────────────────────────── */

.griddle-col-headers {
    display: flex;
    gap: 5px;
}

.griddle-row-spacer {
    width: var(--label-size);
    flex-shrink: 0;
}

.griddle-col-header {
    width: var(--cell-size);
    height: var(--label-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #bbb;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.griddle-row-label {
    width: var(--label-size);
    height: var(--cell-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #bbb;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

/* Highlighted labels when that row / col is active */
.griddle-row-label.active-label {
    color: #fff;
    background: var(--g-green);
}

.griddle-col-header.active-label {
    color: #fff;
    background: var(--g-blue);
}

/* ── Active row / column highlighting ────────────────────────────────────────── */

/* Active row: green tint on blank cells */
.griddle-row.active-row .griddle-cell:not(.green):not(.yellow):not(.blue):not(.gray):not(.solution) {
    background: #dff5de;
    border-color: var(--g-green);
}

/* Active col: blue tint on blank cells */
.griddle-cell.active-col:not(.green):not(.yellow):not(.blue):not(.gray):not(.solution) {
    background: #daeeff;
    border-color: var(--g-blue);
    box-shadow: none;
}

/* Solved row: light green background strip */
.griddle-row.solved-row {
    background: var(--g-solved);
    border-radius: var(--g-radius);
    padding: 2px;
}

.griddle-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border: 2px solid var(--g-border);
    border-radius: var(--g-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.1rem, 3.5vw, 1.6rem);
    font-weight: 700;
    text-transform: uppercase;
    background: var(--g-empty);
    transition: border-color 0.1s, box-shadow 0.1s;
    perspective: 250px;
    cursor: pointer;
}

/* Color classes applied after scoring */
.griddle-cell.green  { background: var(--g-green);  border-color: var(--g-green);  color: #fff; }
.griddle-cell.yellow { background: var(--g-yellow); border-color: var(--g-yellow); color: #fff; }
.griddle-cell.blue   { background: var(--g-blue);   border-color: var(--g-blue);   color: #fff; }
.griddle-cell.gray   { background: var(--g-gray);   border-color: var(--g-gray);   color: #fff; }

/* Solved column: bottom tick mark */
.griddle-cell.solved-col::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.7);
}

.griddle-cell.solved-col {
    position: relative;
}

/* ── Cursor: next-letter position indicator ──────────────────────────────────── */

/* White ring + dark outer glow — visible on any cell colour */
.griddle-cell.cursor-cell {
    animation: griddle-cursor-blink 1s step-end infinite;
}

@keyframes griddle-cursor-blink {
    0%, 100% { box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(0, 0, 0, 0.55); }
    50%       { box-shadow: none; }
}

/* ── Flip animation ──────────────────────────────────────────────────────────── */

@keyframes griddle-flip {
    0%   { transform: rotateY(0deg);  }
    49%  { transform: rotateY(90deg); }
    50%  { transform: rotateY(90deg); }
    100% { transform: rotateY(0deg);  }
}

.griddle-cell.flipping {
    animation: griddle-flip 0.5s ease-in-out forwards;
}

/* ── Puzzle number ───────────────────────────────────────────────────────────── */

#griddle-puzzle-number {
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: #aaa;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 0 0 6px;
}

/* ── Hint text below the grid ────────────────────────────────────────────────── */

#griddle-hint {
    text-align: center;
    font-size: 0.78rem;
    color: #aaa;
    margin-bottom: 10px;
    letter-spacing: 0.02em;
}

/* ── Status message ──────────────────────────────────────────────────────────── */

#griddle-status {
    min-height: 1.4rem;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--g-text);
}

#griddle-status.error   { color: #c62828; }
#griddle-status.success { color: var(--g-green); }

/* ── Guess counter ───────────────────────────────────────────────────────────── */

#griddle-score {
    text-align: center;
    font-size: 0.78rem;
    color: #888;
    margin-bottom: 8px;
    letter-spacing: 0.03em;
    font-weight: 600;
}

/* ── Share button ────────────────────────────────────────────────────────────── */

#griddle-share-area {
    text-align: center;
    margin-bottom: 14px;
}

#griddle-share {
    padding: 10px 28px;
    font-size: 1rem;
    font-weight: 700;
    background: var(--g-green);
    color: #fff;
    border: none;
    border-radius: var(--g-radius);
    cursor: pointer;
    transition: background 0.15s;
}

#griddle-share:hover { background: #4e9b59; }

/* ── Debug / control buttons ─────────────────────────────────────────────────── */

#griddle-debug-area {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

#griddle-debug-area button {
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: var(--g-radius);
    cursor: pointer;
    transition: background 0.15s;
}

#griddle-show-solution {
    background: #e0e0e0;
    color: #444;
    border: 1px solid #bbb;
}
#griddle-show-solution:hover  { background: #ccc; }
#griddle-show-solution.danger { background: #c62828; color: #fff; border-color: #c62828; }

#griddle-help-btn {
    background: #4a90d9;
    color: #fff;
    border: 1px solid #357abd;
}
#griddle-help-btn:hover { background: #357abd; }

#griddle-reset {
    background: #e0e0e0;
    color: #c62828;
    border: 1px solid #bbb;
}
#griddle-reset:hover   { background: #ccc; }
#griddle-reset.danger  { background: #c62828; color: #fff; border-color: #c62828; }

/* ── Revealed (hint) cell ────────────────────────────────────────────────────── */

.griddle-cell.revealed {
    background: #f3e5f5;
    border: 2px dashed #9c27b0;
    color: #6a1b9a;
}

/* ── Right-click reveal popup ────────────────────────────────────────────────── */

#griddle-reveal-popup {
    position: fixed;
    z-index: 600;
    background: #fff;
    border: 1px solid var(--g-border);
    border-radius: var(--g-radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    padding: 12px 16px;
    min-width: 170px;
}

.reveal-popup-msg {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0 0 10px;
    text-align: center;
    color: var(--g-text);
}

.reveal-popup-btns {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.reveal-popup-btns button {
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: var(--g-radius);
    cursor: pointer;
}

#griddle-reveal-yes {
    background: #9c27b0;
    color: #fff;
    border: 1px solid #7b1fa2;
}
#griddle-reveal-yes:hover { background: #7b1fa2; }

#griddle-reveal-no {
    background: #e0e0e0;
    color: #444;
    border: 1px solid #bbb;
}
#griddle-reveal-no:hover { background: #ccc; }

/* Solution overlay painted directly on grid cells */
.griddle-cell.solution {
    background: #f5f5f5;
    border-color: #bbb;
    color: #333;
}

/* ── Help modal ──────────────────────────────────────────────────────────────── */

#griddle-help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

#griddle-help-modal {
    background: #fff;
    border-radius: 10px;
    max-width: 480px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    position: relative;
}

#griddle-help-modal h2 {
    font-size: 1.1rem;
    font-weight: 700;
    padding: 1rem 1rem 0.5rem;
    margin: 0;
    border-bottom: 1px solid var(--g-border);
}

#griddle-help-body {
    overflow-y: auto;
    padding: 0.75rem 1rem 1rem;
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--g-text);
}

#griddle-help-body h3 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #555;
    margin: 1rem 0 0.3rem;
}

#griddle-help-body p  { margin: 0.3rem 0; }
#griddle-help-body ul { margin: 0.3rem 0; padding-left: 1.4rem; }
#griddle-help-body li { margin-bottom: 0.3rem; }

#griddle-help-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: #888;
    padding: 2px 6px;
    border-radius: 4px;
}
#griddle-help-close:hover { background: #f0f0f0; color: #333; }

/* Colour chips used inside help text */
.help-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    vertical-align: middle;
    margin: 0 2px;
}
.help-chip.green  { background: var(--g-green); }
.help-chip.yellow { background: var(--g-yellow); }
.help-chip.blue   { background: var(--g-blue); }
.help-chip.gray   { background: var(--g-gray); }

/* ── On-screen keyboard ──────────────────────────────────────────────────────── */

#griddle-keyboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
}

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

.kb-key {
    height: 46px;
    min-width: 30px;
    padding: 0 4px;
    font-size: 0.85rem;
    font-weight: 700;
    border: none;
    border-radius: 4px;
    background: #d3d6da;
    color: #1a1a1b;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.1s, color 0.1s, opacity 0.1s;
    flex: 1;
    max-width: 42px;
    touch-action: manipulation;
}

.kb-key:hover:not(:disabled) { filter: brightness(0.88); }
.kb-key:disabled { cursor: default; }

.kb-back {
    max-width: 56px;
    font-size: 1.1rem;
}

.kb-tab {
    max-width: 70px;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

.kb-space {
    flex: 4;
    max-width: 220px;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

/* Key states — best score seen for that letter */
.kb-key.kb-green  { background: var(--g-green);  color: #fff; }
.kb-key.kb-yellow { background: var(--g-yellow); color: #fff; }
.kb-key.kb-blue   { background: var(--g-blue);   color: #fff; }
.kb-key.kb-gray   { background: var(--g-gray);   color: #fff; opacity: 0.55; }

/* ── Responsive ──────────────────────────────────────────────────────────────── */

@media (max-width: 400px) {
    :root { --cell-size: 48px; }

    #griddle-input  { max-width: 140px; font-size: 0.95rem; }
    #griddle-submit { padding: 10px 12px; font-size: 0.9rem; }
}
