:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;

    --tier-1: #ef4444;
    --tier-2: #f59e0b;
    --tier-3: #10b981;
    --tier-4: #3b82f6;

    --card-width: 80px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 1rem;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}


main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
}


.container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 1rem;
}


/* Compact UI */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
}

.btn-save {
    background: linear-gradient(to right, #ec4899, #8b5cf6);
    color: white;
}

.search-box-inline {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    max-width: 500px;
}

/* Tier List Styles */
.tier-list-container {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
}

.tier-row {
    display: flex;
    min-height: 90px;
    /* 縮小 */
    border-bottom: 1px solid var(--glass-border);
}

.tier-row:last-child {
    border-bottom: none;
}

.tier-label {
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    outline: none;
    cursor: text;
    text-align: center;
    word-break: break-all;
}

.tier-label:focus {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}


.tier-1 {
    background-color: var(--tier-1);
}

.tier-2 {
    background-color: var(--tier-2);
}

.tier-3 {
    background-color: var(--tier-3);
}

.tier-4 {
    background-color: var(--tier-4);
}

.tier-content {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    padding: 0.5rem;
    gap: 0.4rem;
    align-content: flex-start;
}

/* Search Section */
.search-section {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

input[type="text"] {
    flex: 1;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 0.4rem;
    padding: 0.5rem 0.75rem;
    color: white;
    outline: none;
}

button {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 0.4rem;
    padding: 0.5rem 1rem;
    font-weight: bold;
    cursor: pointer;
}

.search-results {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.5rem;
    overflow-y: auto;
    flex: 1;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 0.4rem;
}

/* Card Image Styles */
.card-container {
    position: relative;
    display: inline-block;
    width: var(--card-width);
    height: auto;
    cursor: grab;
    transition: transform 0.1s;
    user-select: none;
    -webkit-touch-callout: none;
}

.card-img {
    width: 100%;
    display: block;
    border-radius: 4px;
    pointer-events: none;
    /* コンテナがドラッグイベントをハンドルする */
}

.card-img.sub-card {
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 65%;
    z-index: 10;
    box-shadow: -2px -2px 5px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
}

.card-container.dragging {
    opacity: 0.5;
    z-index: 1000;
}

.card-container.mobile-dragging {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    transform: scale(1.1);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    width: var(--card-width);
}


/* Responsive */
@media (max-width: 640px) {
    .container {
        height: auto;
    }

    .tier-row {
        min-height: 70px;
    }

    .tier-label {
        width: 50px;
        font-size: 0.8rem;
    }

    :root {
        --card-width: 60px;
    }

    .top-bar {
        flex-direction: column;
        align-items: stretch;
    }
}

.usage-guide {
    background: rgba(15, 23, 42, 0.4);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--glass-border);
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.usage-guide h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.usage-guide ul {
    list-style: none;
    padding-left: 0;
}

.usage-guide li {
    margin-bottom: 0.4rem;
    line-height: 1.4;
}

.usage-guide strong {
    color: var(--accent-color);
}