#tooltip {
    position: fixed;
    left: 0;
    top: 0;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #555;
    padding: 8px;
    color: #fff;
    font-size: 10px;
    pointer-events: none;
    z-index: 1000;
    white-space: pre-line;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    max-width: 200px;
    transform: translate3d(0, 0, 0);
    will-change: transform;
    contain: layout paint;
}

body.perf-firefox #tooltip {
    box-shadow: none;
}

.tooltip-title {
    color: #ffd700;
    font-weight: bold;
    margin-bottom: 4px;
    border-bottom: 1px solid #333;
    padding-bottom: 2px;
    display: block;
}

.tooltip-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tooltip-icon img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.tooltip-desc {
    color: #ccc;
}

.tooltip-hint {
    color: #777;
    font-style: italic;
    margin-top: 4px;
    display: block;
}

#game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.recap-title {
    margin-top: 10px;
    font-size: 11px;
    color: #bbb;
}

.recap-list {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 10px;
    color: #ddd;
    text-align: left;
}

.recap-line {
    display: flex;
    gap: 6px;
    align-items: baseline;
}

.recap-tag {
    font-size: 9px;
    color: #888;
    border: 1px solid #333;
    padding: 1px 4px;
    border-radius: 4px;
    min-width: 36px;
    text-align: center;
}

#item-toast {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 9;
    animation: toast-fade 1s ease-out forwards;
}

#levelup-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(5, 8, 12, 0.8);
    z-index: 12;
    backdrop-filter: blur(2px);
}

#class-selection-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 8, 12, 0.95);
    z-index: 15;
    backdrop-filter: blur(4px);
}

.class-selection-card {
    background: radial-gradient(circle, rgba(20, 24, 32, 0.98) 0%, rgba(10, 12, 18, 0.98) 70%);
    border: 2px solid var(--ui-accent);
    box-shadow: 0 0 24px var(--ui-glow);
    padding: 24px;
    border-radius: 10px;
    width: min(460px, 90%);
    text-align: center;
}

.class-selection-title {
    font-size: 16px;
    letter-spacing: 3px;
    color: var(--ui-accent);
    margin-bottom: 8px;
}

.class-selection-subtitle {
    font-size: 11px;
    color: #aaa;
    margin-bottom: 20px;
}

.class-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.class-option {
    background: #1b1f27;
    border: 2px solid #333a46;
    padding: 14px;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
    color: #fff;
    transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.class-option:hover {
    transform: translateY(-3px);
    border-color: var(--ui-accent);
    box-shadow: 0 0 16px var(--ui-glow);
}

.class-option-emoji {
    font-size: 48px;
    line-height: 1;
}

.class-option-name {
    font-size: 14px;
    color: var(--ui-accent);
    letter-spacing: 1px;
}

.class-option-desc {
    font-size: 10px;
    color: #bbb;
    line-height: 1.4;
}

.class-option-stats {
    font-size: 9px;
    color: #888;
    margin-top: 6px;
    line-height: 1.5;
}

.levelup-card {
    background: radial-gradient(circle, rgba(20, 24, 32, 0.98) 0%, rgba(10, 12, 18, 0.98) 70%);
    border: 2px solid var(--ui-accent);
    box-shadow: 0 0 24px var(--ui-glow);
    padding: 18px;
    border-radius: 10px;
    width: min(360px, 90%);
    text-align: center;
}

.levelup-title {
    font-size: 14px;
    letter-spacing: 2px;
    color: var(--ui-accent);
    margin-bottom: 6px;
}

.levelup-subtitle {
    font-size: 10px;
    color: #aaa;
    margin-bottom: 14px;
}

#levelup-options {
    display: grid;
    gap: 10px;
}

.levelup-option {
    background: #1b1f27;
    border: 1px solid #333a46;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: #fff;
    transition: transform 0.08s ease, box-shadow 0.12s ease, border-color 0.12s ease;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.levelup-option-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.levelup-option-icon img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.levelup-option-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.levelup-option:hover {
    transform: translateY(-2px);
    border-color: var(--ui-accent);
    box-shadow: 0 0 12px var(--ui-glow);
}

.levelup-option-title {
    font-size: 12px;
    margin-bottom: 4px;
}

.levelup-option-desc {
    font-size: 10px;
    color: #bbb;
    line-height: 1.4;
}

.item-card {
    background: radial-gradient(circle, #222 0%, #111 70%);
    border: 2px solid var(--ui-accent);
    box-shadow: 0 0 20px var(--ui-glow);
    padding: 16px 20px;
    border-radius: 8px;
    text-align: center;
    transform: scale(0.9);
    animation: pop 0.2s ease-out forwards;
}

#item-emoji {
    font-size: 32px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#item-emoji img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

#item-text {
    font-size: 12px;
    color: #fffbe6;
    letter-spacing: 1px;
}

@keyframes pop {
    0% { transform: scale(0.6); }
    100% { transform: scale(1); }
}

@keyframes toast-fade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

#legend-panel {
    position: fixed;
    right: 10px;
    bottom: 70px;
    width: 220px;
    max-height: 240px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #444;
    border-radius: 6px;
    color: #fff;
    font-size: 10px;
    display: none;
    z-index: 11;
}

.legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    border-bottom: 1px solid #333;
}

#legend-list {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-item {
    display: flex;
    gap: 8px;
    align-items: center;
}

.legend-item .icon {
    font-size: 24px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.legend-item .icon img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.legend-item .meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#shop-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    background: rgba(10, 10, 15, 0.95);
    border: 2px solid var(--ui-accent);
    border-radius: 8px;
    padding: 10px;
    z-index: 20;
    display: none;
    box-shadow: 0 0 20px var(--ui-glow);
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
    color: var(--ui-accent);
}

.shop-sell-panel {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #333;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.shop-sell-title {
    font-size: 10px;
    letter-spacing: 1px;
    color: #bbb;
}

.shop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #333;
}

.shop-item-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.shop-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shop-item-icon img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.shop-item-price {
    color: #ffd700;
    font-size: 10px;
}

.shop-item:last-child {
    border-bottom: none;
}

.shop-item button {
    background: #333;
    color: #ffd700;
    border: 1px solid #555;
    padding: 4px 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 10px;
}

.shop-item button:hover {
    background: #444;
    border-color: #ffd700;
}

.shop-item button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
