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

body {
    font-family: 'Noto Serif JP', serif;
    background: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
}

#app-header {
    background: linear-gradient(180deg, #16213e 0%, #111a30 100%);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 3px solid;
    border-image: linear-gradient(90deg, #e94560, #ff6b81, #e94560) 1;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* Title: 盤戦 -BANSEN- battle-hardened look */
#app-header h1 {
    white-space: nowrap;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.title-kanji {
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: 4px;
    background: linear-gradient(180deg, #ff4d6d 0%, #e94560 40%, #c9303e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 8px rgba(233,69,96,0.4)) drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    text-shadow: none;
}

.title-sub {
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 3px;
    color: #888;
    text-transform: uppercase;
}

#nav-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.nav-btn {
    background: transparent;
    color: #a0a0b0;
    border: 1px solid #333;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.nav-btn:hover {
    color: #fff;
    border-color: #e94560;
}

.nav-btn.active {
    color: #fff;
    background: #e94560;
    border-color: #e94560;
}

#user-info {
    color: #ccc;
    font-size: 0.85rem;
    margin-left: 8px;
}

#rating-display {
    color: #e94560;
    font-weight: bold;
    margin-left: 4px;
}

/* Pages */
.page {
    display: none;
    padding: 16px;
}

.page.active {
    display: block;
}

.page h2 {
    color: #e94560;
    margin-bottom: 12px;
}

/* Dialog overlay */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.dialog {
    background: #16213e;
    border: 2px solid #e94560;
    border-radius: 8px;
    padding: 24px 32px;
    text-align: center;
}

.dialog p {
    font-size: 1.2rem;
    margin-bottom: 16px;
}

.dialog button {
    font-family: inherit;
    font-size: 1rem;
    padding: 8px 24px;
    margin: 0 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

#btn-promote {
    background: #e94560;
    color: #fff;
}

#btn-promote:hover {
    background: #c73650;
}

#btn-no-promote {
    background: #444;
    color: #fff;
}

#btn-no-promote:hover {
    background: #666;
}

/* Auth tabs */
.auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.auth-tab {
    flex: 1;
    padding: 8px;
    background: #2a2a4a;
    color: #888;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
}

.auth-tab.active {
    background: #e94560;
    color: #fff;
    border-color: #e94560;
}

/* Game controls */
.game-controls {
    width: var(--board-size, min(80vw, 450px));
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 8px;
}

.control-btn {
    font-family: inherit;
    font-size: 0.85rem;
    padding: 8px 16px;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    background: #2a2a4a;
    color: #ccc;
    transition: all 0.2s;
}

.control-btn:hover {
    border-color: #888;
    color: #fff;
}

.resign-btn {
    background: #8b0000;
    border-color: #a00;
    color: #fff;
}

.resign-btn:hover {
    background: #a00;
}

.premium-btn {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border-color: #FFD700;
    color: #FFD700;
}

.premium-btn:hover {
    background: linear-gradient(135deg, #16213e, #1a1a2e);
}

/* Chat panel */
.chat-panel {
    width: var(--board-size, min(80vw, 450px));
    background: #2a2a4a;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 180px;
}

.chat-header {
    font-size: 0.8rem;
    color: #888;
    padding: 4px 10px;
    border-bottom: 1px solid #3a3a5a;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px;
    font-size: 0.85rem;
    min-height: 60px;
}

.chat-msg {
    margin-bottom: 4px;
    word-break: break-word;
}

.chat-msg .sender {
    font-weight: bold;
    margin-right: 4px;
}

.chat-msg.system {
    color: #888;
    font-style: italic;
}

.chat-input-area {
    display: flex;
    border-top: 1px solid #3a3a5a;
}

.chat-input-area input {
    flex: 1;
    padding: 6px 10px;
    background: #1a1a2e;
    color: #fff;
    border: none;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
}

.chat-input-area button {
    padding: 6px 12px;
    background: #e94560;
    color: #fff;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
}

.chat-input-area button:hover {
    background: #c73650;
}

/* Ad placeholders */
.ad-banner {
    width: 100%;
    max-width: 600px;
    margin: 8px auto;
}

.ad-sidebar {
    width: 160px;
    min-height: 300px;
}

.ad-placeholder {
    background: #2a2a4a;
    border: 1px dashed #444;
    border-radius: 4px;
    padding: 16px;
    text-align: center;
    color: #555;
    font-size: 0.8rem;
}

/* Premium badge */
.premium-badge {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: 4px;
    font-weight: bold;
}

/* Responsive */
@media (max-width: 600px) {
    #app-header {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }

    #nav-bar {
        justify-content: center;
        flex-wrap: wrap;
        gap: 4px;
        width: 100%;
    }

    .nav-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
        min-height: 36px;
    }

    /* Tap target size for mobile */
    button {
        min-height: 36px;
    }

    /* Dialog: bigger on mobile */
    .dialog {
        min-width: 85vw !important;
        max-width: 95vw !important;
        margin: 10px;
    }
}

/* Very small phones (iPhone SE 375px) */
@media (max-width: 420px) {
    .nav-btn {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    h2 {
        font-size: 1.3rem !important;
    }

    h3 {
        font-size: 1rem !important;
    }
}

/* Profile modal */
#profile-modal {
    justify-content: center;
    align-items: center;
}

/* In-game badge */
.in-game-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #2a6a2a;
    color: #4ade80;
    border-radius: 12px;
    font-size: 0.75rem;
}

/* Research room member speaking indicator */
.research-member {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.research-member.speaking {
    color: #4ade80;
    text-shadow:
        0 0 6px rgba(74, 222, 128, 0.6),
        0 0 12px rgba(74, 222, 128, 0.3);
    animation: speaking-pulse 1.2s ease-in-out infinite;
}

@keyframes speaking-pulse {
    0%, 100% {
        text-shadow:
            0 0 6px rgba(74, 222, 128, 0.6),
            0 0 12px rgba(74, 222, 128, 0.3);
    }
    50% {
        text-shadow:
            0 0 10px rgba(74, 222, 128, 0.8),
            0 0 20px rgba(74, 222, 128, 0.5),
            0 0 30px rgba(74, 222, 128, 0.2);
    }
}
