/* ===========================
   ROOT & RESET
=========================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-dark: #0a0a1a;
    --bg-card: rgba(18, 18, 40, 0.75);
    --border: rgba(120, 100, 255, 0.25);
    --accent: #7c5af3;
    --accent-2: #f35ab9;
    --accent-glow: rgba(124, 90, 243, 0.45);
    --text-primary: #f0eeff;
    --text-muted: rgba(200, 190, 255, 0.6);
    --success: #3ef5a8;
    --danger: #f55a5a;
    --warn: #f5c23e;
    --pill-low: rgba(94, 200, 255, 0.15);
    --pill-high: rgba(255, 100, 100, 0.15);
    --pill-correct: rgba(62, 245, 168, 0.2);
    --radius: 20px;
    --radius-sm: 12px;
    --transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
}

/* ===========================
   ANIMATED BACKGROUND
=========================== */
.bg-particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.particle {
    position: absolute;
    border-radius: 50%;
    animation: floatUp linear infinite;
    opacity: 0;
}

@keyframes floatUp {
    0%   { transform: translateY(100vh) scale(0); opacity: 0; }
    10%  { opacity: 0.6; }
    90%  { opacity: 0.3; }
    100% { transform: translateY(-10vh) scale(1.2); opacity: 0; }
}

body::before {
    content: '';
    position: fixed;
    top: -30%;
    left: -20%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(124,90,243,0.18) 0%, transparent 70%);
    animation: orb1 12s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -30%;
    right: -20%;
    width: 55vw;
    height: 55vw;
    background: radial-gradient(circle, rgba(243,90,185,0.14) 0%, transparent 70%);
    animation: orb2 15s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

@keyframes orb1 {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(5vw, 5vh) scale(1.1); }
}
@keyframes orb2 {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(-4vw, -6vh) scale(1.08); }
}

/* ===========================
   SCREENS
=========================== */
.screen {
    position: relative;
    z-index: 10;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* ===========================
   CARD
=========================== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    width: 100%;
    max-width: 480px;
    box-shadow:
        0 0 60px rgba(124, 90, 243, 0.12),
        0 30px 60px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255,255,255,0.08);
    animation: cardIn 0.6s var(--transition) both;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(30px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===========================
   LOGO / HEADER
=========================== */
.logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 8px;
}

.logo-icon {
    font-size: 2.4rem;
    filter: drop-shadow(0 0 12px rgba(124, 90, 243, 0.7));
    animation: pulse 2.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { filter: drop-shadow(0 0 12px rgba(124, 90, 243, 0.7)); }
    50%       { filter: drop-shadow(0 0 24px rgba(243, 90, 185, 0.8)); }
}

.logo-text {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #c4b0ff 0%, #f35ab9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 32px;
    font-weight: 300;
}

/* ===========================
   FORM ELEMENTS
=========================== */
.form-group {
    margin-bottom: 28px;
}

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

input[type="number"],
input[type="text"] {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    padding: 14px 48px 14px 18px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    -moz-appearance: textfield;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button { -webkit-appearance: none; }

input:focus {
    border-color: var(--accent);
    background: rgba(124, 90, 243, 0.08);
    box-shadow: 0 0 0 4px var(--accent-glow), 0 0 20px rgba(124, 90, 243, 0.2);
}

input::placeholder { color: rgba(200, 190, 255, 0.35); font-weight: 400; }

.input-icon {
    position: absolute;
    right: 14px;
    font-size: 1.2rem;
    pointer-events: none;
    transition: transform 0.2s ease;
}

input:focus ~ .input-icon { transform: scale(1.2) rotate(-10deg); }

.hint-text {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 8px;
    font-weight: 300;
}

/* ===========================
   BUTTONS
=========================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 14px 28px;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.3px;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background 0.2s;
}

.btn:hover::after { background: rgba(255,255,255,0.07); }
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    color: #fff;
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    box-shadow: 0 4px 24px rgba(124, 90, 243, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(124, 90, 243, 0.55);
}

.btn-arrow {
    font-size: 1.2rem;
    transition: transform 0.2s;
}

.btn-primary:hover .btn-arrow { transform: translateX(4px); }

.btn-ghost {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 10px 18px;
    font-size: 0.9rem;
}

.btn-ghost:hover {
    color: var(--text-primary);
    border-color: rgba(200, 190, 255, 0.5);
}

/* ===========================
   BEST SCORE DISPLAY
=========================== */
.best-score-display {
    margin-top: 20px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--warn);
    background: rgba(245, 194, 62, 0.1);
    border: 1px solid rgba(245, 194, 62, 0.3);
    border-radius: 10px;
    padding: 10px 16px;
    animation: slideUp 0.4s var(--transition);
}

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

/* ===========================
   GAME CARD
=========================== */
.game-card { gap: 0; }

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.range-badge {
    background: linear-gradient(135deg, rgba(124,90,243,0.25), rgba(243,90,185,0.2));
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #d0b8ff;
    letter-spacing: 0.5px;
}

