/* CSS Variables for Premium Theme */
:root {
    --bg-color-1: #f0f8ff;
    --bg-color-2: #fff0f5;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(161, 140, 209, 0.3);
    --glass-highlight: rgba(255, 255, 255, 1);
    
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-accent: #ff758c;
    
    --btn-primary-bg: linear-gradient(135deg, #ff8bac 0%, #ffadd2 100%);
    --btn-secondary-bg: rgba(255, 255, 255, 0.9);
    --btn-danger-bg: linear-gradient(135deg, #ff758c 0%, #ff7eb3 100%);
    --btn-info-bg: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);

    --glow-shadow: 0 6px 20px rgba(255, 107, 129, 0.25);
    
    --font-main: 'Nunito', 'M PLUS Rounded 1c', 'Quicksand', 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-main);
    color: var(--text-primary);
    background-color: var(--bg-color-1);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background Animations */
.bg-gradient {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: radial-gradient(circle at 10% 20%, rgba(251, 194, 235, 0.4) 0%, transparent 50%),
                radial-gradient(circle at 90% 80%, rgba(161, 140, 209, 0.4) 0%, transparent 50%),
                linear-gradient(120deg, var(--bg-color-1) 0%, var(--bg-color-2) 100%);
    z-index: -2;
}

.glass-orb {
    position: fixed; border-radius: 50%; filter: blur(60px); z-index: -1; opacity: 0.7; animation: float 20s infinite ease-in-out alternate; mix-blend-mode: multiply;
}

.orb-1 { width: 350px; height: 350px; background: rgba(161, 140, 209, 0.5); top: 10%; left: 10%; }
.orb-2 { width: 450px; height: 450px; background: rgba(251, 194, 235, 0.5); bottom: -5%; right: 5%; animation-delay: -5s; }
.orb-3 { width: 300px; height: 300px; background: rgba(132, 250, 176, 0.4); top: 50%; left: 40%; animation-delay: -10s; }

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, -50px) scale(1.1); }
}

/* Layout */
.app-container {
    width: 100%;
    max-width: 800px;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.screen-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}
.screen-section.active {
    display: block;
}
.hidden { display: none !important; }

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

/* Glassmorphism Panel */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-top: 2px solid rgba(255,255,255,1);
    border-left: 2px solid rgba(255,255,255,1);
    border-radius: 32px;
    padding: 30px;
    padding-bottom: 45px;
    box-shadow: 0 15px 35px rgba(161, 140, 209, 0.15), inset 0 0 20px rgba(255,255,255,0.5);
    text-align: center;
    position: relative;
}

.glass-panel::after {
    content: "©だっちGAMES";
    position: absolute;
    bottom: 15px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.7;
    pointer-events: none;
    font-weight: 600;
}

/* Images */
.title-logo {
    max-width: 100%;
    height: auto;
    max-height: 280px;
    margin-bottom: 30px;
    filter: drop-shadow(0 5px 15px rgba(255, 139, 172, 0.4));
    animation: floatUpDown 4s ease-in-out infinite;
}

@keyframes floatUpDown {
    0% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
    100% { transform: translateY(0); }
}

/* Typography */
.neon-text {
    font-weight: 800;
    font-size: 2.5rem;
    background: linear-gradient(to right, #4facfe, #ff7eb3);
    -webkit-background-clip: text;
    color: transparent;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.05);
    letter-spacing: -1px;
}
.catchphrase { font-size: 1rem; color: var(--text-secondary); margin-bottom: 30px; }
.section-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 20px; }
.highlight-text { color: var(--text-accent); }
.text-glow { text-shadow: 0 0 15px rgba(255,255,255,0.5); }
.font-bold { font-weight: 700; }
.text-info { color: #2ed573; }
.text-danger { color: #ff4757; }

/* Utility Classes */
.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; }
.mt-30 { margin-top: 30px; }
.mb-15 { margin-bottom: 15px; }
.mb-20 { margin-bottom: 20px; }
.w-full { width: 100%; }
.flex-1 { flex: 1; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.uppercase { text-transform: uppercase; }

/* Inputs */
.input-section { margin-bottom: 20px; text-align: left; }
.input-label { display: block; font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 8px; font-weight: 600; }
.input-with-icon { display: flex; gap: 10px; align-items: center; }

.glass-input, .glass-select {
    width: 100%;
    background: rgba(255, 255, 255, 0.6);
    border: 2px solid var(--glass-border);
    color: var(--text-primary);
    padding: 12px 15px;
    border-radius: 12px;
    font-size: 1rem;
    font-family: var(--font-main);
    outline: none;
    transition: all 0.3s ease;
}
.glass-input:focus, .glass-select:focus {
    border-color: var(--text-accent);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}
.text-xl { font-size: 1.5rem; letter-spacing: 2px; }

/* Buttons */
.button-group-vertical { display: flex; flex-direction: column; gap: 15px; }
.button-group-bottom { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--glass-border); }

button {
    font-family: var(--font-main);
    cursor: pointer;
    border: none;
    border-radius: 20px;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    transition: all 0.2s ease;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.btn-primary { background: var(--btn-primary-bg); color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.3); font-size: 1.1rem; padding: 16px 24px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.btn-pulse { animation: pulseGlow 2s infinite; }
@keyframes pulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(255, 139, 172, 0.6); }
    70% { box-shadow: 0 0 0 20px rgba(255, 139, 172, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 139, 172, 0); }
}
.btn-secondary { background: var(--btn-secondary-bg); border: 2px solid var(--glass-border); color: var(--text-primary); }
.btn-secondary:hover { background: var(--glass-highlight); }
.btn-danger { background: var(--btn-danger-bg); color: #fff; }
.btn-info { background: var(--btn-info-bg); color: #fff; }
.btn-back { background: transparent; color: var(--text-secondary); padding: 10px; }
.btn-back:hover { color: var(--text-primary); }
.btn-icon-small { background: rgba(0,0,0,0.05); padding: 8px; border-radius: 50%; font-size: 1.2rem; color: var(--text-primary); }
.btn-icon-small:hover { background: rgba(0,0,0,0.1); }

.glow-effect:hover { box-shadow: var(--glow-shadow); }

.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    font-size: 1.5rem;
    padding: 10px 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.2); }

