/* ============================================
   Cloo — shared game design system
   ============================================ */

:root {
    --bg-deep: #0f1022;
    --bg-card: rgba(255, 255, 255, 0.06);
    --bg-card-solid: #1c1e3a;
    --border-soft: rgba(255, 255, 255, 0.12);
    --text-primary: #f1f2ff;
    --text-muted: #9fa3c8;
    --accent: #8b7cf8;
    --accent-2: #f472b6;
    --accent-glow: rgba(139, 124, 248, 0.45);
    --green: #34d399;
    --red: #f87171;
    --amber: #fbbf24;
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
}

body {
    font-family: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-deep);
    background-image:
        radial-gradient(900px 500px at 15% -10%, rgba(139, 124, 248, 0.22), transparent 60%),
        radial-gradient(800px 500px at 100% 0%, rgba(244, 114, 182, 0.14), transparent 55%),
        radial-gradient(700px 600px at 50% 110%, rgba(56, 189, 248, 0.10), transparent 60%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
}

/* ---------- Shared components ---------- */

.brand-logo {
    font-weight: 900;
    letter-spacing: -0.02em;
    background: linear-gradient(92deg, #a5b4fc 0%, #c084fc 45%, #f472b6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 30px;
    border: none;
    border-radius: 999px;
    font-family: inherit;
    font-size: 1em;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, #8b7cf8 0%, #c084fc 60%, #f472b6 130%);
    color: white;
    box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px var(--accent-glow);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    color: #052e22;
    box-shadow: 0 8px 24px rgba(52, 211, 153, 0.35);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(52, 211, 153, 0.45);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-soft);
    color: var(--text-muted);
    padding: 9px 20px;
    font-size: 0.85em;
    font-weight: 700;
}

.btn-ghost:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    background: rgba(139, 124, 248, 0.1);
}

.btn-large {
    width: 100%;
    font-size: 1.15em;
    padding: 16px 30px;
}

/* ============================================
   Game page
   ============================================ */

.game-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 14px 12px 24px;
}

/* Top bar */
.game-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
    padding: 4px 2px;
}

.game-topbar .brand-logo {
    font-size: 1.7em;
    margin: 0;
    text-decoration: none;
}

.score-chips {
    display: flex;
    gap: 8px;
}

.score-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 64px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
}

.score-chip .chip-value {
    font-size: 1.05em;
    font-weight: 900;
    color: var(--text-primary);
    line-height: 1.2;
}

.score-chip .chip-label {
    font-size: 0.62em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.chip-value.bump {
    animation: chipBump 0.5s ease;
    color: var(--green);
}

@keyframes chipBump {
    30% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

.score-chip.chip-hot {
    border-color: rgba(251, 191, 36, 0.55);
    background: rgba(251, 191, 36, 0.1);
}

.badge-difficulty {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-soft);
    color: var(--text-muted);
    margin-left: 6px;
}

/* Guess dots */
.guess-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 6px;
}

.guess-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.45);
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.guess-dot.used {
    background: rgba(255, 255, 255, 0.14);
    box-shadow: none;
}

.guess-dots-label {
    font-size: 0.62em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-left: 2px;
}

/* Action row: hint + reveal-letter */
.action-row {
    display: flex;
    gap: 8px;
    margin: 14px 0 4px;
}

.action-form {
    flex: 1;
    display: flex;
}

.action-form .hint-button,
.action-form .reveal-button {
    width: 100%;
}

.reveal-button {
    background: rgba(139, 124, 248, 0.1);
    border: 1px solid rgba(139, 124, 248, 0.5);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 800;
    font-size: 0.85em;
    color: #c4b5fd;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}

.reveal-button:hover:not(:disabled) {
    background: rgba(139, 124, 248, 0.22);
    transform: translateY(-1px);
}

.reveal-button:disabled {
    cursor: default;
    opacity: 0.45;
}

/* Try-again banner */
.try-again-banner {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.5);
    color: #fde68a;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    text-align: center;
    font-weight: 800;
    font-size: 0.92em;
    margin: 12px 0 0;
    animation: fadeIn 0.35s ease;
}

