:root {
    --main-color: #3B8BBB;
    --light-main-color: #5BA3CC;
    --accent-color: #C45C5C;
    --dark-main-color: #3D5A73;
    --text-bright-color: #FFFFFF;
    --icon-color: #FFFFFF;
    --icon-bk-color: #e5e7eb;
    --dark-gray-color: #374151;
    --medium-dark-gray-color: #6b7280;
    --gray-color: #9ca3af;
    --medium-light-gray-color: #d1d5db;
    --light-gray-color: #f3f4f6;
    --large-width: 1000px;
    --middle-width: 800px;
    --header-color1: #5BA3CC;
    --header-color2: #3D5A73;
    --main-header-bg-image: linear-gradient(135deg, var(--header-color1) 0%, var(--header-color2) 100%);
    
    /* New refined variables */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;

    /* Main level colors (color1, color2) - subtle gradient */
    --lv0-color1: #45B8AC;  --lv0-color2: #3DA89D;
    --lv1-color1: #2980B9;  --lv1-color2: #2570A5;
    --lv2-color1: #7A5DA2;  --lv2-color2: #6D5192;
    --lv3-color1: #C43B46;  --lv3-color2: #B0353F;
    --lv4-color1: #DD873C;  --lv4-color2: #C87936;
    --lv5-color1: #D4A711;  --lv5-color2: #BE9610;
    --lv6-color1: #84AC39;  --lv6-color2: #769A33;
    --lv7-color1: #3D9954;  --lv7-color2: #36894B;
    --lv8-color1: #526FAE;  --lv8-color2: #49639C;
    --lv9-color1: #9F4C74;  --lv9-color2: #8E4468;
    --lv10-color1: #D16141; --lv10-color2: #BC573A;
    --lv11-color1: #D99727; --lv11-color2: #C38823;
    --lv12-color1: #ACAA25; --lv12-color2: #9A9821;
    --lv13-color1: #61A347; --lv13-color2: #57923F;
    --lv14-color1: #338D87; --lv14-color2: #2D7E79;

    /* Extra level colors - muted, subtle gradient */
    --ex1-color1: #3D6575;  --ex1-color2: #365A68;
    --ex2-color1: #655A72;  --ex2-color2: #5A5066;
    --ex3-color1: #7E585C;  --ex3-color2: #714E52;
    --ex4-color1: #856A56;  --ex4-color2: #775F4C;
    --ex5-color1: #7E754A;  --ex5-color2: #716942;
    --ex6-color1: #65724C;  --ex6-color2: #5A6644;
    --ex7-color1: #4A6B56;  --ex7-color2: #42604C;
    --ex8-color1: #576278;  --ex8-color2: #4D576B;
    --ex9-color1: #725664;  --ex9-color2: #664C59;
    --ex10-color1: #856156; --ex10-color2: #77564C;
    --ex11-color1: #85704A; --ex11-color2: #776442;
    --ex12-color1: #727242; --ex12-color2: #66663B;
    --ex13-color1: #567250; --ex13-color2: #4C6647;
    --ex14-color1: #4A6B68; --ex14-color2: #42605D;
    --footer-color1: #A8C4D9;
    --footer-color2: #95B3C8;
}