/* Mode Cards */
.mode-cards { display: flex; flex-direction: column; gap: 15px; }
.mode-card {
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid var(--glass-border);
    border-radius: 24px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    position: relative;
    overflow: hidden;
}
.mode-card:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.9);
    transform: translateY(-5px);
}
.mode-icon { font-size: 2rem; margin-bottom: 10px; }
.mode-card h3 { margin-bottom: 5px; font-size: 1.2rem; }
.mode-card p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.4; }

/* Lobby & Waiting Room */
.divider {
    display: flex; align-items: center; text-align: center; color: var(--text-secondary); margin: 15px 0;
}
.divider::before, .divider::after {
    content: ''; flex: 1; border-bottom: 1px solid var(--glass-border);
}
.divider span { padding: 0 10px; font-size: 0.9rem; }

.room-id-display {
    background: rgba(255, 255, 255, 0.5); padding: 10px 20px; border-radius: 16px; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; border: 2px solid var(--glass-border); transition: all 0.2s;
}
.room-id-display:hover { background: rgba(255, 255, 255, 0.8); border-color: var(--text-accent); }
.room-id-display .label { font-size: 0.8rem; color: var(--text-secondary); }
.room-id-display .id-text { font-size: 1.5rem; font-weight: 800; letter-spacing: 2px; color: var(--text-primary); }
.room-id-display .copy-icon { opacity: 0.5; }

.participants-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; border-bottom: 1px solid var(--glass-border); padding-bottom: 10px; }
.count-badge { background: rgba(255,255,255,0.1); padding: 4px 10px; border-radius: 20px; font-size: 0.9rem; }

