:root,
[data-theme="dark"] {
    --timetrader-bg-overlay: linear-gradient(135deg, rgba(15, 12, 41, 0.72) 0%, rgba(48, 43, 99, 0.78) 50%, rgba(36, 36, 62, 0.82) 100%);
    --timetrader-text: #fff;
    --timetrader-key-label: rgba(255, 255, 255, 0.8);
    --timetrader-alt-label: #fff;
    --timetrader-dot: rgba(255, 255, 255, 0.9);
    --timetrader-empty-dot: rgba(255, 255, 255, 0.4);
    --theme-toggle-bg: rgba(0, 0, 0, 0.25);
    --theme-toggle-border: rgba(255, 255, 255, 0.2);
    --theme-toggle-color: #fff;
}

[data-theme="light"] {
    --timetrader-bg-overlay: linear-gradient(135deg, rgba(200, 210, 220, 0.85) 0%, rgba(180, 195, 210, 0.9) 50%, rgba(170, 185, 200, 0.95) 100%);
    --timetrader-text: #0a0a1a;
    --timetrader-key-label: rgba(10, 10, 26, 0.85);
    --timetrader-alt-label: #0a0a1a;
    --timetrader-dot: rgba(10, 10, 26, 0.95);
    --timetrader-empty-dot: rgba(10, 10, 26, 0.5);
    --theme-toggle-bg: rgba(220, 225, 235, 0.85);
    --theme-toggle-border: rgba(0, 0, 0, 0.25);
    --theme-toggle-color: #0a0a1a;
}

/* Background */
body {
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    font-family: 'Segoe UI', system-ui, sans-serif;
    color: var(--timetrader-text);
    transition: color 0.35s ease;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--timetrader-bg-overlay);
    pointer-events: none;
    z-index: -10;
    transition: background 0.35s ease;
}

.icon-grid {
    position: relative;
    z-index: 1;
}

/* TimeTrader keypad layout */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(4, 120px);
    grid-gap: 24px;
    padding: 20px;
}

/* Explicit keypad geometry follows the standard invisible TimeTrader keypad. */
.icon-tile[data-key="/"] { grid-column: 3; grid-row: 1; }
.icon-tile[data-key="*"] { grid-column: 4; grid-row: 1; }
.icon-tile[data-key="7"] { grid-column: 2; grid-row: 2; }
.icon-tile[data-key="8"] { grid-column: 3; grid-row: 2; }
.icon-tile[data-key="9"] { grid-column: 4; grid-row: 2; }
.icon-tile[data-key="4"] { grid-column: 2; grid-row: 3; }
.icon-tile[data-key="5"] { grid-column: 3; grid-row: 3; }
.icon-tile[data-key="6"] { grid-column: 4; grid-row: 3; }
.icon-tile[data-key="1"] { grid-column: 2; grid-row: 4; }
.icon-tile[data-key="2"] { grid-column: 3; grid-row: 4; }
.icon-tile[data-key="3"] { grid-column: 4; grid-row: 4; }
.icon-tile[data-key="0"] { grid-column: 2 / span 2; grid-row: 5; width: 100%; }
.icon-tile[data-key="."] { grid-column: 4; grid-row: 5; }

/* Individual Key Styling - NO BACKGROUND */
.icon-tile {
    width: 120px;
    height: 120px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    background: transparent;
    border: none;
    transition: transform 0.15s ease;
    cursor: pointer;
    overflow: hidden;
}

.icon-tile:hover {
    transform: scale(1.08);
}

.icon-tile:active {
    transform: scale(0.95);
}

.icon-tile.disabled {
    cursor: default;
    pointer-events: none;
    opacity: 0.45;
}

.icon-tile.disabled:hover,
.icon-tile.disabled:active {
    transform: none;
}

.icon-tile a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 84px;
    flex: 0 0 84px;
    position: relative;
    z-index: 1;
}

/* Images - NO SHADOWS, NO BACKGROUND */
.icon-tile img {
    width: 72px;
    height: 72px;
    object-fit: contain;
}

.icon-tile img[src=""],
.icon-tile img:not([src]) {
    display: none;
}

/* Number label on each key */
.key-label {
    position: absolute;
    top: 4px;
    left: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--timetrader-key-label);
    pointer-events: none;
}

/* Period key dot */
.dot-icon {
    font-size: 2.5rem;
    line-height: 1;
    color: var(--timetrader-dot);
    pointer-events: none;
}

/* Alt label - hidden by default, shown only when labels are active */
.alt-label {
    display: none;
    width: 100%;
    text-align: center;
    font-size: 0.7rem;
    line-height: 1.15;
    font-weight: 600;
    color: var(--timetrader-alt-label);
    letter-spacing: 0.02em;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 6px;
    margin-top: 6px;
    box-sizing: border-box;
}

/* Show labels when the labels key is active */
body.labels-active .alt-label {
    display: block;
}

body.labels-active .alt-label:empty {
    display: none;
}

.icon {
    font-size: 0.8rem;
    margin-bottom: 5px;
}

/* Period key pressed state */
#period-key.period-held {
    transform: scale(0.95);
}

/* Empty tile placeholder dot */
.icon-tile.icon:empty::after {
    content: '•';
    font-size: 1.5rem;
    color: var(--timetrader-empty-dot);
}
