:root {
    --bg-base: #080910;
    --bg-glass: rgba(18, 21, 36, 0.7);
    --bg-glass-hover: rgba(28, 33, 58, 0.85);
    --text-primary: #eef0f8;
    --text-secondary: #7a82a0;

    --accent-blue: #00d2ff;
    --accent-blue-dark: #0095cc;
    --accent-purple: #7c5cbf;
    --accent-purple-light: #a67cf7;

    --accent-red-light: #ff5555;
    --accent-red-dark: #b01c1c;

    --accent-green-light: #00ff87;
    --accent-green-dark: #00d46a;

    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;

    --shadow-sm: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg-base);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(0, 210, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(255, 75, 75, 0.05) 0%, transparent 40%);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100dvh;
    user-select: none;
    -webkit-user-select: none;
}

h1, h2, h3 { font-family: 'Outfit', sans-serif; }

.top-bar {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.coin-display {
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,215,0,0.3);
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1.1rem;
    color: #ffd700;
    box-shadow: 0 5px 15px rgba(255,215,0,0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.rank-badge {
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    border: 1px solid rgba(255,255,255,0.2);
    padding: 5px 15px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--accent-purple);
    box-shadow: 0 0 10px rgba(58, 123, 213, 0.2);
}

.btn-hint {
    background: linear-gradient(135deg, #f2994a, #f2c94c);
    color: #333;
    box-shadow: 0 5px 15px rgba(242, 153, 74, 0.3);
    padding: 10px 20px;
    font-size: 1rem;
}

input[type="text"] {
    user-select: auto;
    -webkit-user-select: auto;
}

#app {
    width: 100%;
    max-width: 1000px;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* Base Classes */
.hidden { display: none !important; }

/* ── View Transition System ─────────────────────────── */
/* top-level game panels fade in/out instead of snapping */
#catalogue, #game-cc, #game-sr, #onboarding {
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}
#catalogue.view-active,
#game-cc.view-active,
#game-sr.view-active,
#onboarding.view-active {
    opacity: 1;
    pointer-events: auto;
}

/* ── Tutorial Overlay ───────────────────────────────── */
.tutorial-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(12px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.tutorial-card {
    max-width: 440px;
    width: 100%;
    text-align: center;
    padding: 30px;
}
.tutorial-card h2 { font-size: 1.8rem; margin: 0 0 10px 0; }
.tutorial-card p  { color: var(--text-secondary); line-height: 1.6; margin: 0 0 15px 0; }
.tutorial-preview {
    background: rgba(0,0,0,0.4);
    border-radius: 12px;
    padding: 15px;
    text-align: left;
    margin-top: 15px;
}
.tutorial-dots { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }
.t-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.2); transition: background 0.3s; }
.t-dot.active { background: var(--accent-blue); box-shadow: 0 0 8px var(--accent-blue); }

/* ── Daily Challenge Card ────────────────────────────── */
.daily-challenge-card {
    cursor: pointer;
    border: 1px solid rgba(0, 255, 135, 0.25);
    background: linear-gradient(135deg, rgba(0,255,135,0.05), rgba(0,210,255,0.05));
    transition: transform 0.2s, box-shadow 0.2s;
    padding: 18px 24px;
}
.daily-challenge-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 255, 135, 0.15);
    border-color: rgba(0, 255, 135, 0.5);
}

/* ── Achievement Badge Grid ──────────────────────────── */
.badge-tile {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    cursor: default;
    transition: transform 0.2s;
}
.badge-tile.earned {
    background: linear-gradient(135deg, rgba(242,201,76,0.3), rgba(242,153,74,0.2));
    border: 1px solid rgba(242,201,76,0.5);
}
.badge-tile.locked {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    opacity: 0.5;
}
.badge-tile.earned:hover { transform: scale(1.15); }

/* ── AI Quote Banner ─────────────────────────────────── */
.ai-quote {
    background: rgba(0,0,0,0.6);
    border-left: 3px solid currentColor;
    padding: 10px 15px;
    border-radius: 8px;
    font-style: italic;
    font-size: 0.9rem;
    animation: fadeIn 0.4s ease;
    margin-bottom: 5px;
}


/* Allow absolute daily-end overlay to fill the CC game panel */
#game-cc { position: relative; overflow: hidden; }

