* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

body {
    background: #0a0a0f;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #fff;
}

#game-wrapper {
    display: flex;
    flex-direction: column;
    position: relative;
}

#game-container {
    position: relative;
    border: 2px solid #333;
    border-radius: 4px;
    overflow: hidden;
}

#game-canvas {
    display: block;
    background: #1a1a2e;
}

#ui-overlay {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    margin-bottom: 8px;
    background: rgba(30, 30, 50, 0.9);
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 16px;
    position: relative;
}

#stats-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

#lives {
    font-size: 20px;
    letter-spacing: 2px;
    min-width: 115px;
}

#level {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 20px;
    font-weight: bold;
}

#score-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#score {
    color: #FFD700;
    font-weight: bold;
}

#score-value {
    display: inline-block;
    transition: transform 0.1s ease-out;
}

#high-score {
    font-size: 9px;
    color: #888;
}

#buttons-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

#sound-button,
#back-button {
    background: rgba(60, 60, 80, 0.8);
    border: 1px solid #555;
    border-radius: 4px;
    color: #fff;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

#sound-button:hover,
#back-button:hover,
#editor-link:hover {
    background: rgba(80, 80, 110, 0.9);
}

#sound-button {
    margin-right: 8px;
}

#editor-link {
    position: absolute;
    top: 70px;
    right: 30px;
    background: rgba(60, 80, 60, 0.8);
    border: 1px solid #585;
    border-radius: 4px;
    color: #8f8;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    z-index: 100;
}

#message-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
}

#message-overlay.hidden {
    display: none;
}

#message-text {
    font-size: 48px;
    font-weight: bold;
    margin-bottom: 20px;
}

#message-sub {
    font-size: 18px;
    color: #aaa;
}

#level-select-scroll {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: scroll;
    overflow-x: hidden;
    pointer-events: auto;
}

#level-select-scroll.hidden {
    display: none;
}

#level-select-spacer {
    pointer-events: none;
}

/* 3D Medal Animation */
#medal-container {
    position: absolute;
    top: 420px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    pointer-events: none;
    perspective: 1000px;
    z-index: 50;
}

#medal-container.hidden {
    display: none;
}

#medal-container.fade-out {
    animation: medalFadeOut 0.75s ease-in forwards;
}

@keyframes medalFadeOut {
    to { opacity: 0; }
}

#medal-3d {
    width: 120px;
    height: 120px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateY(-60deg);
    animation: medalSpin 6.5s linear forwards;
}

@keyframes medalSpin {
    from { transform: rotateY(-60deg); }
    to { transform: rotateY(480deg); }
}

.medal-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#medal-front {
    background: radial-gradient(ellipse at 30% 30%, #FFEC8B 0%, #FFD700 40%, #B8860B 100%);
    border: 3px solid #B8860B;
    transform: translateZ(6px);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.2), inset 0 -5px 15px rgba(0,0,0,0.15);
}

#medal-back {
    background: radial-gradient(ellipse at 70% 70%, #B8860B 0%, #9A7B0A 40%, #7A6208 100%);
    border: 3px solid #7A6208;
    transform: rotateY(180deg) translateZ(6px);
}

#medal-number {
    font-size: 48px;
    font-weight: bold;
    color: #654a00;
    text-shadow: 1px 1px 0px rgba(255,255,255,0.4), -1px -1px 0px rgba(0,0,0,0.2);
}

/* Solid base for coin edge */
.medal-edge-base {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(to bottom, #C9A227 0%, #8B6914 50%, #C9A227 100%);
}

/* Coin edge ridges - 3D vertical bars on top of base */
.medal-edge-ridge {
    position: absolute;
    width: 2px;
    height: 12px;
    top: 50%;
    left: 50%;
    margin-top: -6px;
    margin-left: -1px;
    background: linear-gradient(to right, #654a00 0%, #FFD700 50%, #654a00 100%);
}

/* Medal color variations - Silver */
#medal-container.silver #medal-front {
    background: radial-gradient(ellipse at 30% 30%, #ffffff 0%, #C0C0C0 40%, #808080 100%);
    border-color: #707070;
}
#medal-container.silver #medal-back {
    background: radial-gradient(ellipse at 70% 70%, #909090 0%, #707070 40%, #505050 100%);
    border-color: #505050;
}
#medal-container.silver #medal-number {
    color: #404040;
}
#medal-container.silver .medal-edge-base {
    background: linear-gradient(to bottom, #A0A0A0 0%, #606060 50%, #A0A0A0 100%);
}
#medal-container.silver .medal-edge-ridge {
    background: linear-gradient(to right, #404040 0%, #D0D0D0 50%, #404040 100%);
}

/* Medal color variations - Bronze */
#medal-container.bronze #medal-front {
    background: radial-gradient(ellipse at 30% 30%, #DEB887 0%, #CD7F32 40%, #8B4513 100%);
    border-color: #6B3510;
}
#medal-container.bronze #medal-back {
    background: radial-gradient(ellipse at 70% 70%, #8B4513 0%, #6B3510 40%, #4B250D 100%);
    border-color: #4B250D;
}
#medal-container.bronze #medal-number {
    color: #3B1A08;
}
#medal-container.bronze .medal-edge-base {
    background: linear-gradient(to bottom, #B87333 0%, #6B3510 50%, #B87333 100%);
}
#medal-container.bronze .medal-edge-ridge {
    background: linear-gradient(to right, #3B1A08 0%, #CD7F32 50%, #3B1A08 100%);
}

#highscore-dialog {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 80px;
    background: rgba(0, 0, 0, 0.6);
    z-index: 40;
}

#highscore-dialog.hidden {
    display: none;
}

#highscore-dialog-content {
    background: linear-gradient(135deg, #1a2a4a 0%, #0a1a2e 100%);
    border: 2px solid #4a6a9f;
    border-radius: 12px;
    padding: 30px 40px;
    text-align: center;
    box-shadow: 0 0 30px rgba(74, 106, 159, 0.4);
}

#highscore-title {
    font-size: 28px;
    font-weight: bold;
    color: #FFD700;
    margin-bottom: 10px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

#highscore-score {
    font-size: 42px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 10px;
}

#highscore-info {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 15px;
    min-height: 20px;
}

#highscore-info.beat {
    color: #4ade80;
}

#highscore-info.not-beat {
    color: #f87171;
}

#highscore-name-input {
    width: 200px;
    padding: 10px 15px;
    font-size: 16px;
    border: 2px solid #4a6a9f;
    border-radius: 6px;
    background: rgba(20, 30, 50, 0.9);
    color: #fff;
    text-align: center;
    outline: none;
    margin-bottom: 15px;
}

#highscore-name-input:focus {
    border-color: #6a9aff;
    box-shadow: 0 0 10px rgba(106, 154, 255, 0.3);
}

#highscore-name-input::placeholder {
    color: #666;
}

#highscore-submit {
    display: block;
    width: 100%;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    background: linear-gradient(135deg, #4a6a9f 0%, #2a4a7a 100%);
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

#highscore-submit:hover {
    background: linear-gradient(135deg, #5a7aaf 0%, #3a5a8a 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(74, 106, 159, 0.4);
}

/* Game help bar */
#game-help {
    display: flex;
    gap: 20px;
    justify-content: center;
    padding: 8px 15px;
    margin-top: 8px;
    font-size: 11px;
    color: #666;
}

#game-help kbd {
    background: rgba(80, 80, 100, 0.5);
    border: 1px solid #555;
    border-radius: 3px;
    padding: 1px 5px;
    font-family: monospace;
    font-size: 10px;
    color: #aaa;
}
