/* stockXchange — shared styles for landing, host board, and player views */

:root {
    --green: #177d24;
    --green-light: #22a838;
    --red: #c0392b;
    --ink: #1c2430;
    --paper: #f4f6f8;
    --gold: #e2b23c;
}

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

body {
    font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
}

.logo {
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--green);
}

.logo.small {
    font-size: 1.2rem;
}

.big-button {
    display: block;
    width: 100%;
    padding: 13px 16px;
    margin: 8px 0;
    border: none;
    border-radius: 10px;
    background: var(--green);
    color: #fff;
    font-size: 1.02rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.big-button small {
    display: block;
    font-size: 0.72rem;
    font-weight: 400;
    opacity: 0.85;
}

.big-button.join {
    background: var(--ink);
}

/* --- Landing --- */
.landing {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.landing-card {
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.landing-card .logo {
    font-size: 2.4rem;
}

.tagline {
    margin: 10px 0 28px;
    color: #5a6672;
}

.join-form {
    margin-top: 18px;
}

.join-form input,
.join-screen input {
    width: 100%;
    padding: 16px;
    margin-bottom: 10px;
    border: 2px solid #d5dbe1;
    border-radius: 12px;
    font-size: 1.1rem;
    text-align: center;
}

#code,
#codeInput {
    letter-spacing: 6px;
    font-weight: 700;
    text-transform: uppercase;
}

/* --- Host board --- */
.host {
    background: var(--ink);
    color: #fff;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.host-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.25);
}

.join-prompt {
    font-size: 1.1rem;
}

.room-code {
    display: inline-block;
    padding: 2px 12px;
    margin-left: 6px;
    border-radius: 8px;
    background: var(--gold);
    color: var(--ink);
    font-weight: 800;
    letter-spacing: 4px;
}

.host-controls {
    display: flex;
    align-items: center;
    gap: 14px;
}

.goal {
    opacity: 0.8;
}

.ctrl {
    padding: 10px 22px;
    border: none;
    border-radius: 8px;
    background: var(--green-light);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

/* Board: one column per stock, filling the space between bar and strip. */
.board {
    flex: 1;
    display: flex;
    gap: 12px;
    padding: 14px;
    min-height: 0;
}

.stock-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #263041;
    border-radius: 12px;
    border-top: 5px solid var(--accent);
    overflow: hidden;
}

.stock-head {
    padding: 12px 14px 10px;
    text-align: center;
}

.stock-name {
    display: block;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.3px;
}

.stock-price {
    font-size: 2rem;
    font-weight: 800;
    position: relative;
}

.stock-col.subpar .stock-price {
    color: var(--red);
}

/* Gentle price pulse — a brief color tint on the number only. */
.price.pulse-up {
    animation: pulseUp 0.5s ease-out;
}

.price.pulse-down {
    animation: pulseDown 0.5s ease-out;
}

.delta {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 6px;
    font-size: 0.8rem;
    font-style: normal;
    font-weight: 700;
    opacity: 0;
    transition: opacity 0.25s;
    white-space: nowrap;
}

.delta.show {
    opacity: 0.9;
}

.delta.up {
    color: var(--green-light);
}

.delta.down {
    color: #ff7a6b;
}

/* Holders of this stock (top few + overflow). */
.holders {
    padding: 4px 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.holder {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 0;
    font-size: 0.95rem;
}

.holder .hn {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.holder .hs {
    font-weight: 700;
    color: var(--accent);
}

.holder.more,
.holder.none {
    opacity: 0.5;
    font-size: 0.82rem;
    justify-content: center;
}

/* Per-stock event ticker. */
.feed {
    flex: 1;
    overflow: hidden;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.feed-item {
    font-size: 0.85rem;
    opacity: 0.55;
    transition: opacity 0.3s;
}

.feed-item.newest {
    opacity: 1;
    font-weight: 700;
}

.feed-item.up { color: var(--green-light); }
.feed-item.down { color: #ff7a6b; }
.feed-item.dividend { color: var(--gold); }
.feed-item.split { color: #7fd1ff; }
.feed-item.offmarket { color: #ff7a6b; }

/* Net-worth standings strip along the bottom. */
.leaderboard-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    overflow-x: auto;
    white-space: nowrap;
}

.lb-chip {
    padding: 6px 12px;
    border-radius: 20px;
    background: #263041;
    font-size: 1rem;
}

.lb-chip b {
    color: var(--gold);
    margin-right: 4px;
}

.lb-chip .lb-net {
    font-weight: 700;
    margin-left: 4px;
}

.lb-chip.winner {
    background: var(--gold);
    color: var(--ink);
}

.lb-chip.winner b {
    color: var(--ink);
}

.lb-count,
.lb-empty {
    opacity: 0.6;
    font-size: 0.95rem;
}

/* Scan-to-join QR in the corner. */
.qr-corner {
    position: fixed;
    right: 16px;
    bottom: 64px;
    background: #fff;
    padding: 8px 8px 4px;
    border-radius: 10px;
    text-align: center;
}

.qr-corner img {
    display: block;
    width: 104px;
    height: 104px;
}

.qr-caption {
    color: var(--ink);
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 2px;
}

.winner-banner {
    position: fixed;
    inset: auto 0 0 0;
    padding: 24px;
    background: var(--gold);
    color: var(--ink);
    font-size: 1.6rem;
    font-weight: 800;
    text-align: center;
}

/* --- Player portfolio --- */
.player {
    max-width: 560px;
    margin: 0 auto;
}

.join-screen {
    padding: 40px 24px;
    text-align: center;
}

.join-screen .logo {
    font-size: 2rem;
    margin-bottom: 24px;
}

.error {
    color: var(--red);
    margin-top: 10px;
}

.phone-top {
    position: sticky;
    top: 0;
    z-index: 5;
}

.wallet {
    padding: 14px 18px;
    background: var(--green);
    color: #fff;
}

.wallet-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.me {
    font-size: 1.3rem;
    font-weight: 800;
}

.control-area {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.ctrl-btn {
    padding: 7px 12px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
}

.ctrl-btn.claim {
    background: #fff;
    color: var(--green);
}

.ctrl-btn.play-pause,
.ctrl-btn.gear {
    font-size: 1.1rem;
    line-height: 1;
    padding: 6px 12px;
}

.controlled-by {
    font-size: 0.8rem;
    opacity: 0.9;
    white-space: nowrap;
}

.wallet-figures {
    display: flex;
    gap: 24px;
}

.wallet-figures .label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    opacity: 0.8;
}

.wallet-figures .cash,
.wallet-figures .net {
    font-size: 1.4rem;
    font-weight: 800;
}

.lot-area {
    padding: 8px 12px 10px;
    background: #e9edf1;
}

.lot-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.lot-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #5a6672;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lot-buttons {
    display: flex;
    gap: 6px;
}

.lot-btn {
    flex: 1;
    padding: 9px 0;
    border: 2px solid #cfd6dd;
    border-radius: 8px;
    background: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
}

.lot-btn.active {
    border-color: var(--green);
    background: var(--green);
    color: #fff;
}

.surprise {
    padding: 7px 12px;
    border: none;
    border-radius: 8px;
    background: var(--gold);
    font-weight: 700;
    font-size: 0.82rem;
    white-space: nowrap;
    cursor: pointer;
}

.holding {
    padding: 14px 16px;
    border-bottom: 1px solid #e4e9ee;
}

.holding.owned {
    background: #f0faf1;
}

.h-main {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.h-name {
    font-size: 1.15rem;
    font-weight: 700;
}

.h-price {
    font-size: 1.1rem;
}

.h-owned {
    font-size: 0.85rem;
    color: #5a6672;
    margin: 4px 0 10px;
}

.h-actions {
    display: flex;
    gap: 8px;
}

.h-actions button {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

.h-actions .buy {
    background: var(--green);
    color: #fff;
}

.h-actions .sell {
    background: var(--ink);
    color: #fff;
}

.h-actions .loadup {
    background: #e9edf1;
}

.h-actions button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Host status + controller indicator in the top bar. */
.status {
    font-weight: 700;
}

.status.live {
    color: var(--green-light);
}

.status.paused {
    opacity: 0.7;
}

.controller {
    opacity: 0.9;
}

/* Big momentary announcement (off-market / split). */
.announce {
    position: fixed;
    left: 50%;
    top: 34%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 30;
    max-width: 80vw;
    padding: 26px 44px;
    background: rgba(20, 26, 34, 0.96);
    border: 3px solid var(--gold);
    border-radius: 20px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.announce.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.announce[hidden] {
    display: none;
}

.announce-icon {
    font-size: 3.5rem;
    line-height: 1;
}

.announce-headline {
    font-size: 2rem;
    font-weight: 800;
    margin: 8px 0 6px;
    color: #fff;
}

.announce-detail {
    font-size: 1.15rem;
    color: #fff;
    opacity: 0.85;
}

/* One-time "click to enable sound" hint on the board. */
.sound-hint {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 25;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* Settings modal (phone). */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    width: 100%;
    max-width: 360px;
    padding: 22px;
    border-radius: 14px;
    background: #fff;
    color: var(--ink);
}

.modal h2 {
    margin-bottom: 16px;
    font-size: 1.3rem;
}

.setting {
    display: block;
    margin-bottom: 18px;
}

.setting span {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #5a6672;
}

.setting input {
    width: 100%;
    padding: 12px;
    border: 2px solid #d5dbe1;
    border-radius: 10px;
    font-size: 1.1rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-actions button {
    flex: 1;
    padding: 13px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

.modal-save {
    background: var(--green);
    color: #fff;
}

.modal-close {
    background: #e9edf1;
}

/* Host: scrolling trade ticker along the very bottom. */
.trade-marquee {
    height: 40px;
    display: flex;
    align-items: center;
    overflow: hidden;
    background: #0f1621;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.marquee-track {
    white-space: nowrap;
    will-change: transform;
}

.marquee-item {
    display: inline-block;
    margin-right: 36px;
    font-size: 1rem;
    font-weight: 600;
    color: #cbd5e1;
}

.marquee-item.colored {
    color: var(--accent);
}

/* Host: pre-game lobby with a big join QR. */
.lobby {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(16, 22, 32, 0.98);
}

.lobby[hidden] {
    display: none;
}

.lobby-inner {
    padding: 24px;
    text-align: center;
}

.logo.big {
    font-size: 2.6rem;
    margin-bottom: 18px;
}

.lobby-qr {
    display: inline-block;
    padding: 16px;
    border-radius: 16px;
    background: #fff;
}

.lobby-qr img {
    display: block;
    width: 320px;
    height: 320px;
}

.lobby-join {
    margin-top: 20px;
    font-size: 1.2rem;
    opacity: 0.85;
}

.lobby-code {
    margin: 6px 0 18px;
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 10px;
    color: var(--gold);
}

.lobby-players {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 720px;
    margin: 0 auto 18px;
}

.lobby-player {
    padding: 6px 14px;
    border-radius: 20px;
    background: #263041;
    font-weight: 600;
}

.lobby-waiting {
    opacity: 0.6;
}

.lobby-hint {
    font-size: 1.05rem;
    opacity: 0.75;
}

/* Player: rank pill + goal progress. */
.me-block {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.rank-pill {
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.22);
    font-size: 0.8rem;
    font-weight: 700;
}

.goal-progress {
    margin-top: 10px;
}

.goal-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.25);
    overflow: hidden;
}

.goal-fill {
    width: 0;
    height: 100%;
    background: var(--gold);
    transition: width 0.4s ease;
}

.goal-text {
    margin-top: 4px;
    font-size: 0.78rem;
    opacity: 0.9;
}

/* Player: settings "add bot" button. */
.setting-btn {
    width: 100%;
    padding: 12px;
    border: 2px dashed #cfd6dd;
    border-radius: 10px;
    background: #fff;
    font-size: 1rem;
    font-weight: 700;
    color: var(--green);
    cursor: pointer;
}

.setting-note {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: #8892a0;
}

@keyframes pulseUp {
    0% { color: var(--green-light); }
    100% { color: #fff; }
}

@keyframes pulseDown {
    0% { color: #ff7a6b; }
    100% { color: #fff; }
}

/* Respect reduced-motion: keep the color cue, drop the animation. */
@media (prefers-reduced-motion: reduce) {
    .price.pulse-up,
    .price.pulse-down {
        animation: none;
    }
}
