﻿:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #ec4899;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-color: #8b5cf6;
    --error-color: #ef4444;
    --success-color: #22c55e;
    --border-color: #e2e8f0;
    --bg-secondary: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-lg: 1rem;
    --radius-full: 9999px;
}

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

.hidden {
    display: none !important;
}

body {
    font-family: 'M PLUS Rounded 1c', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.app-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-template-rows: auto 1fr;
    width: 100%;
    max-width: 1200px;
    height: 90vh;
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.app-container.guest-only {
    grid-template-columns: 1fr;
}

/* Header */
.game-header {
    grid-column: 1 / -1;
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.game-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.score-display {
    font-size: 1.25rem;
    font-weight: 700;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    backdrop-filter: blur(4px);
}

/* Game Area */
.game-area {
    grid-column: 1 / 2;
    display: flex;
    flex-direction: column;
    background-color: #f1f5f9;
    position: relative;
    min-height: 0;
}

.message-log {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
    min-height: 0;
}

.message {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    max-width: 80%;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.cpu-message {
    align-self: flex-start;
}

.message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--secondary-color);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 0.875rem;
    box-shadow: var(--shadow-sm);
}

.user-message .avatar {
    background-color: var(--primary-color);
}

.bubble {
    padding: 1rem 1.25rem;
    background-color: white;
    border-radius: 1.25rem;
    border-bottom-left-radius: 0.25rem;
    box-shadow: var(--shadow-sm);
    font-size: 1rem;
    line-height: 1.4;
    position: relative;
}

.user-message .bubble {
    background-color: var(--primary-color);
    color: white;
    border-radius: 1.25rem;
    border-bottom-right-radius: 0.25rem;
}

/* Input Area */
.input-area {
    padding: 1.5rem 2rem;
    background-color: var(--surface-color);
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    gap: 1rem;
    position: relative;
}

#user-input {
    flex: 1;
    padding: 1rem 1.5rem;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
    outline: none;
}

#user-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#send-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    box-shadow: var(--shadow-md);
}

#send-btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

#send-btn:active {
    transform: translateY(0);
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.secondary-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background-color: transparent;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.15s;
}

.secondary-btn:hover {
    background-color: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.error-message {
    color: var(--error-color);
    font-size: 0.875rem;
    font-weight: 500;
    flex: 1;
}

.error-message.shake {
    animation: shake 0.4s;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

/* Ranking Sidebar */
.ranking-sidebar {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    background-color: var(--surface-color);
    border-left: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ranking-header {
    margin-bottom: 1.5rem;
}

.ranking-header h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.ranking-tabs {
    display: flex;
    gap: 0.5rem;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-full);
    padding: 0.25rem;
}

.tab-btn {
    flex: 1;
    padding: 0.5rem;
    border: none;
    background-color: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background-color: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.ranking-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: var(--bg-secondary);
    border-radius: 0.75rem;
    transition: transform 0.2s;
}

.ranking-item:hover {
    transform: translateX(2px);
}

.rank {
    font-weight: 700;
    font-size: 1rem;
    width: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.ranking-item.rank-1 .rank {
    color: #fbbf24;
}

.ranking-item.rank-2 .rank {
    color: #94a3b8;
}

.ranking-item.rank-3 .rank {
    color: #cd7f32;
}

.rank-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.score {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 0.875rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.2s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90%;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.2s;
}

.modal:not(.hidden) .modal-content {
    transform: scale(1);
}

.modal h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.modal p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.final-score {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 1.5rem 0;
}

#restart-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    background-color: var(--primary-color);
    color: white;
    border: none;

    @keyframes shake {

        0%,
        100% {
            transform: translateX(0);
        }

        25% {
            transform: translateX(-5px);
        }

        75% {
            transform: translateX(5px);
        }
    }

    /* Ranking Sidebar */
    .ranking-sidebar {
        grid-column: 2 / 3;
        grid-row: 2 / 3;
        background-color: var(--surface-color);
        border-left: 1px solid var(--border-color);
        padding: 1.5rem;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .ranking-header {
        margin-bottom: 1.5rem;
    }

    .ranking-header h3 {
        font-size: 1.125rem;
        margin-bottom: 1rem;
        color: var(--text-primary);
    }

    .ranking-tabs {
        display: flex;
        gap: 0.5rem;
        background-color: var(--bg-secondary);
        border-radius: var(--radius-full);
        padding: 0.25rem;
    }

    .tab-btn {
        flex: 1;
        padding: 0.5rem;
        border: none;
        background-color: transparent;
        color: var(--text-secondary);
        font-size: 0.875rem;
        font-weight: 500;
        border-radius: var(--radius-full);
        cursor: pointer;
        transition: all 0.2s;
    }

    .tab-btn.active {
        background-color: white;
        color: var(--primary-color);
        box-shadow: var(--shadow-sm);
    }

    .ranking-list {
        list-style: none;
        overflow-y: auto;
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .ranking-item {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem;
        background-color: var(--bg-secondary);
        border-radius: 0.75rem;
        transition: transform 0.2s;
    }

    .ranking-item:hover {
        transform: translateX(2px);
    }

    .rank {
        font-weight: 700;
        font-size: 1rem;
        width: 2rem;
        text-align: center;
        color: var(--text-secondary);
    }

    .ranking-item.rank-1 .rank {
        color: #fbbf24;
    }

    .ranking-item.rank-2 .rank {
        color: #94a3b8;
    }

    .ranking-item.rank-3 .rank {
        color: #cd7f32;
    }

    .rank-info {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .name {
        font-weight: 600;
        color: var(--text-primary);
        font-size: 0.875rem;
    }

    .date {
        font-size: 0.75rem;
        color: var(--text-secondary);
    }

    .score {
        font-weight: 700;
        color: var(--primary-color);
        font-size: 0.875rem;
    }

    /* Modal */
    .modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(15, 23, 42, 0.7);
        backdrop-filter: blur(4px);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 100;
        transition: opacity 0.2s;
    }

    .modal.hidden {
        opacity: 0;
        pointer-events: none;
    }

    .modal-content {
        background-color: white;
        padding: 2rem;
        border-radius: 1rem;
        box-shadow: var(--shadow-lg);
        max-width: 400px;
        width: 90%;
        text-align: center;
        transform: scale(0.9);
        transition: transform 0.2s;
    }

    .modal:not(.hidden) .modal-content {
        transform: scale(1);
    }

    .modal h2 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
        color: var(--text-primary);
    }

    .modal p {
        margin-bottom: 1.5rem;
        color: var(--text-secondary);
    }

    .final-score {
        font-size: 2rem;
        font-weight: 700;
        color: var(--primary-color);
        margin: 1.5rem 0;
    }

    #restart-btn {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        font-weight: 600;
        background-color: var(--primary-color);
        color: white;
        border: none;
        border-radius: var(--radius-full);
        cursor: pointer;
        transition: all 0.2s;
    }

    #restart-btn:hover {
        background-color: var(--primary-dark);
        transform: translateY(-1px);
    }


    #start-login-btn,
    #start-register-btn {
        transition: all 0.2s ease;
        cursor: pointer;
        border-radius: 0.5rem;
        font-weight: bold;
    }

    #start-login-btn {
        background: white;
        border: 1px solid var(--border-color);
        color: var(--text-primary);
    }

    color: var(--text-primary);
}

