/* ─── Ghibli Family Adventure Game ─── */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

:root {
    --bg-primary: #0f0e13;
    --bg-secondary: #1a1825;
    --bg-card: #1e1c2a;
    --text-primary: #e8e0f0;
    --text-secondary: #9a90b0;
    --accent-green: #6dbd5a;
    --accent-blue: #6aaee0;
    --accent-gold: #e0b84a;
    --accent-red: #e07070;
    --accent-purple: #a882e8;
    --border: #2e2a42;
    --shadow: rgba(0, 0, 0, 0.5);
    --ghibli-sky: #3a6ea8;
    --ghibli-grass: #4a8a30;
    --ghibli-warm: #c88a30;
}

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

body {
    font-family: 'Nunito', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(109, 189, 90, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(106, 174, 224, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(224, 184, 74, 0.04) 0%, transparent 50%);
}

/* ─── Layout ─── */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
}

/* ─── Screen transitions ─── */
.screen {
    display: none;
    animation: fadeIn 0.5s ease;
}
.screen.active { display: block; }

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

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

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

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

/* ─── Header ─── */
.game-header {
    text-align: center;
    padding: 24px 0;
}

.game-header h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent-green);
    text-shadow: 2px 2px 0 rgba(90, 143, 76, 0.15);
    line-height: 1.2;
}

.game-header p {
    color: var(--text-secondary);
    margin-top: 8px;
    font-size: 1.05rem;
}

/* ─── Cards ─── */
.card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 4px 16px var(--shadow);
}

.card-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--accent-blue);
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: 2px solid transparent;
    border-radius: 12px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px var(--shadow); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--accent-green);
    color: white;
    border-color: #4a7a3e;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-danger {
    background: var(--accent-red);
    color: white;
    border-color: #a64444;
}

.btn-gold {
    background: linear-gradient(135deg, var(--accent-gold), #daa520);
    color: white;
    border-color: #a67c28;
}

.btn-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 16px 20px;
    margin-bottom: 10px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.btn-option:hover {
    border-color: var(--accent-blue);
    background: rgba(74, 127, 181, 0.08);
    transform: translateX(4px);
}

.btn-option.good::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-green);
}

.btn-option.neutral::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-gold);
}

.btn-option.risky::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-red);
}

.btn-block { display: flex; width: 100%; }

/* ─── Forms ─── */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-input, .form-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.form-input::placeholder { color: var(--text-secondary); }

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* ─── Player Cards ─── */
.player-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.player-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    text-align: center;
    position: relative;
    transition: all 0.3s;
}

.player-card.active-player {
    border-color: var(--accent-gold);
    box-shadow: 0 0 20px rgba(196, 155, 50, 0.25);
    animation: pulse 2s infinite;
}

.player-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 8px;
    overflow: hidden;
    border: 3px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-avatar .placeholder {
    font-size: 2rem;
    color: var(--text-secondary);
}

.player-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.player-items {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.remove-player {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-red);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ─── Photo Upload ─── */
.photo-upload {
    position: relative;
    cursor: pointer;
}

.photo-upload input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* ─── GAME SCREEN — Fullscreen immersive layout ─── */

#game-screen {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    overflow: hidden;
    background: #080810;
}

#game-screen.active {
    display: flex;
    animation: none;
}

/* Background scene image */
#scene-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: opacity 0.8s ease;
    z-index: 0;
}

/* Subtle vignette — само самите краища */
#game-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        rgba(0,0,0,0.18) 0%,
        transparent 18%,
        transparent 72%,
        rgba(0,0,0,0.22) 100%
    );
    z-index: 1;
    pointer-events: none;
}

/* ── TOP BAR ── */
.game-top-bar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
    gap: 12px;
}

/* Player avatars row */
.game-players-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.game-players-row::-webkit-scrollbar { display: none; }

.game-player-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.3s, transform 0.3s;
}

.game-player-chip.active {
    opacity: 1;
    transform: scale(1.15);
}

.game-player-chip img,
.game-player-chip .chip-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.game-player-chip.active img,
.game-player-chip.active .chip-placeholder {
    border-color: var(--accent-gold);
    box-shadow: 0 0 12px rgba(196, 155, 50, 0.6);
}

