/* ========================================
   SUNROOM — Собери браслет: Стили v2
   Природный / эко дизайн + геймплей
   ======================================== */

/* --- CSS Variables --- */
:root {
    --bg-primary: #2c2416;
    --bg-secondary: #3d3225;
    --bg-card: #4a3c2e;
    --text-primary: #f5e6d3;
    --text-secondary: #c4a882;
    --text-muted: #8a7560;
    --accent: #c8956c;
    --accent-hover: #d4a57c;
    --gold: #d4a04a;
    --silver: #a8b5c0;
    --bronze: #b87333;
    --diamond: #7ecdc0;
    --danger: #c75050;
    --success: #6abf69;
    --border: #5a4a3a;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --font: 'Comfortaa', 'Segoe UI', sans-serif;
    --transition: 0.3s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* --- Screen System --- */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    z-index: 10;
}

.screen-content {
    width: 100%;
    max-width: 420px;
    padding: 24px 20px;
    text-align: center;
    max-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.screen-content::-webkit-scrollbar {
    display: none;
}

/* --- Typography --- */
h1 {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--text-primary);
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

p {
    line-height: 1.5;
    color: var(--text-secondary);
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 14px 36px;
    border: none;
    border-radius: 50px;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    text-align: center;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #a87550);
    color: #fff;
    box-shadow: 0 4px 15px rgba(200, 149, 108, 0.4);
}

.btn-primary:hover, .btn-primary:active {
    background: linear-gradient(135deg, var(--accent-hover), #b8855e);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(200, 149, 108, 0.5);
}

.btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
    padding: 12px 32px;
}

.btn-secondary:hover, .btn-secondary:active {
    background: rgba(200, 149, 108, 0.1);
}

.btn-back {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 16px;
    padding: 8px;
    transition: color var(--transition);
}

.btn-back:hover {
    color: var(--text-secondary);
}

/* ===== SCREEN 1: LANDING ===== */
.logo-area {
    margin-bottom: 24px;
}

.stone-icon {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.si {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
    box-shadow: 0 0 12px rgba(155, 89, 182, 0.3);
}

.si1 {
    background: radial-gradient(circle at 30% 30%, #c39bd3, #9b59b6, #6c3483);
    animation-delay: 0s;
}

.si2 {
    background: radial-gradient(circle at 30% 30%, #e0c080, #c8956c, #8b6914);
    animation-delay: 0.5s;
    box-shadow: 0 0 12px rgba(200, 149, 108, 0.3);
}

.si3 {
    background: radial-gradient(circle at 30% 30%, #5dade2, #2e86c1, #1a5276);
    animation-delay: 1s;
    box-shadow: 0 0 12px rgba(46, 134, 193, 0.3);
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.tagline {
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.landing-main h2 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    line-height: 1.3;
}

.landing-desc {
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.prize-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 28px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.prize-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.prize-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(0,0,0,0.2);
}

.dot-bronze { background: radial-gradient(circle at 35% 35%, #d49050, var(--bronze), #805020); }
.dot-silver { background: radial-gradient(circle at 35% 35%, #c8d5e0, var(--silver), #708090); }
.dot-gold { background: radial-gradient(circle at 35% 35%, #f0d070, var(--gold), #a07020); }
.dot-diamond { background: radial-gradient(circle at 35% 35%, #a0e8d8, var(--diamond), #40a090); }

/* ===== SCREEN 2: FORM ===== */
.form-desc {
    font-size: 0.9rem;
    margin-bottom: 24px;
}

form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 1rem;
    transition: border-color var(--transition);
    outline: none;
}

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

.form-group input:focus {
    border-color: var(--accent);
}

.form-group input.invalid {
    border-color: var(--danger);
}

.error-msg {
    display: block;
    font-size: 0.8rem;
    color: var(--danger);
    min-height: 20px;
    margin-top: 4px;
}

/* ===== SCREEN 3: RULES ===== */
.rules-list {
    text-align: left;
    margin-bottom: 24px;
}

.rule-item {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: flex-start;
}

.rule-number {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}

.rule-item p {
    font-size: 0.88rem;
    line-height: 1.4;
    padding-top: 2px;
}

.rule-number-danger {
    background: var(--danger) !important;
    font-size: 1rem !important;
}

.rule-danger p {
    color: var(--danger);
}

.rule-danger p strong {
    color: #e85555;
}

.prize-scale {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.scale-item {
    text-align: left;
}

.scale-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.scale-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.scale-bronze .scale-fill { background: linear-gradient(90deg, var(--bronze), #d49050); }
.scale-silver .scale-fill { background: linear-gradient(90deg, var(--silver), #c8d5e0); }
.scale-gold .scale-fill { background: linear-gradient(90deg, var(--gold), #f0d070); }
.scale-diamond .scale-fill { background: linear-gradient(90deg, var(--diamond), #a0e8d8); }

.scale-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
}

.scale-range { color: var(--text-muted); }
.scale-prize { color: var(--text-secondary); font-weight: 600; }

.attempts-info {
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.attempts-dots {
    display: flex;
    gap: 6px;
}

.attempt-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--border);
    transition: background var(--transition);
}

.attempt-dot.full {
    background: var(--accent);
    box-shadow: 0 0 6px rgba(200, 149, 108, 0.4);
}

.attempt-dot.used {
    background: var(--text-muted);
    opacity: 0.4;
}

.btn-play {
    width: 100%;
    font-size: 1.1rem;
    padding: 16px;
}

/* ===== SCREEN 4: GAME ===== */
#screen-game {
    align-items: stretch;
    justify-content: stretch;
    background: var(--bg-primary);
}

/* HUD */
.game-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 16px;
    background: linear-gradient(180deg, rgba(44, 36, 22, 0.95) 0%, rgba(44, 36, 22, 0) 100%);
    z-index: 20;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
}

.hud-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hud-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.hud-timer-wrap .hud-value {
    color: var(--accent);
}

.hud-timer-wrap .hud-value.warning {
    color: var(--danger);
    animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { opacity: 1; }
    to { opacity: 0.5; }
}

/* Combo HUD */
.hud-combo {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gold);
    min-height: 20px;
    transition: all 0.2s ease;
    opacity: 0;
    transform: scale(0.5);
}

.hud-combo.active {
    opacity: 1;
    transform: scale(1);
    animation: comboPulse 0.6s ease infinite alternate;
}

@keyframes comboPulse {
    from { text-shadow: 0 0 4px rgba(212, 160, 74, 0.3); }
    to { text-shadow: 0 0 12px rgba(212, 160, 74, 0.7); }
}

/* Vertical progress bar */
.game-progress {
    position: absolute;
    right: 8px;
    top: 70px;
    bottom: 20px;
    width: 32px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.progress-bar-vertical {
    flex: 1;
    width: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}

.progress-fill-vertical {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(0deg, var(--bronze), var(--silver), var(--gold), var(--diamond));
    border-radius: 3px;
    transition: height 0.3s ease;
    height: 0%;
}

.progress-mark {
    position: absolute;
    right: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    transition: all 0.3s ease;
}

.mark-line {
    width: 12px;
    height: 2px;
    background: var(--text-muted);
    transition: background 0.3s ease;
}

.mark-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    width: 16px;
    text-align: right;
    transition: all 0.3s ease;
}

.progress-mark.reached .mark-label {
    color: var(--accent);
    font-weight: 700;
    text-shadow: 0 0 6px rgba(200, 149, 108, 0.5);
}

.progress-mark.reached .mark-line {
    background: var(--accent);
    box-shadow: 0 0 4px rgba(200, 149, 108, 0.5);
}

/* Canvas */
#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* ===== SCREEN 5: RESULT ===== */
#screen-result .screen-content {
    padding-top: 40px;
}

.result-bracelet {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 20px;
}

.result-stone {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    animation: popIn 0.3s ease backwards;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), inset 0 -2px 4px rgba(0,0,0,0.15);
}

@keyframes popIn {
    from { transform: scale(0) rotate(-30deg); opacity: 0; }
    to { transform: scale(1) rotate(0deg); opacity: 1; }
}

.result-score {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.result-combo {
    font-size: 0.9rem;
    color: var(--gold);
    margin-bottom: 16px;
    opacity: 0.8;
}

.result-prize-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.result-prize-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.03) 0%, transparent 60%);
    pointer-events: none;
}

.result-prize-card.tier-bronze { border-color: var(--bronze); }
.result-prize-card.tier-silver { border-color: var(--silver); }
.result-prize-card.tier-gold { border-color: var(--gold); box-shadow: 0 0 20px rgba(212, 160, 74, 0.15); }
.result-prize-card.tier-diamond { border-color: var(--diamond); box-shadow: 0 0 25px rgba(126, 205, 192, 0.2); }

.result-prize-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.result-prize-card h3 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 14px;
}

.promo-code-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--bg-primary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
}

.promo-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.promo-code {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.05em;
}

.btn-copy {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: color var(--transition);
    display: flex;
    align-items: center;
}

.btn-copy:hover, .btn-copy.copied {
    color: var(--success);
}

.result-attempts {
    margin-bottom: 16px;
}

.result-attempts p {
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.btn-shop {
    display: block;
    width: 100%;
    margin-bottom: 8px;
}

.result-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== RESPONSIVE ===== */
@media (max-height: 650px) {
    .screen-content { padding: 16px 16px; }
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.25rem; }
    .landing-main h2 { font-size: 1.2rem; }
    .prize-preview { padding: 12px; gap: 6px; }
    .rules-list { margin-bottom: 16px; }
    .rule-item { margin-bottom: 8px; }
    .prize-scale { gap: 6px; margin-bottom: 14px; }
}

@media (max-width: 360px) {
    .screen-content { padding: 16px 12px; }
    h1 { font-size: 1.8rem; }
    .btn { padding: 12px 28px; }
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }

/* Countdown overlay */
.countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(44, 36, 22, 0.85);
    z-index: 30;
}

.countdown-number {
    font-size: 5rem;
    font-weight: 700;
    color: var(--accent);
    animation: countdownPop 0.8s ease forwards;
    text-shadow: 0 0 30px rgba(200, 149, 108, 0.4);
}

.countdown-number.go {
    color: var(--success);
    text-shadow: 0 0 30px rgba(106, 191, 105, 0.4);
}

@keyframes countdownPop {
    0% { transform: scale(2); opacity: 0; }
    30% { transform: scale(1); opacity: 1; }
    80% { opacity: 1; }
    100% { transform: scale(0.8); opacity: 0; }
}