.ranking-tabs {
    display: flex;
    gap: 0.5rem;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-full);
    padding: 0.25rem;
}

.tab-btn {
    flex: 1;
    padding: 0.5rem;
    border: none;
    background-color: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background-color: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.ranking-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: var(--bg-secondary);
    border-radius: 0.75rem;
    transition: transform 0.2s;
}

.ranking-item:hover {
    transform: translateX(2px);
}

.rank {
    font-weight: 700;
    font-size: 1rem;
    width: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.ranking-item.rank-1 .rank {
    color: #fbbf24;
}

.ranking-item.rank-2 .rank {
    color: #94a3b8;
}

.ranking-item.rank-3 .rank {
    color: #cd7f32;
}

.rank-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.score {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 0.875rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.2s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90%;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.2s;
}

.modal:not(.hidden) .modal-content {
    transform: scale(1);
}

.modal h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.modal p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.final-score {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 1.5rem 0;
}

#restart-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s;
}

#restart-btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

/* Start Screen Styles */
.start-mode-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: 0.75rem;
}

.start-mode-btn {
    padding: 0.8rem 0.5rem;
    font-size: 1rem;
    transition: all 0.2s ease;
    border: 2px solid var(--border-color);
}

.start-mode-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    background-color: var(--bg-secondary);
    transform: translateY(-2px);
}

.start-mode-btn span {
    display: block;
    margin-top: 0.3rem;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: normal;
}

#start-error {
    margin: 0;
    color: var(--error-color);
}

#start-login-btn,
#start-register-btn {
    transition: all 0.2s ease;
    cursor: pointer;
    border-radius: 0.5rem;
    font-weight: bold;
}

#start-login-btn {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.mobile-ranking-control {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 0;
        height: 100%;
        overflow: hidden;
    }

    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
        box-shadow: none;
    }

    .ranking-sidebar {
        display: none;
    }

    .mobile-ranking-control {
        display: inline-block;
    }

    .ranking-sidebar.ranking-open {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 10000;
        overflow-y: auto;
        padding: 1.5rem;
    }

    #close-ranking-btn {
        margin-bottom: 1rem;
    }

    .game-header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .game-header h1 {
        font-size: 1.2rem;
        margin: 0;
    }

    .game-header>div {
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .score-display {
        font-size: 1rem;
        padding: 0.25rem 0.75rem;
    }

    .game-area {
        height: 100%;
        overflow: hidden;
    }

    .message-log {
        padding: 1rem;
    }

    .input-area {
        padding: 0.75rem;
    }

    .input-wrapper input {
        font-size: 16px;
        /* Prevent iOS zoom */
    }

    /* Adjust modal for mobile */
    .modal-content {
        width: 90%;
        max-height: 90vh;
        overflow-y: auto;
        padding: 1.5rem;
    }
}
.turn-prompt {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

#turn-timer {
    font-variant-numeric: tabular-nums;
}

.game-credit {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: #475569;
}