* {
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(90deg, #4a5568 0%, #2d3748 100%);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img,
button {
    -webkit-touch-callout: none;
}

.main {
    position: relative;
}

/* Header */
.main .header {
    background-image: var(--main-header-bg-image);
    height: 40px;
    padding: 10px 0;
    color: white;
    font-size: 11pt;
    width: 100%;
    display: flex;
    justify-content: space-between;
    box-shadow: 0 2px 16px rgba(61, 90, 115, 0.25);
    position: relative;
    z-index: 10;
}

.main .header .left {
    padding-left: 32px;
    display: inline-block;
    align-self: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.main .header .left:active {
    transform: scale(0.95);
}

.main .header .left .level {
    white-space: nowrap;
    height: 18px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.main .header .left .key {
    white-space: nowrap;
    height: 20px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.main .header .center {
    margin: 0;
    padding: 0 16px;
    vertical-align: middle;
    min-width: 0;
    flex: 1;
    align-self: center;
}

.main .header .right {
    /* Same width as the heart and its gap on the left (10px + 34px),
       so the centered title stays in the middle of the screen */
    padding-left: 44px;
    padding-right: 32px;
    text-align: center;
    align-self: center;
    flex-shrink: 0;
    display: flex;
    gap: 20px;
}

/* Favorite heart, between the level/key block and the title */
.main .header .favorite {
    padding-left: 10px;
    align-self: center;
    flex-shrink: 0;
    display: flex;
}

.main .header .favorite input {
    width: 34px;
    height: 34px;
}

.main .header .favorite input,
.main .header .right input {
    outline: none;
    opacity: 0.9;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    cursor: pointer;
}

.main .header .favorite input:hover,
.main .header .right input:hover {
    opacity: 1;
}

.main .header .favorite input:active,
.main .header .right input:active {
    transform: scale(0.9);
}

.main .header .favorite input:disabled,
.main .header .right input:disabled {
    opacity: 0.5;
    cursor: default;
}

.main .header .center .title {
    padding: 0 8px;
    height: 22px;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.main .header .center .composer {
    padding: 0 8px;
    height: 18px;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 14px;
    opacity: 0.85;
    font-weight: 400;
}

/* Sheet Music */
.bg {
    position: relative;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
}

.spacer {
    height: calc((100vh - var(--music-height) - 120px) / 2);
    max-height: calc(var(--music-height) / 2);
    background: transparent;
}

.progress-background {
    background-color: var(--light-gray-color);
    margin: 0;
    padding: 0;
    width: 100%;
    height: 3px;
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 109;
}

.progress-bar {
    background-color: #045de9;
    background-image: linear-gradient(315deg, #045de9 0%, #09c6f9 74%);
    margin: 0;
    padding: 0;
    width: 0;
    height: 3px;
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 110;
}

.music {
    overflow-x: auto;
    overflow-y: hidden;
    height: var(--music-height);
    margin: 0 auto;
    background-color: transparent;
    position: relative;
    width: 90%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.music::-webkit-scrollbar {
    display: none;
}

#musicImg {
    position: relative;
    left: 0px;
    height: 100%;
    vertical-align: bottom;
}

.main svg {
    height: 100%;
    width: auto;
}

.main .play-button {
    outline: none;
    position: absolute;
    width: calc(var(--music-height) / 2.2);
    height: calc(var(--music-height) / 2.2);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    cursor: pointer;
    transition: transform var(--transition-fast), filter var(--transition-fast);
    filter: drop-shadow(0 4px 12px rgba(59, 139, 187, 0.35));
}

.main .play-button:hover {
    transform: translate(-50%, -50%) scale(1.05);
    filter: drop-shadow(0 6px 16px rgba(59, 139, 187, 0.4));
}

.main .play-button:active {
    transform: translate(-50%, -50%) scale(0.95);
}

.main .stop-button {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 101;
}

.main .stop-button-image {
    position: absolute;
    width: calc(var(--music-height) / 2.2);
    height: calc(var(--music-height) / 2.2);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    filter: drop-shadow(0 4px 12px rgba(59, 139, 187, 0.35));
    transition: transform var(--transition-fast);
}

.main .loading-image {
    position: absolute;
    width: 50px;
    height: 50px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 103;
}

.main .count-image {
    position: absolute;
    width: calc(var(--music-height) / 2);
    height: calc(var(--music-height) / 2);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
}

.main .tempo-label {
    position: absolute;
    top: calc(var(--music-height) / 6);
    left: calc(var(--music-height) / 6);
    font-family: "Times New Roman", "Noto Serif", serif;
    z-index: 102;
}

.main .tempo-label-image {
    height: calc(var(--music-height) / 8);
}

.main .tempo-label-text {
    font-size: calc(var(--music-height) / 8);
}

.marker {
    fill: var(--main-color);
    fill-opacity: 0.3;
}

.time-display {
    position: absolute;
    bottom: 20px;
    left: 8%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--dark-gray-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    z-index: 105;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.difficulty-display {
    position: absolute;
    bottom: 20px;
    left: 8%;
    transform: translateX(-50%);
    height: 32px;
    z-index: 105;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.song-info-button {
    position: absolute;
    bottom: 16px;
    right: 8%;
    transform: translateX(50%);
    height: 40px;
    padding: 4px;
    z-index: 200;
    cursor: pointer;
    pointer-events: auto;
    opacity: 0.7;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.song-info-button:hover {
    opacity: 1;
}

.song-info-button:active {
    transform: translateX(50%) scale(0.9);
}

/* Lower button: top right of the score, lined up with the tempo label and the info button */
.lower-button {
    position: absolute;
    top: calc(var(--music-height) / 6);
    right: 8%;
    transform: translateX(50%);
    height: 48px;
    padding: 4px;
    z-index: 200;
    cursor: pointer;
}

.lower-button:active {
    transform: translateX(50%) scale(0.9);
}

/* Control */
.control {
    background: linear-gradient(90deg, #4a5568 0%, #2d3748 100%);
    height: 30px;
    text-align: center;
    margin: 0;
    padding-top: 10px;
    padding-bottom: 20px;
    padding-left: 10px;
    padding-right: 10px;
    display: flex;
    justify-content: space-around;
}

.control input {
    outline: none;
}

/* Safari dims a disabled image button by itself; Chrome (Android) does not */
.control input:disabled {
    opacity: 0.5;
    cursor: default;
}