.chip-name {
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    text-shadow: var(--outline);
    max-width: 50px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-items {
    font-size: 0.6rem;
    color: #f0d060;
    text-shadow: var(--outline);
}

/* Top-right: progress pill */
.game-progress-pill {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.progress-pill-bar {
    width: 80px;
    height: 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    overflow: hidden;
}

.progress-pill-fill {
    height: 100%;
    background: var(--accent-gold);
    border-radius: 3px;
    transition: width 0.6s ease;
}

.progress-pill-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    text-shadow: var(--outline);
}

/* Turn badge */
.turn-badge {
    font-size: 0.7rem;
    font-weight: 800;
    color: #fff;
    text-shadow: var(--outline);
}

/* ── BOTTOM PANEL ── */
.game-bottom-panel {
    position: relative;
    z-index: 2;
    margin-top: auto;
    padding: 0 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 65vh;
    overflow-y: auto;
    scrollbar-width: none;
}
.game-bottom-panel::-webkit-scrollbar { display: none; }

/* Текстов контур — мixin чрез CSS custom property */
:root {
    --outline: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000,
               -2px 0 0 #000, 2px 0 0 #000, 0 -2px 0 #000, 0 2px 0 #000,
               0 0 10px rgba(0,0,0,0.9);
}

/* Current player name */
.game-active-player-label {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--accent-gold);
    text-shadow: var(--outline);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0 4px;
}

/* Scene text */
.scene-text {
    font-size: 1.05rem;
    line-height: 1.7;
    padding: 0 4px;
    background: none;
    border: none;
    border-radius: 0;
    color: #ffffff;
    text-shadow: var(--outline);
}

/* Option buttons */
.btn-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 16px 10px 20px;
    margin: 0;
    background: transparent;
    border: none;
    border-left: 3px solid rgba(255,255,255,0.4);
    border-radius: 0;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: var(--outline);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.btn-option:hover {
    padding-left: 26px;
    border-left-color: rgba(255,255,255,0.9);
    color: #ffffff;
}

.btn-option:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn-option.good   { border-left-color: #7be870; }
.btn-option.neutral { border-left-color: #f0d060; }
.btn-option.risky  { border-left-color: #f07070; }

.btn-option.good:hover   { border-left-color: #a0f090; }
.btn-option.neutral:hover { border-left-color: #ffe880; }
.btn-option.risky:hover  { border-left-color: #f09090; }

/* Scene meta badges */
.scene-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 0 4px;
}

.scene-badge {
    padding: 0;
    background: none;
    border: none;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    text-shadow: var(--outline);
}

/* Quit button */
.game-quit-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    text-shadow: 0 1px 4px rgba(0,0,0,0.9);
    font-size: 0.72rem;
    cursor: pointer;
    padding: 6px 8px;
    font-family: 'Nunito', sans-serif;
    text-align: center;
    transition: color 0.2s;
}
.game-quit-btn:hover { color: rgba(255,255,255,0.85); }

/* ─── Progress Bar ─── */
.progress-bar {
    height: 12px;
    background: rgba(255,255,255,0.06);
    border-radius: 6px;
    overflow: hidden;
    margin: 8px 0;
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green), var(--ghibli-grass));
    border-radius: 6px;
    transition: width 0.5s ease;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* ─── Result / Consequence panel ─── */
.result-moral {
    font-size: 0.9rem;
    font-weight: 700;
    color: #a0f090;
    text-shadow: var(--outline);
    padding: 0 4px;
    font-style: italic;
}

.result-effects {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 4px;
}

.result-effect-tag {
    font-size: 0.78rem;
    font-weight: 700;
    color: #f0d060;
    text-shadow: var(--outline);
}

.btn-continue-turn {
    display: inline-block;
    padding: 12px 32px;
    background: transparent;
    border: 2px solid rgba(255,255,255,0.6);
    border-radius: 30px;
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    text-shadow: var(--outline);
    cursor: pointer;
    transition: all 0.2s;
    align-self: flex-start;
}

.btn-continue-turn:hover {
    border-color: #fff;
    background: rgba(255,255,255,0.1);
    transform: translateX(4px);
}

/* ─── Adventure Selection ─── */
.adventure-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 14px;
    margin: 16px 0;
}

.adventure-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    cursor: pointer;
    transition: all 0.2s;
}

.adventure-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow);
}