.tile.tile-revealed {
    border-color: var(--amber);
    background: rgba(251, 191, 36, 0.14);
    color: #fde68a;
}

.token-earned {
    margin-top: 10px !important;
    font-size: 0.8em;
    color: #fde68a;
}

/* Puzzle card */
.puzzle-card {
    padding: 22px 20px;
    margin-bottom: 14px;
    animation: cardIn 0.4s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(14px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.puzzle-card.shake {
    animation: cardShake 0.5s ease;
}

@keyframes cardShake {
    10%, 50%, 90% { transform: translateX(-7px); }
    30%, 70% { transform: translateX(7px); }
    100% { transform: translateX(0); }
}

.puzzle-type-badge {
    text-align: center;
    margin-bottom: 14px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.badge-sound {
    background: rgba(244, 114, 182, 0.15);
    border: 1px solid rgba(244, 114, 182, 0.4);
    color: #f9a8d4;
}

.badge-image {
    background: rgba(56, 189, 248, 0.13);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #7dd3fc;
}

.puzzle-title {
    font-size: 1.02em;
    font-weight: 700;
    color: var(--text-muted);
    margin: 0 0 14px;
    text-align: center;
}

/* Clues */
.clues-section {
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.clue-item {
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.98em;
    animation: clueIn 0.45s cubic-bezier(0.2, 0.8, 0.3, 1) backwards;
}

.clue-item:nth-child(2) { animation-delay: 0.07s; }
.clue-item:nth-child(3) { animation-delay: 0.14s; }
.clue-item:nth-child(4) { animation-delay: 0.21s; }

@keyframes clueIn {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 1; transform: translateX(0); }
}

.clue-num {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(139, 124, 248, 0.18);
    border: 1px solid rgba(139, 124, 248, 0.45);
    color: #c4b5fd;
    font-size: 0.72em;
    font-weight: 900;
}

.clue-text {
    flex: 1;
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.4;
}

.letter-count {
    flex: 0 0 auto;
    font-size: 0.72em;
    font-weight: 800;
    color: #c4b5fd;
    background: rgba(139, 124, 248, 0.14);
    border-radius: 999px;
    padding: 3px 10px;
    white-space: nowrap;
}

.clue-item-image {
    justify-content: center;
    text-align: center;
    flex-direction: column;
    gap: 6px;
    padding: 18px 14px;
}

.clue-text-image {
    font-size: 3.2em;
    line-height: 1.1;
}

/* Hints */
.hint-section {
    margin: 14px 0 4px;
}

.hint-button {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.45);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 800;
    font-size: 0.88em;
    color: var(--amber);
    cursor: pointer;
    width: 100%;
    transition: background 0.2s ease, transform 0.15s ease;
}

.hint-button:hover:not(:disabled) {
    background: rgba(251, 191, 36, 0.2);
    transform: translateY(-1px);
}

.hint-button:disabled {
    cursor: default;
    opacity: 0.75;
}

.hints-container {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hint-item {
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.3);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.hint-text {
    margin: 0;
    color: #fde68a;
    font-size: 0.92em;
    font-weight: 600;
}

/* Answer tiles */
.answer-form {
    margin-top: 16px;
}

.answer-tiles {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    min-height: 46px;
    margin-bottom: 14px;
    cursor: default;
    user-select: none;
}

.tile {
    width: 40px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    font-size: 1.3em;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--text-primary);
    transition: border-color 0.12s ease, background 0.12s ease;
}

.tile.filled {
    border-color: var(--accent);
    background: rgba(139, 124, 248, 0.14);
    animation: tilePop 0.14s ease;
}

.tile.tile-extra {
    border-color: var(--amber);
    background: rgba(251, 191, 36, 0.1);
}

.tile-gap {
    width: 14px;
}

@keyframes tilePop {
    50% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

.tile.cursor {
    border-color: rgba(196, 181, 253, 0.9);
    box-shadow: 0 0 0 3px rgba(139, 124, 248, 0.22);
}

/* Keyboard */
.virtual-keyboard {
    margin: 6px 0 4px;
    user-select: none;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 6px;
    touch-action: manipulation;
}

.key-btn {
    flex: 1;
    max-width: 44px;
    padding: 0;
    height: 48px;
    font-family: inherit;
    font-size: 0.95em;
    font-weight: 800;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.09);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.12s ease, transform 0.08s ease;
}

.key-btn:hover {
    background: rgba(139, 124, 248, 0.35);
}

.key-btn:active,
.key-btn.pressed {
    transform: scale(0.92);
    background: var(--accent);
}

.key-btn-wide {
    max-width: 130px;
    flex: 3;
    font-size: 0.78em;
}

.key-btn-special {
    max-width: 66px;
    flex: 1.5;
    font-size: 0.78em;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.key-btn-enter {
    max-width: 96px;
    flex: 2;
    background: linear-gradient(135deg, #8b7cf8, #c084fc);
    color: white;
    font-size: 0.82em;
    border: none;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.key-btn-enter:hover:not(:disabled) {
    filter: brightness(1.12);
    background: linear-gradient(135deg, #8b7cf8, #c084fc);
}

.key-btn-enter:disabled {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
}

/* Result */
.result-message {
    padding: 24px 20px;
    border-radius: var(--radius-lg);
    text-align: center;
    font-size: 1.15em;
    font-weight: 800;
    margin: 18px 0 0;
    animation: resultIn 0.45s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes resultIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}

.result-message p {
    margin: 0;
}

.result-answer {
    display: block;
    margin-top: 8px;
    font-size: 1.35em;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.result-success {
    background: rgba(52, 211, 153, 0.12);
    border: 1px solid rgba(52, 211, 153, 0.5);
    color: #6ee7b7;
}

.result-error {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.45);
    color: #fca5a5;
}

.next-form {
    margin-top: 16px;
}

.game-footer {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 6px;
    padding: 8px;
}

/* Completed-all state */
.complete-card {
    text-align: center;
    padding: 40px 24px;
}

.complete-card h2 {
    font-size: 1.7em;
    margin: 0 0 8px;
}

.complete-card p {
    color: var(--text-muted);
    margin: 0 0 22px;
}

/* Confetti */
.confetti-piece {
    position: fixed;
    top: -12px;
    width: 9px;
    height: 14px;
    border-radius: 2px;
    z-index: 999;
    pointer-events: none;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    to {
        transform: translateY(105vh) rotate(720deg);
        opacity: 0.6;
    }
}

/* ============================================
   Daily mode
   ============================================ */

.mode-header {
    text-align: center;
    margin: 4px 0 12px;
}

.mode-header h2 {
    font-size: 1.3em;
    margin: 0 0 2px;
}

.mode-header .mode-sub {
    color: var(--text-muted);
    font-size: 0.85em;
    font-weight: 700;
    margin: 0;
}

.share-grid {
    display: flex;
    justify-content: center;
    gap: 6px;
    font-size: 1.9em;
    margin: 14px 0;
    letter-spacing: 0.05em;
}

.daily-streak-line {
    text-align: center;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.92em;
    margin: 6px 0 16px;
}

.share-button-row {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.share-feedback {
    text-align: center;
    color: var(--green);
    font-weight: 800;
    font-size: 0.85em;
    min-height: 1.2em;
    margin-top: 8px;
}

.countdown-line {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82em;
    font-weight: 700;
    margin-top: 14px;
}

/* ============================================
   Blitz mode
   ============================================ */

.blitz-timer {
    position: relative;
    height: 12px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 6px;
}

.blitz-timer-fill {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #34d399, #fbbf24 65%, #f87171);
    border-radius: 999px;
    transform-origin: left;
    transition: transform 1s linear;
}

.blitz-timer-label {
    text-align: center;
    font-weight: 900;
    font-size: 1.25em;
    margin-bottom: 10px;
}

.blitz-timer-label.urgent {
    color: var(--red);
    animation: chipBump 0.5s ease infinite;
}

.blitz-stats {
    display: flex;
    justify-content: center;
    gap: 16px;
    color: var(--text-muted);
    font-weight: 800;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.blitz-stats strong {
    color: var(--text-primary);
}

.blitz-flash {
    text-align: center;
    font-weight: 900;
    font-size: 1em;
    min-height: 1.3em;
    margin: 6px 0;
}

.blitz-flash.good { color: var(--green); }
.blitz-flash.bad { color: var(--red); }

.skip-form {
    margin-top: 10px;
    text-align: center;
}

.leaderboard {
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.leaderboard li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    margin-bottom: 6px;
    font-weight: 700;
}

.leaderboard .rank {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(139, 124, 248, 0.18);
    color: #c4b5fd;
    font-size: 0.8em;
    font-weight: 900;
    flex: 0 0 auto;
}

.leaderboard .run-score {
    font-weight: 900;
    color: var(--text-primary);
}

.leaderboard .run-meta {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.82em;
}

.leaderboard li.new-run {
    border-color: rgba(52, 211, 153, 0.55);
    background: rgba(52, 211, 153, 0.08);
}

/* ============================================
   Home page
   ============================================ */

.mode-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
    margin: 0 0 12px;
    text-align: left;
}

.mode-card {
    display: block;
    padding: 22px 20px;
    text-decoration: none;
    color: var(--text-primary);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.mode-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 16px 44px rgba(139, 124, 248, 0.25);
}

.mode-card .mode-icon {
    font-size: 2em;
    display: block;
    margin-bottom: 8px;
}

.mode-card h3 {
    margin: 0 0 6px;
    font-size: 1.12em;
}

.mode-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88em;
    font-weight: 600;
    line-height: 1.45;
}

.mode-card .mode-tag {
    display: inline-block;
    margin-top: 12px;
    font-size: 0.72em;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #c4b5fd;
}

/* ============================================
   Home page (hero)
   ============================================ */

.hero-container {
    max-width: 860px;
    margin: 0 auto;
    padding: 40px 18px 60px;
    text-align: center;
}

.hero-title {
    font-size: clamp(3.2em, 9vw, 4.8em);
    margin: 20px 0 6px;
    line-height: 1.05;
}

.hero-subtitle {
    font-size: 1.2em;
    color: var(--text-muted);
    font-weight: 600;
    margin: 0 0 32px;
}

.hero-features {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 36px;
}

.feature-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    font-size: 0.9em;
    font-weight: 700;
    color: var(--text-primary);
}

.cta-button {
    font-size: 1.25em;
    padding: 18px 56px;
}

.how-to-play {
    margin-top: 56px;
    text-align: left;
}

.how-to-play > h2 {
    text-align: center;
    font-size: 1.5em;
    margin: 0 0 20px;
}

.puzzle-types {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.puzzle-type-card {
    padding: 26px 24px;
}

.puzzle-type-card h3 {
    margin: 0 0 8px;
    font-size: 1.15em;
}

.puzzle-type-card .type-desc {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.95em;
    margin: 0 0 14px;
}

.example-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed var(--border-soft);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 0.9em;
    color: var(--text-muted);
    font-weight: 600;
}

.example-box strong {
    color: var(--text-primary);
}

.hero-footer {
    margin-top: 48px;
    color: var(--text-muted);
    font-size: 0.8em;
}

.hero-footer a {
    color: var(--text-muted);
}

/* ---------- Mobile ---------- */
@media (max-width: 520px) {
    .game-container {
        padding: 10px 8px 18px;
    }

    .game-topbar .brand-logo {
        font-size: 1.4em;
    }

    .score-chip {
        min-width: 54px;
        padding: 5px 8px;
    }

    .score-chip .chip-value {
        font-size: 0.95em;
    }

    .puzzle-card {
        padding: 16px 12px;
    }

    .clue-text-image {
        font-size: 2.6em;
    }

    .tile {
        width: 32px;
        height: 40px;
        font-size: 1.1em;
    }

    .tile-gap {
        width: 10px;
    }

    .keyboard-row {
        gap: 4px;
    }

    .key-btn {
        height: 46px;
        font-size: 0.85em;
    }

    .key-btn-special,
    .key-btn-wide,
    .key-btn-enter {
        font-size: 0.68em;
    }
}