.attempts-section {
    text-align: center;
    margin-bottom: 24px;
}

.attempts-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.attempts-count {
    font-size: 3.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, #c4b0ff, #f35ab9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    transition: transform 0.2s var(--transition);
}

.attempts-count.bump {
    animation: bump 0.35s var(--transition);
}

@keyframes bump {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* ===========================
   THERMOMETER
=========================== */
.thermometer-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.therm-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 28px;
}

.therm-label.high { text-align: right; }

.thermometer {
    flex: 1;
    height: 10px;
    background: rgba(255,255,255,0.07);
    border-radius: 100px;
    position: relative;
    overflow: visible;
    border: 1px solid var(--border);
}

.therm-fill {
    height: 100%;
    border-radius: 100px;
    background: linear-gradient(90deg, #5ec8ff, var(--accent), var(--accent-2));
    transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    width: 0%;
}

.therm-needle {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
    transition: left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    left: 0%;
}

/* ===========================
   HINT BANNER
=========================== */
.hint-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    margin-bottom: 22px;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    font-weight: 500;
}

.hint-banner.too-low {
    border-color: rgba(94, 200, 255, 0.4);
    background: rgba(94, 200, 255, 0.07);
    color: #5ec8ff;
}

.hint-banner.too-high {
    border-color: rgba(245, 90, 90, 0.4);
    background: rgba(245, 90, 90, 0.07);
    color: #f55a5a;
}

.hint-banner.neutral { border-color: var(--border); color: var(--text-muted); }

#hintIcon { font-size: 1.3rem; }

/* ===========================
   GUESS SECTION
=========================== */
.guess-section {
    display: flex;
    gap: 12px;
    align-items: stretch;
    margin-bottom: 24px;
}

.guess-section .input-wrapper { flex: 1; }

.guess-section .btn-primary {
    width: auto;
    padding: 14px 22px;
    white-space: nowrap;
    font-size: 1rem;
    border-radius: var(--radius-sm);
}

/* ===========================
   HISTORY
=========================== */
.history-section { min-height: 50px; }

.history-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.history-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill {
    padding: 5px 14px;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 700;
    transition: transform 0.15s ease;
    animation: popIn 0.3s var(--transition) both;
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.5); }
    to   { opacity: 1; transform: scale(1); }
}

.pill:hover { transform: scale(1.1); }

.pill.low {
    background: var(--pill-low);
    border: 1px solid rgba(94, 200, 255, 0.3);
    color: #5ec8ff;
}

.pill.high {
    background: var(--pill-high);
    border: 1px solid rgba(245, 90, 90, 0.3);
    color: #f55a5a;
}

.pill.correct {
    background: var(--pill-correct);
    border: 1px solid rgba(62, 245, 168, 0.4);
    color: var(--success);
}

/* ===========================
   WIN SCREEN
=========================== */
.win-card {
    text-align: center;
    position: relative;
    z-index: 20;
}

.win-emoji {
    font-size: 5rem;
    margin-bottom: 16px;
    animation: bounce 1s var(--transition) infinite alternate;
    filter: drop-shadow(0 0 20px rgba(62, 245, 168, 0.5));
    display: block;
}

@keyframes bounce {
    from { transform: translateY(0) rotate(-5deg); }
    to   { transform: translateY(-12px) rotate(5deg); }
}

.win-title {
    font-size: 2.2rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--success), #a0ffdf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.win-subtitle {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-bottom: 32px;
}

.win-subtitle strong { color: var(--text-primary); }

.win-stats {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 32px;
}

.stat-box {
    flex: 1;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 12px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 900;
    background: linear-gradient(135deg, #c4b0ff, #f35ab9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-top: 4px;
}

.win-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.win-buttons .btn-ghost {
    padding: 14px;
    font-size: 0.95rem;
    width: 100%;
    justify-content: center;
}

/* ===========================
   CONFETTI
=========================== */
.confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 15;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    top: -10px;
    width: 10px;
    height: 10px;
    opacity: 0;
    animation: confettiFall linear forwards;
    border-radius: 2px;
}

@keyframes confettiFall {
    0%   { opacity: 1; transform: translateY(0) rotate(0deg); }
    100% { opacity: 0; transform: translateY(110vh) rotate(720deg); }
}

/* ===========================
   SHAKE ANIMATION
=========================== */
.shake {
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-8px); }
    40%       { transform: translateX(8px); }
    60%       { transform: translateX(-5px); }
    80%       { transform: translateX(5px); }
}

/* ===========================
   RESPONSIVE
=========================== */
@media (max-width: 520px) {
    .card { padding: 28px 20px; }
    .logo-text { font-size: 1.6rem; }
    .attempts-count { font-size: 2.8rem; }
    .win-title { font-size: 1.8rem; }
    .win-stats { gap: 8px; }
    .stat-value { font-size: 1.4rem; }
    .guess-section { flex-direction: column; }
    .guess-section .btn-primary { width: 100%; }
}