/* ═══════════════════════════════════════════════════════════
   DAILY END SCREEN
   ═══════════════════════════════════════════════════════════ */

.daily-end-overlay {
    position: absolute;
    inset: 0;
    background: rgba(8, 9, 16, 0.96);
    backdrop-filter: blur(20px);
    border-radius: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.4s ease;
    padding: 20px;
    box-sizing: border-box;
}
.daily-end-overlay.daily-end-visible { opacity: 1; }

.daily-end-card {
    text-align: center;
    max-width: 400px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.daily-end-firework {
    font-size: 4rem;
    animation: popIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.daily-end-title {
    margin: 0;
    font-size: 2rem;
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, #ffd700, #ff9a44);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: popIn 0.5s 0.1s both cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.daily-end-streak {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f2c94c;
    letter-spacing: 1px;
    animation: fadeIn 0.5s 0.2s both ease;
}

.daily-end-score-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    animation: fadeIn 0.5s 0.3s both ease;
}
.daily-end-score-label { color: var(--text-secondary); font-size: 0.95rem; }
.daily-end-score-value {
    font-size: 3.5rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    color: #ffffff;
    line-height: 1;
}

.daily-end-share-btn {
    background: linear-gradient(135deg, #1da1f2, #0a7abf);
    box-shadow: 0 5px 20px rgba(29, 161, 242, 0.4);
    width: 100%;
    font-size: 1.1rem;
    animation: fadeIn 0.4s 0.4s both ease;
}
.daily-end-share-btn:hover { filter: brightness(1.15); }

.daily-end-divider {
    color: var(--text-secondary);
    font-size: 0.8rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    width: 100%;
    position: relative;
    animation: fadeIn 0.4s 0.5s both ease;
}

.daily-end-cta {
    display: flex;
    gap: 12px;
    width: 100%;
    animation: fadeIn 0.4s 0.55s both ease;
}
.daily-end-cta-btn {
    flex: 1;
    font-size: 0.95rem !important;
    padding: 14px 10px !important;
}

.daily-end-back {
    margin-top: 4px;
    animation: fadeIn 0.4s 0.6s both ease;
}

/* ═══════════════════════════════════════════════════════════
   SHARE MODAL
   ═══════════════════════════════════════════════════════════ */

.share-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(16px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.share-modal-overlay.share-modal-visible { opacity: 1; }

.share-modal-card {
    max-width: 420px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid rgba(255,255,255,0.12);
}

.share-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.share-modal-title {
    font-size: 1.2rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(90deg, #fff, var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.share-close-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    font-family: inherit;
}
.share-close-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }

.share-preview {
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 12px;
    padding: 14px 16px;
}
.share-preview pre {
    margin: 0;
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}

.share-platforms {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.share-platform-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 13px 16px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: #fff;
    transition: transform 0.15s, filter 0.15s, box-shadow 0.15s;
}
.share-platform-btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.share-platform-btn:active { transform: scale(0.96); }

.share-icon {
    font-size: 1.3rem;
    line-height: 1;
    font-style: normal;
    font-weight: 900;
}

/* Brand colors */
.share-twitter  { background: #000; border: 1px solid rgba(255,255,255,0.15); box-shadow: 0 4px 15px rgba(0,0,0,0.5); }
.share-whatsapp { background: linear-gradient(135deg, #25d366, #128c7e); box-shadow: 0 4px 15px rgba(37,211,102,0.3); }
.share-telegram { background: linear-gradient(135deg, #2ca5e0, #1a73c1); box-shadow: 0 4px 15px rgba(44,165,224,0.3); }
.share-facebook { background: linear-gradient(135deg, #1877f2, #0d5dbf); box-shadow: 0 4px 15px rgba(24,119,242,0.3); }

.share-copy-btn {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.07);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}
.share-copy-btn:hover { background: rgba(255,255,255,0.14); transform: translateY(-1px); }

.share-native-btn {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.07);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.2s;
}
.share-native-btn:hover { color: #fff; }

/* Mobile: Shrink share grid to 2-col on very small */
@media screen and (max-width: 380px) {
    .share-modal-card { padding: 16px; }
    .share-platforms { grid-template-columns: 1fr 1fr; gap: 8px; }
    .share-platform-btn { font-size: 0.82rem; padding: 10px 8px; }
    .daily-end-cta { flex-direction: column; }
    .daily-end-score-value { font-size: 2.8rem; }
}
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 20px 30px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

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

.header h1 {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff 0%, #a0a5b5 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0 0 10px 0;
}

.header p {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin: 0;
}

/* Catalogue UI */
#catalogue {
    display: flex;
    gap: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.game-card {
    flex: 1;
    min-width: 320px;
    cursor: pointer;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity 0.4s;
}

.game-card:hover { transform: translateY(-12px); background: var(--bg-glass-hover); }
.game-card:hover::before { opacity: 1; }

.card-cc:hover { box-shadow: 0 15px 40px rgba(0, 210, 255, 0.2); border-color: rgba(0, 210, 255, 0.5); }
.card-sr:hover { box-shadow: 0 15px 40px rgba(255, 75, 75, 0.2); border-color: rgba(255, 75, 75, 0.5); }

.game-card .icon { font-size: 4rem; margin-bottom: 20px; text-shadow: 0 10px 20px rgba(0,0,0,0.5); }
.game-card h2 { font-size: 2rem; margin-top: 0; }
.game-card p { color: var(--text-secondary); line-height: 1.5; }

.title-cc { background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin: 0; text-align: center; font-size: 2.5rem; }
.title-sr { background: linear-gradient(90deg, var(--accent-red-light), #ff9a44); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin: 0; text-align: center; font-size: 2.5rem; }

/* Buttons & Inputs */
.back-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    margin-bottom: 30px;
    transition: all 0.2s;
    font-family: inherit;
}
.back-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

.input-form { display: flex; gap: 10px; width: 100%; max-width: 500px; }
input[type="text"] {
    flex: 1;
    padding: 15px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.4);
    color: white;
    font-size: 1.2rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes inputPulse {
    0% { box-shadow: 0 0 10px rgba(255,255,255,0.05); }
    50% { box-shadow: 0 0 20px rgba(0, 210, 255, 0.2), inset 0 0 10px rgba(255,255,255,0.05); border-color: rgba(0, 210, 255, 0.5); }
    100% { box-shadow: 0 0 10px rgba(255,255,255,0.05); }
}
input[type="text"]:focus {
    border-color: rgba(255,255,255,0.3);
    animation: inputPulse 2s infinite ease-in-out;
}

.btn {
    padding: 15px 30px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    color: white;
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.2s;
}
.btn:hover { transform: scale(1.05); filter: brightness(1.2); }
.btn:active { transform: scale(0.95); transition-duration: 0.05s; }
.btn-cc { background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple)); box-shadow: 0 5px 20px rgba(0, 210, 255, 0.3); }
.btn-sr { background: linear-gradient(135deg, var(--accent-red-light), var(--accent-red-dark)); box-shadow: 0 5px 20px rgba(255, 75, 75, 0.3); }

/* Animation Utility */
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); filter: blur(5px); } to { opacity: 1; transform: translateY(0); filter: blur(0); } }
.animate-slide-up { animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}
.shake { animation: shake 0.35s ease-in-out; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.97); }
}

/* Subtle glow on interactive focus */
.btn:focus-visible, input[type="text"]:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* Smooth card transition */
.game-card {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 180px;
    flex: 1;
    min-width: 260px;
    max-width: 360px;
    padding: 28px;
    position: relative;
    overflow: hidden;
}
.game-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.02));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}
.game-card:hover { transform: translateY(-6px); box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
.game-card .icon { font-size: 2.8rem; margin-bottom: 12px; line-height: 1; }
.game-card h2 { margin: 0 0 8px 0; font-size: 1.5rem; }
.game-card p { flex: 1; color: var(--text-secondary); font-size: 0.92rem; line-height: 1.6; margin: 0 0 12px 0; }
.card-cc { background: linear-gradient(145deg, rgba(0,120,180,0.15), rgba(10,12,25,0.6)); }
.card-sr { background: linear-gradient(145deg, rgba(180,30,30,0.15), rgba(10,12,25,0.6)); }
.card-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-secondary);
    align-self: flex-start;
}

