:root {
    --primary: #FF6B9D;
    --primary-dark: #E85A8A;
    --secondary: #7C3AED;
    --accent: #22D3EE;
    --accent-yellow: #FBBF24;
    --success: #34D399;
    --bg: #FFF5F7;
    --bg-dark: #1E1B4B;
    --card-bg: #FFFFFF;
    --text: #1F2937;
    --text-muted: #6B7280;
    --shadow: rgba(124, 58, 237, 0.2);
    --radius: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Nunito', 'Baloo 2', sans-serif;
}

body {
    background: linear-gradient(135deg, #FFF5F7 0%, #EDE9FE 50%, #E0F2FE 100%);
    color: var(--text);
    overflow: hidden;
    min-height: 100vh;
}

.app-container {
    width: 100%;
    min-height: 100vh;
    position: relative;
}

/* 操作説明サイドバー - 常時表示 */
.controls-sidebar {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 4px 20px var(--shadow);
    border: 2px solid var(--accent);
}

.controls-title {
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--secondary);
    margin-bottom: 8px;
    text-align: center;
}

.controls-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-item {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.control-item .key {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.7rem;
    min-width: 70px;
    text-align: center;
}

/* 画面共通 */
.screen {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    padding: 2rem;
}

.screen.active {
    display: flex;
}

/* タイトル画面 */
.title-content {
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.main-title {
    font-family: 'Baloo 2', cursive;
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.title-sub {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
}

.title-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.btn-primary, .btn-secondary {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 280px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(255, 107, 157, 0.5);
}

.btn-secondary {
    background: white;
    color: var(--secondary);
    border: 3px solid var(--secondary);
}

.btn-secondary:hover {
    background: var(--secondary);
    color: white;
    transform: translateY(-2px);
}

/* オンライン設定画面 */
.setup-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 8px 32px var(--shadow);
    border: 2px solid var(--accent);
    max-width: 400px;
}

.screen-title {
    font-family: 'Baloo 2', cursive;
    font-size: 1.5rem;
    color: var(--secondary);
    margin-bottom: 1.5rem;
    text-align: center;
}

.setup-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.setup-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.setup-form input:focus {
    outline: none;
    border-color: var(--secondary);
}

.role-buttons {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.btn-role {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--accent);
    background: white;
    color: var(--secondary);
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-role:hover {
    background: var(--accent);
    color: white;
}

.setup-status {
    font-size: 0.9rem;
    color: var(--text-muted);
    min-height: 1.5em;
}

/* 職業選択アリーナ */
#screen-class-arena {
    flex-direction: row;
    gap: 1.5rem;
}

.arena-skill-panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1rem;
    min-width: 200px;
    max-width: 240px;
    box-shadow: 0 4px 20px var(--shadow);
    border: 2px solid var(--accent);
}

.arena-skill-title {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--secondary);
    margin-bottom: 0.75rem;
}

.arena-skill-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.arena-skill-card {
    background: rgba(255,255,255,0.8);
    border: 2px solid #E5E7EB;
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.arena-skill-card:hover {
    border-color: var(--accent);
    transform: scale(1.02);
}

.arena-skill-card .skill-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
}

.arena-skill-card .skill-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.arena-skill-card .skill-stats {
    font-size: 0.7rem;
    color: var(--secondary);
    margin-top: 4px;
}

.arena-skill-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

@media (max-width: 900px) {
    #screen-class-arena {
        flex-direction: column;
    }
    .arena-skill-panel {
        max-width: none;
    }
}

.arena-wrapper {
    position: relative;
    width: 900px;
    height: 600px;
    max-width: 95vw;
    max-height: 80vh;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 8px 40px var(--shadow);
}

#arena-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: linear-gradient(180deg, #CFFAFE 0%, #E9D5FF 100%);
}

.arena-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 16px 24px;
    background: linear-gradient(180deg, rgba(255,255,255,0.9) 0%, transparent 100%);
    pointer-events: none;
}

.arena-overlay *:not(.game-start-zone) {
    pointer-events: auto;
}

.arena-title {
    font-family: 'Baloo 2', cursive;
    font-size: 1.25rem;
    color: var(--secondary);
}

.arena-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.current-class {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 12px;
    background: var(--secondary);
    color: white;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
}

.game-start-zone {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--success), #10B981);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 700;
    box-shadow: 0 4px 20px rgba(52, 211, 153, 0.5);
    pointer-events: none;
}

.start-label {
    display: block;
    font-size: 0.9rem;
}

.players-count {
    font-size: 0.75rem;
    opacity: 0.9;
}

/* ゲーム画面 */
.game-wrapper {
    position: relative;
    width: 1100px;
    height: 700px;
    max-width: 95vw;
    max-height: 85vh;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 8px 40px var(--shadow);
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.hud {
    position: absolute;
    z-index: 10;
}

.top-left { top: 16px; left: 16px; }
.top-right { top: 16px; right: 16px; }
.bottom-center { bottom: 16px; left: 50%; transform: translateX(-50%); }

.player-hp-bar, .boss-hp-bar {
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 16px;
    border-radius: 12px;
    min-width: 200px;
    box-shadow: 0 4px 15px var(--shadow);
}

.hp-label {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--secondary);
    margin-bottom: 6px;
}

.bar-bg {
    background: #E5E7EB;
    height: 14px;
    border-radius: 7px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--success), #10B981);
    transition: width 0.3s ease;
}

.bar-fill.boss {
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
}

.hp-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.death-count {
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 600;
    margin-top: 2px;
}

.boss-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 6px;
}

.skill-bar {
    display: flex;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow);
}

.skill-slot {
    width: 56px;
    height: 56px;
    background: white;
    border: 2px solid var(--accent);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.skill-icon {
    font-size: 1.5rem;
}

.skill-key {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--secondary);
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
}

.skill-cooldown {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: rgba(0, 0, 0, 0.4);
    transition: height 0.1s linear;
    border-radius: 0 0 10px 10px;
}

.countdown-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
}

#countdown-number {
    font-family: 'Baloo 2', cursive;
    font-size: 120px;
    font-weight: 700;
    color: var(--accent-yellow);
    text-shadow: 0 0 30px rgba(251, 191, 36, 0.8);
}

.countdown-overlay.hidden {
    display: none !important;
}

/* オーバーレイ */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    justify-content: center;
    align-items: center;
}

.overlay.active {
    display: flex;
}

.overlay-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2.5rem;
    text-align: center;
    box-shadow: 0 8px 40px var(--shadow);
    border: 3px solid var(--primary);
}

.overlay-title {
    font-family: 'Baloo 2', cursive;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.overlay-title.clear {
    color: var(--success);
}

.overlay-title.gameover {
    color: var(--primary);
}

#overlay-message {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.game-button {
    font-weight: 700;
    background: linear-gradient(135deg, var(--secondary), #5B21B6);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.game-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow);
}

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