:root {
    --bg-dark: #121418;
    --card-bg: #1e2126;
    --text-gold: #d4af37;
    --text-silver: #b0b0b0;
    --accent-blue: #2c3e50;
    --border-color: #2c2e33;
    --player-msg-bg: #22303f;
    --client-msg-bg: #2a2d33;
}

body {
    background-color: var(--bg-dark);
    color: #e0e0e0;
    font-family: "Sawarabi Mincho", "Georgia", serif;
    margin: 0;
    display: flex;
    height: 100vh;
    overflow: hidden;
    animation: fadeIn 1s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Sidebar */
#sidebar {
    width: 320px;
    background-color: #1a1c20;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

#sidebar header {
    padding: 30px 20px;
    background: linear-gradient(to bottom, #1a1c20, #121418);
    border-bottom: 1px solid var(--text-gold);
    animation: slideInDown 0.8s ease-out;
}

@keyframes slideInDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.case-item {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    opacity: 0;
    animation: slideInLeft 0.5s ease-out forwards;
}

/* 案件ごとに少し遅延させて表示 */
.case-item:nth-child(1) { animation-delay: 0.1s; }
.case-item:nth-child(2) { animation-delay: 0.2s; }
.case-item:nth-child(3) { animation-delay: 0.3s; }
.case-item:nth-child(4) { animation-delay: 0.4s; }

@keyframes slideInLeft {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.case-item:hover { 
    background: #25282e;
    padding-left: 25px;
}
.case-item.active { 
    background: var(--player-msg-bg); 
    border-right: 3px solid var(--text-gold); 
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}
.case-item.unread { border-left: 4px solid var(--text-gold); }

/* Main Content Area */
#main-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0f1114;
    position: relative;
}

/* Thread (Chat UI style) */
#thread-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    scroll-behavior: smooth;
}

.message-bubble {
    max-width: 80%;
    padding: 25px;
    border-radius: 4px;
    line-height: 1.8;
    position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.role-client {
    align-self: flex-start;
    background-color: var(--client-msg-bg);
    border-left: 2px solid var(--text-gold);
}

.role-player {
    align-self: flex-end;
    background-color: var(--player-msg-bg);
    border-right: 2px solid var(--text-gold);
    color: var(--text-gold);
}

/* Bottom Action Bar */
#action-bar {
    background: #1a1c20;
    border-top: 1px solid var(--border-color);
    padding: 20px 40px;
    animation: slideInUp 0.5s ease-out;
}

@keyframes slideInUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.reply-btn {
    background: transparent;
    border: 1px solid var(--text-gold);
    color: var(--text-gold);
    padding: 12px 30px;
    border-radius: 2px;
    cursor: pointer;
    font-family: inherit;
    transition: 0.3s;
    position: relative;
    overflow: hidden;
}

.reply-btn:hover {
    background: var(--text-gold);
    color: #000;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
}

/* Report Form */
#report-form {
    margin-top: 20px;
    background: #000;
    padding: 20px;
    border: 1px solid var(--text-gold);
}

/* Message Content Extensions */
.msg-body {
    word-break: break-all;
}

.attachment-area {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    padding-top: 15px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 15px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-gold);
    text-decoration: none;
    border: 1px solid transparent;
    transition: 0.2s;
}

.attachment-item:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: var(--text-gold);
}

.attachment-item::before {
    content: "📎";
    font-size: 1rem;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 10px 15px;
    background: var(--client-msg-bg);
    width: fit-content;
    border-radius: 4px;
    margin-bottom: 20px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-gold);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
}

textarea {
    width: 100%;
    background: transparent;
    color: #fff;
    border: none;
    border-bottom: 1px solid #333;
    padding: 10px;
    font-family: inherit;
    resize: none;
    margin-bottom: 20px;
}

textarea:focus {
    outline: none;
    border-bottom-color: var(--text-gold);
}

/* Ending Overlay Animation */
#ending-overlay {
    background: radial-gradient(circle, #1a1c20 0%, #000 100%) !important;
    backdrop-filter: blur(0px);
    transition: backdrop-filter 3s ease;
}

#ending-overlay.ending-active {
    display: flex !important;
    animation: overlayFade 3s ease-in-out forwards;
    backdrop-filter: blur(10px);
}

@keyframes overlayFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

#ending-overlay h1 {
    font-size: 2.5rem;
    letter-spacing: 15px;
    margin-bottom: 30px;
    opacity: 0;
    transform: translateY(20px);
    color: var(--text-gold);
}

#ending-overlay.ending-active h1 {
    animation: textRise 1.5s ease-out 1.5s forwards;
}

#ending-text {
    font-size: 1.1rem;
    line-height: 2.5;
    max-width: 600px;
    color: #ccc;
    opacity: 0;
    transform: translateY(20px);
}

#ending-overlay.ending-active #ending-text {
    animation: textRise 2s ease-out 3s forwards;
}

@keyframes textRise {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.ending-btn-container {
    margin-top: 50px;
    opacity: 0;
}

#ending-overlay.ending-active .ending-btn-container {
    animation: fadeIn 1s ease-out 5s forwards;
}