/* Compound Chain Structure */
.cc-container { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.level-indicator { font-size: 1rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 2px; }

.chain-viewer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0;
    margin: 20px 0;
    width: 100%;
}

.circuit-path {
    width: 30px;
    height: 4px;
    background: rgba(255,255,255,0.1);
    transition: background 0.4s, box-shadow 0.4s;
}
.circuit-path.active {
    background: var(--accent-blue);
    box-shadow: 0 0 10px var(--accent-blue);
}

.chain-tile {
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(0, 210, 255, 0.4);
    border-radius: 12px;
    padding: 15px 25px;
    font-size: 1.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
    box-shadow: inset 0 0 20px rgba(0, 210, 255, 0.1), 0 5px 15px rgba(0,0,0,0.3);
    transition: all 0.4s;
    font-family: 'Outfit', sans-serif;
    position: relative;
    z-index: 2;
}

.chain-tile.locked {
    background: rgba(0,0,0,0.5);
    border-color: rgba(255,255,255,0.05);
    color: transparent;
    text-shadow: 0 0 12px rgba(255,255,255,0.2);
    box-shadow: none;
}
.chain-tile.newly-added {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn { 0% { transform: scale(0.8); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.cc-input-area { display: flex; flex-direction: column; align-items: center; gap: 15px; width: 100%; }
.hint-card {
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(58, 123, 213, 0.4);
    border-radius: 12px;
    padding: 15px;
    width: 100%;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4), inset 0 0 15px rgba(58, 123, 213, 0.1);
    margin-bottom: 0px;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hint-text {
    color: #fff;
    font-size: 1.5rem;
    font-weight: 500;
    margin-top: 10px;
    font-style: italic;
    background: linear-gradient(90deg, #fff, var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.status-msg { height: 24px; color: var(--accent-red-light); font-weight: 500; }

/* Shiritori Royale Structure */
.sr-container { display: flex; flex-direction: column; gap: 25px; }

/* Fever Mode */
@keyframes feverGlow {
    0% { box-shadow: 0 15px 35px rgba(255, 75, 75, 0.4); border-color: rgba(255, 75, 75, 0.5); }
    50% { box-shadow: 0 15px 50px rgba(255, 0, 100, 0.8); border-color: rgba(255, 0, 100, 1); }
    100% { box-shadow: 0 15px 35px rgba(255, 75, 75, 0.4); border-color: rgba(255, 75, 75, 0.5); }
}

.fever-mode {
    animation: feverGlow 0.5s infinite !important;
}

.avatar-img {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 2px solid var(--accent-red-light);
    margin-bottom: 5px;
    object-fit: cover;
    background: #000;
}

/* Player protagonist icon — matches enemy avatar height so both cards are equal */
.player-avatar-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 2px solid var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    background: linear-gradient(135deg, rgba(0,210,255,0.15), rgba(100,50,255,0.15));
    margin: 0 auto 5px auto;
}

.timer-bar-bg { 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    right: 0;
    width: 100%; 
    height: 12px; 
    background: rgba(0,0,0,0.8); 
    border-radius: 0; 
    overflow: hidden; 
    z-index: 1000;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
}

.timer-bar-fill { 
    height: 100%; 
    background: linear-gradient(90deg, var(--accent-green-light), var(--accent-green-dark)); 
    width: 100%; 
    transition: width 0.1s linear, background 0.3s; 
    box-shadow: 0 0 15px rgba(0, 255, 135, 0.5);
}

.timer-bar-fill.urgent { 
    background: linear-gradient(90deg, var(--accent-red-light), var(--accent-red-dark)); 
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
}

.battle-arena {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 16px;
}
.player-card {
    flex: 1;
    min-width: 0; /* prevent overflow */
    background: rgba(0,0,0,0.35);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#sr-player { border-top: 3px solid var(--accent-blue); }
#sr-enemy  { border-top: 3px solid var(--accent-red-light); }

.player-card h3 { margin: 0; font-size: 1.05rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.hp-label { font-size: 0.78rem; color: var(--text-secondary); font-weight: 500; align-self: flex-end; }

.health-bar-bg { width: 100%; background: rgba(255,255,255,0.08); height: 18px; border-radius: 9px; overflow: hidden; position: relative; }
.health-bar-fill { height: 100%; transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1); border-radius: 9px; }
#sr-player .health-bar-fill { background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple-light)); }
#sr-enemy  .health-bar-fill { background: linear-gradient(90deg, #ff9a44, var(--accent-red-light)); }
.health-text { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,0.9); }

.vs-text { font-size: 2rem; font-weight: 800; color: rgba(255,255,255,0.08); font-family: 'Outfit'; flex-shrink: 0; align-self: center; }

.word-history {
    background: rgba(0,0,0,0.5);
    height: 250px; 
    overflow-y: auto;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: inset 0 5px 15px rgba(0,0,0,0.5);
    scroll-behavior: smooth;
}

.history-item {
    font-weight: 800;
    padding: 12px 20px;
    border-radius: 20px;
    color: #fff;
    max-width: 75%;
    font-size: 1.1rem;
    letter-spacing: 1px;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    word-wrap: break-word;
}

.history-item.player {
    background: linear-gradient(135deg, #1fa2ff, #12d8fa);
    align-self: flex-end; 
    border-bottom-right-radius: 4px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.history-item.enemy {
    background: linear-gradient(135deg, #ff416c, #ff4b2b);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

@keyframes popIn {
    0% { transform: scale(0.8) translateY(10px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.grouped-input { display: flex; align-items: stretch; flex: 1; }
.start-letter { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.1); border-right: none; border-radius: 12px 0 0 12px; padding: 0 20px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.5rem; color: var(--accent-red-light); text-transform: uppercase; transition: color 0.3s, opacity 0.3s; }
.grouped-input input { border-radius: 0 12px 12px 0; border: 1px solid rgba(255,255,255,0.1); }
.grouped-input input:focus { border-color: rgba(255,255,255,0.3); }

/* Input waiting state (enemy turn) */
.grouped-input input:disabled {
    cursor: not-allowed;
    background: rgba(0,0,0,0.2);
    opacity: 0.7;
}

#sr-form button[type="submit"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    filter: none !important;
}

/* Pulsing waiting indicator on the start-letter badge */
@keyframes waitPulse {
    0%, 100% { opacity: 0.5; }
    50%       { opacity: 0.2; }
}
.start-letter.waiting {
    animation: waitPulse 0.8s ease-in-out infinite;
}

/* --- RESPONSIVE DESIGN SYSTEM --- */

/* Tablet (768px - 1024px) */
@media screen and (max-width: 1024px) {
    #app { padding: 15px; }
    .header h1 { font-size: 2.8rem; }
    .game-card { min-width: 280px; }
    .battle-arena { gap: 15px; }
}

/* Mobile (max 768px) — Main Layout */
@media screen and (max-width: 768px) {
    body { align-items: flex-start; }

    #app { padding: 12px; }

    .header { margin-bottom: 10px; }
    .header h1 { font-size: 2rem; }
    .header p { font-size: 0.9rem; }

    /* Catalogue stacks vertically */
    #catalogue > div:last-child {
        flex-direction: column !important;
        gap: 15px !important;
    }
    .game-card { min-width: unset !important; padding: 20px; }
    .game-card .icon { font-size: 2.5rem; margin-bottom: 10px; }
    .game-card h2 { font-size: 1.4rem; }
    .game-card p { font-size: 0.9rem; }

    /* Profile strip  */
    .player-profile div {
        flex-direction: column !important;
        gap: 6px !important;
    }

    /* Game Panels */
    .glass-panel { padding: 15px; border-radius: 16px; }
    .back-btn { margin-bottom: 15px; font-size: 0.85rem; padding: 8px 14px; }

    /* Compound Chain */
    .title-cc, .title-sr { font-size: 1.5rem; }

    .cc-container > div:first-child {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    /* Shrink the action buttons in the header */
    .cc-container .btn, .sr-container .btn { 
        font-size: 0.7rem !important; 
        padding: 4px 8px !important; 
        width: auto !important;
    }
    
    .chain-tile { font-size: 0.85rem; padding: 8px 12px; border-radius: 8px; }
    .circuit-path { width: 12px; height: 3px; }

    .hint-text { font-size: 1.1rem; }
    .hint-card { padding: 12px; }

    /* Input forms full width */
    .cc-input-area { gap: 10px; }
    .input-form { 
        max-width: 100%; 
        flex-direction: row;
        gap: 8px;
    }
    .input-form .btn { width: auto !important; padding: 12px 18px !important; }
    input[type="text"] { 
        padding: 12px 14px; 
        font-size: 1rem; /* 1rem = prevents iOS Safari auto-zoom on focus */
    }

    /* Shiritori Battle Arena stacks vertically */
    .battle-arena { 
        flex-direction: row !important; 
        gap: 10px; 
        align-items: stretch;
    }
    .player-card { padding: 12px 10px; flex: 1; }
    .player-card h3 { font-size: 0.9rem; margin-bottom: 8px; }
    .vs-text { font-size: 1.2rem; align-self: center; }
    .avatar-img { width: 40px; height: 40px; }

    .health-bar-bg { height: 16px; border-radius: 8px; }

    /* Combat log */
    .word-history { height: 170px; padding: 10px; gap: 8px; }
    .history-item { font-size: 0.85rem; padding: 8px 14px; max-width: 80%; }

    /* Shiritori input */
    #sr-form { flex-wrap: nowrap !important; gap: 8px !important; }
    #sr-form .btn { width: auto !important; padding: 12px 18px !important; white-space: nowrap; }
    .start-letter { padding: 0 14px; font-size: 1.2rem; }

    /* SR Header */
    .sr-container > div:first-child {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    .sr-container > div:first-child div { flex-wrap: wrap; }

    /* Footer */
    #credits-footer { padding-top: 25px !important; padding-bottom: 20px !important; }
    #credits-footer p { font-size: 0.75rem !important; }

    /* Rank badges */
    .rank-badge { font-size: 0.75rem; padding: 4px 10px; }
}

/* Ultra-small phones (below 380px) */
@media screen and (max-width: 380px) {
    .header h1 { font-size: 1.6rem; }
    .chain-tile { font-size: 0.75rem; padding: 7px 10px; }
    .circuit-path { width: 8px; }
    .history-item { font-size: 0.8rem; }
    .battle-arena { flex-direction: column !important; }
    .vs-text { margin: 0; }
}


/* -- Compound Chain Quit Confirm Overlay ------------------------------- */
.cc-quit-overlay {
    position: absolute;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 9, 16, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: var(--radius-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.cc-quit-overlay.cc-quit-visible {
    opacity: 1;
    pointer-events: all;
}
.cc-quit-card {
    text-align: center;
    padding: 32px 28px;
    max-width: 340px;
    width: 90%;
    border: 1px solid rgba(124, 92, 191, 0.35);
    box-shadow: 0 0 40px rgba(124, 92, 191, 0.15);
    animation: none;
}

/* Ensure the quit overlay anchors correctly inside the game panel */
#game-cc { position: relative; }

/* ── Universal Share Modal ───────────────────────────────────────────── */
.share-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 9, 16, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.share-modal-backdrop.share-modal-visible {
    opacity: 1;
    pointer-events: all;
}
.share-modal-card {
    position: relative;
    width: 90%;
    max-width: 420px;
    padding: 28px 24px 24px;
    text-align: center;
    border: 1px solid rgba(0, 210, 255, 0.2);
    box-shadow: 0 0 60px rgba(0, 210, 255, 0.1);
    animation: none;
}
.share-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: rgba(255,255,255,0.08);
    border: none;
    color: var(--text-secondary);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 28px;
    transition: background 0.2s;
}
.share-modal-close:hover { background: rgba(255,255,255,0.18); }
.share-preview-box {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 16px;
    text-align: left;
}
.share-preview-text {
    font-family: 'Inter', monospace;
    font-size: 0.82rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    margin: 0;
    line-height: 1.6;
}
.share-platform-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 4px;
}
.share-platform-btn {
    font-size: 0.85rem;
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: transform 0.15s, opacity 0.15s;
}
.share-platform-btn:hover { transform: translateY(-2px); opacity: 0.9; }
.share-twitter  { background: linear-gradient(135deg, #1a1a2e, #16213e); border: 1px solid rgba(255,255,255,0.15); }
.share-whatsapp { background: linear-gradient(135deg, #075e54, #128c7e); }
.share-telegram { background: linear-gradient(135deg, #0088cc, #2ca5e0); }
.share-facebook { background: linear-gradient(135deg, #1877f2, #42a5f5); }

