:root {
    --bg-color: #050510;
    --text-color: #ffffff;
    --accent-color: #00f0ff;
    --danger-color: #ff2a2a;
    --ui-font: 'Press Start 2P', monospace;
    --ui-font-secondary: 'Outfit', sans-serif;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--ui-font);
    overflow: hidden;
    user-select: none;
}

p,
button,
input,
label,
.subtitle,
#cal-step-desc {
    font-family: var(--ui-font-secondary);
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 6px;
    box-sizing: border-box;
}

.screen {
    text-align: center;
    background: rgba(5, 5, 16, 0.95);
    padding: 3rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: auto;
    transition: opacity 0.5s ease;
    box-sizing: border-box;
    min-width: 0;
    max-width: 520px;
    width: 100%;
    margin: 0;
    max-height: calc(100vh - 20px);
    overflow-y: auto;
}

@media (max-width: 600px) {
    .screen {
        padding: 2rem 1.5rem;
    }
}

h1 {
    font-weight: 700;
    font-size: 1.7rem;
    letter-spacing: 0.2rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 20px var(--accent-color);
    text-transform: uppercase;
}

.subtitle {
    font-weight: 300;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 2rem;
}

#cal-step-title {
    font-size: 1.3rem;
    letter-spacing: 0.12rem;
}

.cal-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 6px;
}

#cal-step-desc {
    font-size: 1.3rem;
    font-weight: 500;
    letter-spacing: 0.05rem;
    color: rgba(255, 255, 255, 0.85);
    margin: 0.5rem 0 1.5rem;
}

.cal-visual {
    display: block;
    width: 82px;
    height: auto;
    margin: 0;
    opacity: 0.9;
}

button {
    background: transparent;
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
    padding: 1rem 3rem;
    font-size: 1.2rem;
    font-family: var(--ui-font);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    margin-top: 1rem;
}

button:hover {
    background: var(--accent-color);
    color: var(--bg-color);
    box-shadow: 0 0 30px var(--accent-color);
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.button-row {
    display: flex;
    gap: 14px;
    justify-content: center;
    align-items: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    padding-top: 12px;
    background: rgba(5, 5, 16, 0.95);
}

button.small {
    padding: 0.6rem 1.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-width: 1px;
    margin-top: 0;
}

button.ghost {
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.7);
}

button.small:hover {
    box-shadow: none;
}

.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

/* Visualization */
#calibration-canvas {
    width: 100%;
    max-width: 600px;
    height: 200px;
    background: #111;
    border: 1px solid #333;
    border-radius: 8px;
    margin: 20px auto;
    display: block;
}

.meter-container {
    width: 100%;
    height: 40px;
    background: #111;
    border: 1px solid #333;
    border-radius: 4px;
    margin: 16px 0 10px;
    position: relative;
    overflow: hidden;
}

#meter-fill {
    height: 100%;
    width: 0%;
    background: var(--text-color);
    transition: width 0.1s linear;
    z-index: 1;
    position: absolute;
    left: 0;
    top: 0;
}

#meter-target-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 40%;
    right: 40%;
    /* 40-60% zone */
    background: rgba(0, 240, 255, 0.2);
    border-left: 1px solid var(--accent-color);
    border-right: 1px solid var(--accent-color);
    z-index: 2;
}

.controls {
    margin: 20px 0;
    font-size: 0.9rem;
    color: #888;
}

.controls label {
    display: block;
    margin: 8px 0 4px;
}

input[type=range] {
    width: 260px;
    margin-top: 4px;
}

#cal-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 22px;
    justify-content: center;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 10px;
}

#cal-metrics span {
    color: var(--accent-color);
    font-weight: 500;
}

#cal-training {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 22px;
    justify-content: center;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 8px;
}

#cal-training span {
    color: var(--accent-color);
    font-weight: 600;
}

#game-ui {
    position: absolute;
    top: 20px;
    left: 20px;
    font-weight: 500;
    font-size: 1.2rem;
}

#score-display {
    color: var(--accent-color);
}

#debug-volume {
    margin-top: 10px;
    font-size: 0.8rem;
    opacity: 0.5;
}

#credits {
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: center;
    margin: 18px 0 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

#credits-avatar {
    width: 64px;
    height: 64px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    object-fit: cover;
}

#credits-text {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}

.credits-title {
    font-family: var(--ui-font-secondary);
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.85);
}

.credits-links {
    display: flex;
    gap: 10px;
    align-items: center;
}

.credit-link {
    display: inline-flex;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 4px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.credit-link img {
    width: 18px;
    height: 18px;
}

.credit-link:hover {
    transform: translateY(-1px);
    border-color: var(--accent-color);
}

#volume-hint {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(5, 5, 16, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    font-size: 0.9rem;
    letter-spacing: 0.02rem;
    pointer-events: none;
    z-index: 3;
    max-width: 90vw;
    text-align: center;
    box-sizing: border-box;
    overflow: hidden;
    flex-wrap: nowrap;
    justify-content: center;
}

.hint-text {
    font-family: var(--ui-font-secondary);
    color: rgba(255, 255, 255, 0.85);
    max-width: 70vw;
    line-height: 1.2;
    flex: 1 1 auto;
    min-width: 0;
}

.hint-icons {
    position: relative;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
}

.hint-icon {
    position: absolute;
    inset: 0;
    width: 36px;
    height: 36px;
    opacity: 0;
}

.hint-icon-up {
    animation: hintToggle 1s steps(1, end) infinite;
}

.hint-icon-down {
    animation: hintToggle 1s steps(1, end) infinite reverse;
}

@keyframes hintToggle {
    0% { opacity: 1; }
    49% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 0; }
}