.participant-grid {
    display: flex; flex-wrap: wrap; gap: 10px;
}
.participant-item {
    background: rgba(255,255,255,0.6); border-radius: 20px; padding: 10px 15px; display: flex; align-items: center; gap: 10px; border-left: 6px solid var(--p-color, #ccc); animation: fadeIn 0.3s ease; box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}
.p-icon { font-size: 1.5rem; }
.p-info { display: flex; flex-direction: column; align-items: flex-start; }
.p-name { font-size: 0.95rem; font-weight: 600; white-space: nowrap; }
.player-name-colored { 
    font-weight: 700; 
    color: var(--text-primary) !important;
    padding: 2px 8px;
    border-radius: 8px;
    display: inline-block;
}
.p-host-badge { font-size: 0.7rem; background: linear-gradient(135deg, #f1c40f, #e67e22); color: #fff; padding: 3px 8px; border-radius: 6px; margin-top: 4px; box-shadow: 0 2px 5px rgba(243, 156, 18, 0.3); font-weight: 800; }

/* Game Screen */
.stats-bar { display: flex; justify-content: space-between; margin-bottom: 15px; }
.stat-box { background: rgba(255,255,255,0.6); padding: 10px 20px; border-radius: 20px; border: 2px solid var(--glass-border); display: flex; flex-direction: column; align-items: center; box-shadow: 0 4px 10px rgba(0,0,0,0.03); }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); }
.stat-value { font-size: 1.5rem; font-weight: 800; }
.highlight-value { color: var(--text-accent); text-shadow: 0 0 10px rgba(0,240,255,0.4); }

.theme-card { background: rgba(255,255,255,0.7); padding: 20px; border-radius: 24px; border: 2px solid var(--glass-border); position: relative; box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.theme-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.theme-badge { background: linear-gradient(135deg, #9c88ff, #00f0ff); padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 700; color: #fff; }
.theme-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 20px; word-break: break-word; }

.theme-examples { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.example-box { background: rgba(255,255,255,0.5); padding: 10px 15px; border-radius: 12px; font-size: 0.9rem; display: flex; gap: 10px; }
.example-box.low { border-left: 3px solid #3498db; }
.example-box.high { border-left: 3px solid #e74c3c; }
.ex-label { color: var(--text-secondary); font-weight: 600; min-width: 50px; }

.hint-badge {
    background-color: #9c88ff;
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
    transition: all 0.2s;
    user-select: none;
    display: inline-block;
}
.hint-badge:hover {
    filter: brightness(1.1);
}
.hint-badge.active {
    background-color: #ff4757 !important;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255, 71, 87, 0.6);
}
.status-banner { padding: 12px; border-radius: 16px; background: rgba(255,255,255,0.7); border: 2px solid var(--glass-border); }
.prediction-msg { font-size: 0.9rem; margin-top: 5px; color: var(--text-accent); }

.board-wrapper { position: relative; }
.board-labels { display: flex; justify-content: space-between; margin-bottom: 10px; font-weight: 800; font-size: 1.2rem; }
.badge-low { color: #3498db; text-shadow: 0 0 10px rgba(52,152,219,0.5); }
.badge-high { color: #e74c3c; text-shadow: 0 0 10px rgba(231,76,60,0.5); }

.glass-board {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 2px;
    background: linear-gradient(to right, rgba(52, 152, 219, 0.5), rgba(241, 196, 15, 0.5), rgba(231, 76, 60, 0.5));
    padding: 15px 10px;
    border-radius: 24px;
    border: 2px solid var(--glass-border);
    width: 100%;
}

.board-btn {
    flex: 1;
    min-width: 0;
    padding: 0;
    height: 45px;
    border-radius: 12px;
    background: rgba(255,255,255,0.8);
    border: 2px solid rgba(161, 140, 209, 0.4);
    box-shadow: 0 3px 6px rgba(0,0,0,0.05);
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}
.board-btn:not(:disabled):hover { background: rgba(255,255,255,1); transform: scale(1.05); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.board-btn.selected { background: rgba(255, 107, 129, 0.2); border-color: #ff6b81; box-shadow: 0 0 10px rgba(255, 107, 129, 0.4); }
.board-btn.revealed { background: #fff; color: #000; font-weight: 900; animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); border: 3px solid rgba(161, 140, 209, 0.6); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.board-btn.zero { background: rgba(230,230,230,0.8); color: #888; border: none; }
.board-btn .pred-icon {
    position: absolute; top: -10px; right: -10px; font-size: 1rem; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5));
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    80% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.board-btn.selected-result {
    transform: scale(1.2) !important;
    z-index: 20;
    border-color: #2c3e50 !important;
    border-width: 4px !important;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 10px 25px rgba(0,0,0,0.3) !important;
    animation: selectedPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.board-btn.selected-result .pred-icon {
    top: -35px;
    right: 50%;
    transform: translateX(50%);
    font-size: 2rem;
    filter: drop-shadow(0 4px 4px rgba(0,0,0,0.4));
    animation: bouncePointer 1s infinite;
}

@keyframes selectedPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1.2); }
}

@keyframes bouncePointer {
    0%, 100% { transform: translate(50%, 0); }
    50% { transform: translate(50%, -10px); }
}

.board-btn.val-5 { background: #ffffff; border-color: #ff4757; color: #ff4757; box-shadow: 0 0 15px rgba(255, 71, 87, 0.6); font-size: 1.2rem; text-shadow: none; border-width: 3px; }
.board-btn.val-3 { background: #ffffff; border-color: #ffa502; color: #ffa502; box-shadow: 0 0 15px rgba(255, 165, 2, 0.6); font-size: 1.2rem; text-shadow: none; border-width: 3px; }
.board-btn.val-2 { background: #ffffff; border-color: #2ed573; color: #2ed573; box-shadow: 0 0 15px rgba(46, 213, 115, 0.6); font-size: 1.2rem; text-shadow: none; border-width: 3px; }
.board-btn.val-1 { background: #ffffff; border-color: #1e90ff; color: #1e90ff; box-shadow: 0 0 15px rgba(30, 144, 255, 0.6); font-size: 1.2rem; text-shadow: none; border-width: 3px; }

.countdown-text {
    font-size: 3rem;
    font-weight: 900;
    color: var(--text-accent);
    animation: pulseCountdown 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-block;
}

@keyframes pulseCountdown {
    0% { transform: scale(0.5); opacity: 0; }
    30% { transform: scale(1.2); opacity: 1; }
    70% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0; }
}

/* Versus Scoreboard */
.versus-scoreboard {
    display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--glass-border); justify-content: center;
}
.vs-score-item {
    background: rgba(255,255,255,0.8); padding: 5px 12px; border-radius: 20px; font-size: 0.8rem; display: flex; align-items: center; gap: 5px; border: 2px solid var(--p-color, transparent); box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.vs-score-item span.score { font-weight: 700; color: var(--text-primary); }

/* Result Screen */
.result-box { background: rgba(255,255,255,0.7); padding: 30px; border-radius: 24px; border: 2px solid var(--glass-border); box-shadow: 0 10px 30px rgba(0,0,0,0.05); }
.clear-badge { font-size: 2rem; font-weight: 900; color: #2ed573; text-shadow: 0 0 20px rgba(46,213,115,0.6); margin-bottom: 20px; animation: popIn 0.5s; }
.failed-badge { font-size: 2rem; font-weight: 900; color: #ff4757; text-shadow: 0 0 20px rgba(255,71,87,0.6); margin-bottom: 20px; animation: popIn 0.5s; }
.final-score { font-size: 4rem; font-weight: 900; color: #00f0ff; text-shadow: 0 0 30px rgba(0,240,255,0.5); line-height: 1; }

.ranking-grid { display: flex; flex-direction: column; gap: 10px; }
.rank-item {
    display: flex; align-items: center; background: rgba(255,255,255,0.6); padding: 12px 15px; border-radius: 16px; gap: 15px; box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}
.rank-pos { font-size: 1.5rem; font-weight: 900; width: 40px; text-align: center; }
.rank-pos.r-1 { color: gold; text-shadow: 0 0 10px rgba(255,215,0,0.5); }
.rank-pos.r-2 { color: silver; }
.rank-pos.r-3 { color: #cd7f32; }
.rank-info { flex: 1; text-align: left; display: flex; align-items: center; gap: 10px; }
.rank-score { font-size: 1.2rem; font-weight: 800; }

.history-section { text-align: left; }
.history-title { margin-bottom: 15px; font-size: 1.2rem; border-bottom: 1px solid var(--glass-border); padding-bottom: 5px; }
.history-list { display: flex; flex-direction: column; gap: 10px; max-height: 300px; overflow-y: auto; padding-right: 5px; }
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }
.history-item { background: rgba(255,255,255,0.6); padding: 12px; border-radius: 12px; border-left: 4px solid var(--text-accent); box-shadow: 0 2px 5px rgba(0,0,0,0.03); }
.h-theme { font-weight: 700; margin-bottom: 5px; }
.h-detail { font-size: 0.8rem; color: var(--text-secondary); display: flex; justify-content: space-between; }
.h-players { margin-top: 5px; font-size: 0.85rem; }

/* Modals */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(255,255,255,0.4); backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center; z-index: 100;
}
.modal-content { width: 90%; max-width: 400px; animation: popIn 0.3s ease; }
.icon-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.icon-item {
    font-size: 1.8rem; padding: 10px; cursor: pointer; border-radius: 16px; background: rgba(255,255,255,0.6); transition: all 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.icon-item:hover { background: rgba(255,255,255,1); transform: scale(1.1); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.icon-item.selected { background: rgba(255,107,129,0.2); border: 2px solid #ff6b81; }

.rules-modal-content { max-width: 500px; max-height: 80vh; display: flex; flex-direction: column; }
.rules-body { overflow-y: auto; flex: 1; padding-right: 10px; font-size: 0.95rem; line-height: 1.6; color: var(--text-primary); text-align: left; }
.rules-body h4 { color: var(--text-primary); margin-top: 15px; margin-bottom: 5px; border-left: 3px solid var(--text-accent); padding-left: 10px; }
.rules-body p { margin-bottom: 10px; }
.rules-body ul { margin-left: 20px; margin-bottom: 10px; }
.rules-body li { margin-bottom: 5px; }

/* Toasts */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; pointer-events: none; }
.toast { background: rgba(255,255,255,0.95); color: var(--text-primary); padding: 12px 20px; border-radius: 12px; border-left: 4px solid var(--text-accent); box-shadow: 0 5px 20px rgba(0,0,0,0.1); animation: slideIn 0.3s ease forwards, fadeOut 0.3s ease 2.7s forwards; }
.toast.error { border-left-color: #ff4757; }
.toast.success { border-left-color: #2ed573; }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* Responsiveness */
@media (max-width: 480px) {
    .glass-board { gap: 5px; padding: 10px; }
    .board-btn { font-size: 1rem; border-radius: 8px; }
    .theme-title { font-size: 1.4rem; }
    .neon-text { font-size: 2rem; }
}