.adventure-card.selected {
    border-color: var(--accent-green);
    background: rgba(109, 189, 90, 0.1);
}

.adventure-section-label {
    grid-column: 1 / -1;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 4px 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
}

.adventure-card h3 {
    font-size: 1.05rem;
    margin-bottom: 6px;
    color: var(--accent-green);
}

.adventure-card.real h3 { color: var(--accent-blue); }
.adventure-card.real { border-color: rgba(106,174,224,0.2); }
.adventure-card.real.selected { border-color: var(--accent-blue); background: rgba(106,174,224,0.08); }
.adventure-card.real .theme-tag { background: rgba(106,174,224,0.1); color: var(--accent-blue); }

.adventure-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.adventure-themes {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.theme-tag {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    background: rgba(124, 92, 181, 0.12);
    color: var(--accent-purple);
    font-weight: 600;
}

/* ─── Duration Selector ─── */
.duration-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 12px 0;
}

.duration-card {
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-secondary);
}

.duration-card:hover { border-color: var(--accent-blue); }
.duration-card.selected {
    border-color: var(--accent-gold);
    background: rgba(196, 155, 50, 0.08);
}

.duration-card .time { font-size: 1.1rem; font-weight: 800; color: var(--accent-gold); }
.duration-card .desc { font-size: 0.8rem; color: var(--text-secondary); }

/* ─── Inventory ─── */
.inventory-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 8px 0;
}

.inventory-item {
    padding: 4px 10px;
    background: rgba(224, 184, 74, 0.1);
    border: 1px solid rgba(224,184,74,0.35);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-gold);
}

/* ─── Moral Lesson ─── */
.moral-box {
    background: linear-gradient(135deg, rgba(109, 189, 90, 0.08), rgba(106, 174, 224, 0.08));
    border: 1px solid rgba(109,189,90,0.3);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    text-align: center;
    font-weight: 700;
    color: var(--accent-green);
}

/* ─── History ─── */
.history-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
}

.history-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--border);
}

.history-avatar img { width: 100%; height: 100%; object-fit: cover; }

.history-content { flex: 1; }
.history-player { font-weight: 700; color: var(--accent-blue); font-size: 0.9rem; }
.history-scene { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }
.history-choice { font-size: 0.85rem; color: var(--accent-green); margin-top: 2px; font-weight: 600; }

/* ─── Loading ─── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: #0a090e;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 24px;
    z-index: 1000;
}

.loading-overlay.active { display: flex; }

.loading-spinner {
    width: 56px;
    height: 56px;
    border: 3px solid rgba(255,255,255,0.08);
    border-top-color: var(--accent-green);
    border-right-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.loading-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    max-width: 280px;
    line-height: 1.5;
    opacity: 0.85;
}

.loading-dots {
    display: flex;
    gap: 8px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    opacity: 0.2;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; background: var(--accent-blue); }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; background: var(--accent-gold); }

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.15; transform: scale(0.8); }
    40%           { opacity: 1;    transform: scale(1.2); }
}

/* ─── Final Screen ─── */
.final-screen {
    text-align: center;
}

.final-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent-gold);
    margin-bottom: 12px;
}

.final-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 16px;
    border: 3px solid var(--accent-gold);
    margin: 16px 0;
}

.lessons-list {
    list-style: none;
    padding: 0;
}

.lessons-list li {
    padding: 10px 16px;
    margin-bottom: 8px;
    background: rgba(109, 189, 90, 0.08);
    border-left: 4px solid var(--accent-green);
    border-radius: 0 10px 10px 0;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
    .container { padding: 10px; }
    .game-header h1 { font-size: 1.5rem; }
    .player-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .adventure-grid { grid-template-columns: 1fr; }
    .duration-grid { grid-template-columns: 1fr; }
    .scene-text { font-size: 1rem; padding: 14px; }
    .btn-option { padding: 12px 14px; font-size: 0.95rem; }
}
