/* style.css — Ricochet Market — Neon dark theme */

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

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    background: #0a0a1a;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: #eeeeff;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 540px;
    height: 100%;
    margin: 0 auto;
    overflow: hidden;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: default;
}
#game-canvas.aiming {
    cursor: crosshair;
}

/* ─── Screens (overlay panels) ─── */
.screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    background: rgba(10, 10, 26, 0.92);
    padding: 20px;
    animation: fadeIn 0.3s ease-out;
}
.screen.hidden { display: none !important; }

h1 {
    font-size: 3.4em;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 8px;
    color: #ffcc00;
    text-shadow:
        0 0 30px rgba(255, 204, 0, 0.7),
        0 0 80px rgba(255, 204, 0, 0.3),
        0 3px 0 #aa8800;
    line-height: 1.05;
    margin-bottom: 4px;
    animation: titlePulse 4s ease-in-out infinite;
}
h1 span {
    display: block;
    font-size: 0.6em;
    color: #ff6622;
    letter-spacing: 14px;
    text-shadow:
        0 0 25px rgba(255, 102, 34, 0.7),
        0 0 60px rgba(255, 102, 34, 0.3);
}
@keyframes titlePulse {
    0%, 100% { text-shadow: 0 0 30px rgba(255,204,0,0.7), 0 0 80px rgba(255,204,0,0.3), 0 3px 0 #aa8800; }
    50% { text-shadow: 0 0 40px rgba(255,204,0,0.9), 0 0 100px rgba(255,204,0,0.5), 0 3px 0 #aa8800; }
}

/* ─── Title Screen ─── */
.title-logo {
    margin-bottom: 28px;
    text-align: center;
}
.title-tagline {
    font-size: 0.82em;
    color: #7778aa;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-top: 6px;
}
.menu-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    animation: slideUp 0.5s ease-out 0.5s both;
}
.menu-row {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}
.btn-glow {
    animation: glowPulse 2.5s ease-in-out infinite;
    position: relative;
}
.btn-ghost {
    background: transparent;
    border-color: rgba(100, 120, 180, 0.4);
    color: #8899bb;
}
.btn-ghost:hover {
    background: rgba(30, 30, 80, 0.5);
    border-color: rgba(100, 120, 180, 0.7);
    color: #ccccee;
}

.title-sub {
    font-size: 0.85em;
    color: #888aaa;
    margin-bottom: 30px;
    letter-spacing: 2px;
}

h2 {
    font-size: 1.8em;
    color: #ffcc00;
    text-shadow: 0 0 15px rgba(255, 204, 0, 0.4);
    margin-bottom: 20px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ─── How to Play ─── */
#how-to-play { background: rgba(8, 8, 22, 0.96) !important; }
.htp-container {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.htp-pages { width: 100%; min-height: 260px; max-height: 65vh; overflow-y: auto; }
.htp-page {
    text-align: center;
    padding: 0 10px;
    animation: fadeIn 0.3s ease-out;
}
.htp-page.hidden { display: none; }
.htp-page h3 {
    color: #ffcc00;
    font-size: 1.3em;
    margin-bottom: 10px;
    text-shadow: 0 0 10px rgba(255,204,0,0.3);
}
.htp-page p {
    color: #aabbcc;
    font-size: 0.9em;
    line-height: 1.5;
}
.htp-visual {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.htp-peg-row {
    display: flex;
    gap: 16px;
    align-items: center;
}
.htp-peg {
    width: 28px; height: 28px;
    border-radius: 50%;
    position: relative;
}
.htp-hazard::after {
    content: "\2620";
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    color: #fff;
}
.htp-list {
    text-align: left;
    max-width: 280px;
    margin: 0 auto;
    font-size: 0.85em;
    line-height: 1.8;
    color: #aabbcc;
}
.htp-fever-demo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.htp-fever-bar {
    width: 200px;
    height: 16px;
    background: #111125;
    border: 1px solid #333366;
    border-radius: 8px;
    overflow: hidden;
}
.htp-fever-fill {
    height: 100%;
    width: 75%;
    background: linear-gradient(90deg, #3388ff, #44cc44, #ffaa00, #ff4444);
    border-radius: 8px;
    animation: feverGrow 3s ease-in-out infinite;
}
@keyframes feverGrow {
    0%, 100% { width: 20%; }
    50% { width: 100%; }
}
.htp-fever-labels {
    display: flex;
    gap: 18px;
    font-size: 0.8em;
    font-weight: bold;
}
.htp-master-icons {
    display: flex;
    gap: 10px;
}
.htp-mi {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 2px solid;
    background: rgba(20,20,50,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1em;
    animation: floatPeg 4s ease-in-out infinite;
}
.htp-mi:nth-child(2) { animation-delay: 0.5s; }
.htp-mi:nth-child(3) { animation-delay: 1s; }
.htp-mi:nth-child(4) { animation-delay: 1.5s; }
.htp-mi:nth-child(5) { animation-delay: 2s; }
@keyframes floatPeg {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
.htp-stage-path {
    display: flex;
    align-items: center;
    gap: 0;
}
.htp-sp-dot {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: #4488ff;
    box-shadow: 0 0 8px #4488ff;
    flex-shrink: 0;
}
.htp-sp-elite { background: #ffaa00; box-shadow: 0 0 10px #ffaa00; }
.htp-sp-boss { background: #ff4444; box-shadow: 0 0 12px #ff4444; width: 22px; height: 22px; }
.htp-sp-line {
    width: 20px; height: 2px;
    background: rgba(100,120,200,0.3);
    flex-shrink: 0;
}
.htp-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}
.htp-dots {
    display: flex;
    gap: 6px;
}
.htp-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #333366;
    transition: all 0.2s;
}
.htp-dot.active {
    background: #ffcc00;
    box-shadow: 0 0 6px rgba(255,204,0,0.5);
}

/* ─── Buttons ─── */
.btn {
    display: block;
    width: 240px;
    padding: 14px 20px;
    margin: 8px auto;
    font-size: 1.05em;
    font-weight: 700;
    color: #ccccee;
    background: linear-gradient(180deg, #222244, #1a1a36);
    border: 2px solid #4466aa;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-family: inherit;
}
.btn:hover, .btn:active {
    background: linear-gradient(180deg, #2a2a55, #222244);
    border-color: #6688dd;
    box-shadow: 0 0 18px rgba(68, 102, 170, 0.45);
    transform: scale(1.03);
    color: #ffffff;
}
.btn-primary {
    background: linear-gradient(180deg, #553300, #3d2200);
    border-color: #ffcc00;
    color: #ffcc00;
}
.btn-primary:hover, .btn-primary:active {
    background: linear-gradient(180deg, #664400, #553300);
    box-shadow: 0 0 22px rgba(255, 204, 0, 0.45);
    border-color: #ffdd44;
    color: #ffdd44;
}
.btn-share {
    background: linear-gradient(180deg, #1a3a5c, #0d2440);
    border-color: #4488ff;
    color: #88ccff;
    font-size: 0.9em;
}
.btn-share:hover, .btn-share:active {
    background: linear-gradient(180deg, #224466, #1a3a5c);
    box-shadow: 0 0 18px rgba(68, 136, 255, 0.4);
    border-color: #66aaff;
    color: #bbddff;
}
.btn-small {
    width: auto;
    padding: 8px 18px;
    font-size: 0.85em;
}
.btn-icon {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(30, 30, 60, 0.85);
    border: 1px solid #4466aa;
    color: #ccccee;
    font-size: 1em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    font-family: inherit;
}
.btn-icon:hover {
    background: rgba(50, 50, 90, 0.9);
    border-color: #6688dd;
}

/* ─── HUD ─── */
#hud {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 5;
    pointer-events: none;
}
#hud > * { pointer-events: auto; }
#hud-left, #hud-right { display: flex; flex-direction: column; gap: 2px; }
#hud-left { align-items: flex-start; }
#hud-right { align-items: flex-end; }

#hud-score {
    font-size: 1.6em;
    font-weight: 800;
    color: #ffcc00;
    text-shadow: 0 0 12px rgba(255, 204, 0, 0.5);
    line-height: 1;
}
#hud-stage {
    font-size: 0.8em;
    color: #8899bb;
    letter-spacing: 1px;
}
#hud-balls {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    max-width: 160px;
}
.ball-dot {
    width: 13px; height: 13px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffffff, #88ccff);
    box-shadow: 0 0 5px rgba(136, 204, 255, 0.5);
    transition: opacity 0.3s;
}
.ball-dot.used {
    opacity: 0.15;
    background: #333355;
    box-shadow: none;
}
#hud-master {
    font-size: 0.75em;
    color: #aabbcc;
    letter-spacing: 1px;
}

/* ─── Fever Bar ─── */
#fever-container {
    position: absolute;
    right: 6px;
    top: 60px;
    bottom: 100px;
    width: 22px;
    z-index: 5;
}
#fever-bg {
    width: 100%; height: 100%;
    background: #111125;
    border: 1px solid #333366;
    border-radius: 11px;
    overflow: hidden;
    position: relative;
}
#fever-fill {
    position: absolute;
    bottom: 0; left: 0;
    width: 100%;
    background: linear-gradient(to top, #3388ff, #44cc44);
    border-radius: 11px;
    transition: height 0.4s ease-out;
}
#fever-label {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1em;
    font-weight: 800;
    color: #ffcc00;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.6);
    white-space: nowrap;
    z-index: 6;
}

/* ─── Master Select ─── */
#master-select { overflow-y: auto; justify-content: flex-start; padding-top: 30px; }
.master-select-sub {
    font-size: 0.8em;
    color: #7788aa;
    margin-top: -14px;
    margin-bottom: 18px;
    letter-spacing: 1px;
}
#master-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 460px;
    padding: 0 12px;
}
.master-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(135deg, rgba(20,20,55,0.95), rgba(15,15,40,0.95));
    border: 2px solid #3344aa;
    border-radius: 16px;
    padding: 14px 16px;
    text-align: left;
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
    animation: slideUp 0.4s ease-out both;
}
.master-card:nth-child(2) { animation-delay: 0.06s; }
.master-card:nth-child(3) { animation-delay: 0.12s; }
.master-card:nth-child(4) { animation-delay: 0.18s; }
.master-card:nth-child(5) { animation-delay: 0.24s; }
.master-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(ellipse at 0% 50%, var(--mc, #4488ff)15, transparent 70%);
    opacity: 0.08;
    transition: opacity 0.25s;
}
.master-card:hover {
    transform: translateX(6px);
    border-color: var(--mc, #6688cc);
    box-shadow: 0 4px 25px rgba(0,0,0,0.4), 0 0 20px var(--mg, rgba(68,102,170,0.2));
}
.master-card:hover::before { opacity: 0.18; }
.master-card.locked {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(0.7);
}
.master-card .mc-icon {
    width: 56px; height: 56px;
    min-width: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    font-weight: bold;
    position: relative;
    z-index: 1;
}
.master-card .mc-info { flex: 1; min-width: 0; position: relative; z-index: 1; }
.master-card .mc-row-top {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}
.master-card h3 {
    font-size: 1.15em;
    margin: 0;
}
.master-card .mc-title {
    font-size: 0.68em;
    color: #777799;
    font-style: italic;
}
.master-card .mc-desc {
    font-size: 0.78em;
    color: #8899aa;
    margin-bottom: 4px;
    line-height: 1.2;
}
.master-card .mc-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.mc-badge {
    font-size: 0.65em;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.mc-badge-passive {
    background: rgba(100,120,200,0.15);
    color: #99aacc;
    border: 1px solid rgba(100,120,200,0.25);
}
.mc-badge-power {
    border: 1px solid;
}
.master-card .mc-power-desc {
    display: none;
}
.master-card:hover .mc-power-desc,
.master-card:active .mc-power-desc {
    display: block;
    font-size: 0.72em;
    color: #99aabb;
    margin-top: 4px;
    line-height: 1.3;
    animation: fadeIn 0.2s ease-out;
}

/* Premium buy button */
.mc-buy-btn {
    display: inline-block;
    margin-top: 6px;
    padding: 5px 16px;
    font-size: 0.75em;
    font-weight: 700;
    color: #1a1a2e;
    background: linear-gradient(135deg, #ffd700, #ff8800);
    border: none;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 0 8px rgba(255,215,0,0.3);
}
.mc-buy-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 16px rgba(255,215,0,0.6);
}
.master-card.mc-premium {
    opacity: 0.85;
    pointer-events: auto;
    filter: grayscale(0.3);
}

/* ─── Relic Draft ─── */
#relic-cards {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 520px;
}
.relic-card {
    background: linear-gradient(180deg, #1a1a3d, #121230);
    border: 2px solid #3344aa;
    border-radius: 14px;
    padding: 18px 14px;
    width: 145px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    animation: slideUp 0.4s ease-out both;
}
.relic-card:nth-child(2) { animation-delay: 0.08s; }
.relic-card:nth-child(3) { animation-delay: 0.16s; }
.relic-card:nth-child(4) { animation-delay: 0.24s; }
.relic-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.relic-card.common { border-color: #4488ff; }
.relic-card.uncommon { border-color: #44cc44; }
.relic-card.rare { border-color: #ffaa00; }
.relic-card .rc-icon {
    font-size: 2em;
    margin-bottom: 8px;
}
.relic-card h3 {
    font-size: 0.95em;
    margin-bottom: 4px;
}
.relic-card .rc-rarity {
    font-size: 0.65em;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
}
.relic-card .rc-desc {
    font-size: 0.78em;
    color: #99aabb;
    line-height: 1.3;
}

/* ─── Event Screen ─── */
#event-desc {
    color: #99aabb;
    text-align: center;
    margin-bottom: 20px;
    font-size: 0.95em;
    max-width: 400px;
    line-height: 1.4;
}
#event-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 400px;
}
.event-choice {
    background: linear-gradient(180deg, #1a1a3d, #121230);
    border: 2px solid #3344aa;
    border-radius: 10px;
    padding: 14px 18px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}
.event-choice:hover {
    border-color: #ffcc00;
    background: linear-gradient(180deg, #222250, #1a1a44);
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.15);
}
.event-choice h4 {
    color: #ffcc00;
    margin-bottom: 4px;
    font-size: 1em;
}
.event-choice p {
    font-size: 0.82em;
    color: #99aabb;
}

/* ─── Game Over / Victory ─── */
#gameover-stats, #victory-stats {
    text-align: center;
    margin: 12px 0 20px;
    width: 100%;
    max-width: 320px;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 7px 0;
    border-bottom: 1px solid rgba(50, 50, 100, 0.5);
}
.stat-label { color: #8899aa; font-size: 0.9em; }
.stat-value { color: #ffcc00; font-weight: 700; font-size: 0.95em; }

/* ─── Pause ─── */
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 220px;
    margin: 8px auto;
    font-size: 0.95em;
    color: #99aabb;
}
.btn-toggle {
    width: 65px;
    padding: 8px;
    font-size: 0.85em;
    text-align: center;
}

/* ─── Toasts ─── */
#toast-container {
    position: absolute;
    top: 55px;
    left: 0;
    width: 100%;
    z-index: 20;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.toast {
    background: rgba(22, 22, 54, 0.95);
    border: 1px solid #4466aa;
    border-radius: 8px;
    padding: 8px 20px;
    font-size: 0.88em;
    color: #eeeeff;
    animation: toastIn 0.3s ease-out, toastOut 0.4s 2.2s ease-in forwards;
    white-space: nowrap;
    text-shadow: 0 0 8px rgba(200, 200, 255, 0.3);
}
.toast.gold {
    border-color: #ffcc00;
    color: #ffcc00;
}
.toast.green {
    border-color: #44cc44;
    color: #44cc44;
}
.toast.red {
    border-color: #ff4444;
    color: #ff4444;
}

/* ─── Relic HUD (active relics) ─── */
#hud-relics {
    position: absolute;
    left: 6px;
    bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    z-index: 5;
    max-width: 280px;
    cursor: pointer;
}
.relic-pip {
    width: 22px; height: 22px;
    flex-shrink: 0;
    border-radius: 4px;
    border: 1px solid #3344aa;
    background: #161636;
    font-size: 0.65em;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}

/* ─── Animations ─── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-15px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}
@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 204, 0, 0.3); }
    50% { box-shadow: 0 0 25px rgba(255, 204, 0, 0.6); }
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
    h1 { font-size: 2.4em; letter-spacing: 4px; }
    h2 { font-size: 1.4em; }
    .btn { width: 200px; padding: 12px 16px; font-size: 0.95em; }
    .master-card { padding: 10px 12px; }
    .master-card .mc-icon { width: 44px; height: 44px; min-width: 44px; font-size: 1.2em; }
    .master-card h3 { font-size: 1em; }
    .relic-card { width: 120px; padding: 14px 10px; }
    #hud-score { font-size: 1.3em; }
    .ball-dot { width: 10px; height: 10px; }
    .htp-peg { width: 22px; height: 22px; }
    .htp-mi { width: 34px; height: 34px; font-size: 0.9em; }
}

@media (max-width: 380px) {
    h1 { font-size: 2em; }
    .btn { width: 180px; }
    .master-card .mc-badges { gap: 4px; }
    .mc-badge { font-size: 0.6em; padding: 1px 5px; }
    .relic-card { width: 100px; padding: 10px 8px; }
}
