:root {
    --border-color: #e1e1e1;
    --bg-light: #f9f9f9;
    --text-color: #1a1a1a;
    --subtext-color: #666;
    --heading-color: #000;

    --ad-background-color: #d60000; /* LIVE badge */
    --white: #ffffff;
    --font-xs: 12px;
}

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-light);
    color: var(--text-color);
    line-height: 1.5;
    font-size: 16px;
}

/* Layout */
.wrapper { display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1; }

header, footer {
    text-align: center;
    padding: 1rem;
    background: #fff;
}
header { border-bottom: 1px solid var(--border-color); }
footer { border-top: 1px solid var(--border-color); font-size: 0.8rem; color: var(--subtext-color); }

.center { text-align: center; }

.container { max-width: 800px; margin: 2rem auto; padding: 0 1rem; }

.subtitle {
    font-size: 0.875rem;
    color: var(--subtext-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0.25rem 0 0;
}

/* =========================
   Tables (shared styles)
   ========================= */
.table-container {
    background: #fff;
    border-radius: 8px;
    overflow-x: hidden; /* no horizontal scroll */
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.gold-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto; /* natural sizing */
}

.gold-table th,
.gold-table td {
    border: 1px solid var(--border-color);
    padding: 0.6rem 0.4rem;
    text-align: center;
}

/* Headers: allow wrapping, keep neat */
.gold-table th {
    background: #f1f1f1;
    color: var(--heading-color);
    white-space: normal;         /* headers may wrap */
    word-break: normal;
    overflow-wrap: anywhere;     /* prevent overflow on long words */
}

/* Keep "Karat" header on one line */
.gold-table th:first-child { white-space: nowrap; }

/* Cells: numbers single-line by default */
.gold-table td {
    white-space: nowrap;         /* numbers won't wrap */
    word-break: keep-all;
}

/* If you need text to wrap (e.g., descriptions), add class="wrap-text" to that <td> */
.gold-table td.wrap-text {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

/* Zebra + hover */
.gold-table tbody tr:nth-child(even) td { background: #fafafa; }
.gold-table tbody tr:hover td { background: #f0f4f8; }

/* Meta text */
.updated,
.gold-rate-source {
    text-align: center;
    font-size: 0.75rem;
    color: var(--subtext-color);
    margin-top: 0.75rem;
}

.error { text-align: center; color: red; font-weight: 600; margin-top: 2rem; }

/* LIVE badge */
.live-badge {
    margin-left: 10px;
    align-items: center;
    background-color: var(--ad-background-color);
    border-radius: 3px;
    color: var(--white);
    font-size: var(--font-xs);
    justify-content: center;
    line-height: 14px;
    padding: 2px 4px;
    display: inline-flex;
    animation: pulseLive 1.5s infinite;
}

@keyframes pulseLive {
    0%   { box-shadow: 0 0 0 0 rgba(255,0,0,0.6); }
    70%  { box-shadow: 0 0 0 8px rgba(255,0,0,0); }
    100% { box-shadow: 0 0 0 0 rgba(255,0,0,0); }
}

/* =========================
   Ticker
   ========================= */
.ticker-container {
    overflow: hidden;
    background: #111;
    color: #f1c40f;
    white-space: nowrap;
    border-top: 2px solid gold;
    border-bottom: 2px solid gold;
    font-family: sans-serif;
    font-size: 14px;
    padding: 8px 0;
    position: relative;
}
.ticker-content {
    display: inline-block;
    padding-left: 100%;
    animation: ticker-scroll 25s linear infinite;
}
.ticker-item { display: inline-block; margin-right: 3rem; }
@keyframes ticker-scroll {
    0% { transform: translateX(0%); }
    100% { transform: translateX(-100%); }
}

/* Stars */
.star-rating { font-size: 1.6rem; color: gold; margin-top: 0.3rem; letter-spacing: 2px; }

/* =========================
   Mobile tweaks
   ========================= */
@media (max-width: 600px) {
    body { font-size: 14px; }
    header h1 { font-size: 1.25rem; }
    .subtitle { font-size: 0.75rem; }

    .gold-table th {
        font-size: 0.72rem;
        padding: 0.45rem 0.3rem;
        line-height: 1.25;
    }
    .gold-table td {
        font-size: 0.72rem;
        padding: 0.3rem 0.2rem;
    }

    /* Slightly smaller for first header cell so "Karat" never breaks */
    .gold-table th:first-child { font-size: 0.68rem; }
}





/* ===== Gold Calculator – improved look ===== */
.gc-title {
    margin: 0 0 0.75rem 0;
    padding: 1rem;
    border-radius: 10px;
    background: linear-gradient(180deg, #fff, #f6f6f6);
    border: 1px solid var(--border-color);
    text-align: center;
}
.gc-title-main {
    display: block;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.2px;
    color: var(--heading-color);
}
.gc-title-sub {
    display: block;
    margin-top: 4px;
    font-size: 0.82rem;
    color: var(--subtext-color);
}

.gold-calculator {
    padding: 1rem;
    margin-top: 1rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

.gc-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
    padding: 0.75rem 0 0.25rem;
}

.gc-field { display: flex; flex-direction: column; gap: 0.4rem; }
.gc-field span { font-size: 0.85rem; color: var(--subtext-color); }
.gc-field select, .gc-field input {
    padding: 0.65rem 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #fff;
    outline: none;
}
.gc-field select:focus, .gc-field input:focus {
    box-shadow: 0 0 0 3px rgba(212,175,55,0.18);
}

.gc-actions {
    display: flex;
    gap: 0.6rem;
    align-items: end;
    justify-content: flex-start;
}
.gc-btn {
    padding: 0.7rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #111;
    color: #fff;
    cursor: pointer;
    font-weight: 600;
}
.gc-btn:hover { filter: brightness(1.05); }
.gc-btn.ghost {
    background: transparent;
    color: #111;
}

.gc-note {
    grid-column: 1 / -1;
    font-size: 0.82rem;
    color: var(--subtext-color);
}

.gc-result { padding-top: 0.75rem; }
.gc-result-box {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
}
.gc-line { margin-bottom: 0.4rem; }
.gc-total { margin-top: 0.6rem; font-size: 1.15rem; font-weight: 800; }

/* Responsive */
@media (max-width: 720px) {
    .gc-grid { grid-template-columns: 1fr 1fr; }
    .gc-actions { grid-column: 1 / -1; }
}
@media (max-width: 420px) {
    .gc-grid { grid-template-columns: 1fr; }
}
