/* SynthCode – style.css (dark mode, responsive) */

/* -------------------------------------------------
   Root variables – easy theming & scaling
   ------------------------------------------------- */
:root {
    /* Colors */
    --color-bg: #121212;
    --color-surface: #1e1e1e;
    --color-primary: #00bcd4;
    --color-primary-dark: #0097a7;
    --color-text: #e0e0e0;
    --color-muted: #777777;
    --color-success: #4caf50;
    --color-error: #f44336;

    /* Layout */
    --max-width: 960px;
    --gap: 1rem;

    /* Typography */
    --font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-size-base: 1rem;
    --font-size-lg: 1.25rem;
    --font-size-sm: 0.875rem;

    /* Transitions */
    --transition-fast: 0.15s ease-out;
}

/* -------------------------------------------------
   Global resets & base styles
   ------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    width: 100%;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    background: var(--color-bg);
    color: var(--color-text);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* -------------------------------------------------
   Canvas container – scales with viewport
   ------------------------------------------------- */
#canvas-container {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--color-bg);
    overflow: hidden;
}

/* Canvas itself – keep aspect ratio */
#gameCanvas {
    width: 100%;
    height: 100%;
    max-width: var(--max-width);
    max-height: calc(var(--max-width) * 0.5625); /* 16:9 ratio */
    background: var(--color-surface);
    border: 2px solid var(--color-primary);
    border-radius: 8px;
}

/* -------------------------------------------------
   UI overlay – common layout for all screens
   ------------------------------------------------- */
.ui-screen {
    position: absolute;
    inset: 0;
    display: none;               /* hidden by default, shown via .active */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--gap);
    gap: var(--gap);
    background: rgba(0, 0, 0, 0.75);
    color: var(--color-text);
    text-align: center;
    pointer-events: none;        /* enable pointer only on child elements */
}

/* Show active screen */
.ui-screen.active {
    display: flex;
    pointer-events: auto;
}

/* -------------------------------------------------
   Common UI components
   ------------------------------------------------- */
.button {
    min-width: 8rem;
    padding: 0.6rem 1.2rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: var(--font-size-lg);
    cursor: pointer;
    transition: background var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    pointer-events: auto;
}
.button:hover,
.button:focus {
    background: var(--color-primary-dark);
}
.button:active {
    transform: scale(0.97);
}

/* Small secondary button */
.button.secondary {
    background: var(--color-muted);
}
.button.secondary:hover {
    background: #555;
}

/* Text blocks */
.title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: var(--gap);
}
.subtitle {
    font-size: 1.5rem;
    margin-bottom: calc(var(--gap) * 0.5);
}
.paragraph {
    font-size: var(--font-size-base);
    max-width: 28rem;
    line-height: 1.5;
}

/* -------------------------------------------------
   Specific screens (IDs for JS targeting)
   ------------------------------------------------- */
#title-screen .logo {
    font-size: 3rem;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: var(--gap);
}
#tutorial-screen ul {
    list-style: disc inside;
    text-align: left;
    margin: var(--gap) 0;
}
#game-main .hud {
    position: absolute;
    top: var(--gap);
    left: var(--gap);
    right: var(--gap);
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}
#game-main .hud .info {
    background: rgba(0,0,0,0.6);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: var(--font-size-sm);
}
#ai-lab,
#market,
#leaderboard,
#settings,
#result {
    width: 100%;
    max-width: var(--max-width);
}

/* Agent slots */
.agent-slot {
    width: 4rem;
    height: 4rem;
    border: 2px dashed var(--color-muted);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0.3rem;
    background: var(--color-surface);
    position: relative;
}
.agent-slot.filled {
    border-style: solid;
    border-color: var(--color-primary);
}
.agent-slot .tag {
    font-size: 0.75rem;
    background: var(--color-primary);
    color: #fff;
    padding: 0.2rem 0.4rem;
    border-radius: 2px;
}

/* Market info panel */
.market-panel {
    position: absolute;
    bottom: var(--gap);
    left: var(--gap);
    right: var(--gap);
    background: rgba(0,0,0,0.6);
    padding: var(--gap);
    border-radius: 6px;
    display: flex;
    justify-content: space-around;
    font-size: var(--font-size-sm);
}

/* Leaderboard table */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--gap);
}
.leaderboard-table th,
.leaderboard-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--color-muted);
}
.leaderboard-table th {
    background: var(--color-primary);
    color: #fff;
}
.leaderboard-table tr:hover {
    background: rgba(255,255,255,0.05);
}

/* Settings toggles */
.toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.toggle input {
    width: 2rem;
    height: 1rem;
    -webkit-appearance: none;
    background: var(--color-muted);
    border-radius: 1rem;
    position: relative;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.toggle input:checked {
    background: var(--color-primary);
}
.toggle input::after {
    content: "";
    position: absolute;
    top: 0.1rem;
    left: 0.1rem;
    width: 0.8rem;
    height: 0.8rem;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}
.toggle input:checked::after {
    transform: translateX(1rem);
}

/* -------------------------------------------------
   Responsive adjustments
   ------------------------------------------------- */
@media (max-width: 600px) {
    .title { font-size: 2rem; }
    .subtitle { font-size: 1.2rem; }
    .button { min-width: 6rem; padding: 0.5rem 1rem; }
    #gameCanvas {
        max-width: 100%;
        max-height: 100%;
    }
    .hud .info { font-size: var(--font-size-sm); }
    .agent-slot { width: 3rem; height: 3rem; }
}

/* -------------------------------------------------
   Utility classes
   ------------------------------------------------- */
.hidden { display: none !important; }
.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-error   { color: var(--color-error); }
