@charset "utf-8";

/* ============================================================
   CSS Variables
   ============================================================ */
:root {
    --primary: #6C5CE7;
    --primary-dark: #5A4BD1;
    --secondary: #00CEC9;
    --danger: #E21B3C;
    --success: #26890C;
    --warning: #D89E00;
    --bg: #F0F2F5;
    --card-bg: #FFFFFF;
    --text: #2D3436;
    --text-light: #636E72;
    --border: #DFE6E9;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --choice-red: #E21B3C;
    --choice-blue: #1368CE;
    --choice-yellow: #D89E00;
    --choice-green: #26890C;
    --choice-purple: #8B5CF6;
    --choice-orange: #FF6B35;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Container
   ============================================================ */
.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
}

/* ============================================================
   Landing Page
   ============================================================ */
.landing {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 40px;
    padding-top: 80px;
}

.logo-area {
    text-align: center;
}

.logo-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.logo-area h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
}

.subtitle {
    color: var(--text-light);
    margin-top: 8px;
    font-size: 15px;
}

.role-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 360px;
}

.role-buttons .btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    border-radius: var(--radius);
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow);
}

.role-buttons .btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.btn-label {
    font-size: 18px;
    font-weight: 700;
}

.btn-desc {
    font-size: 13px;
    opacity: 0.8;
    margin-top: 4px;
}

.btn-teacher {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-student {
    background: linear-gradient(135deg, var(--secondary), #00B4A6);
    color: white;
}

/* ============================================================
   Views (show/hide)
   ============================================================ */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* ============================================================
   Page Header
   ============================================================ */
.page-header {
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
}

.page-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.back-link {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

/* ============================================================
   Forms
   ============================================================ */
.form-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    transition: border-color 0.2s;
    outline: none;
    font-family: inherit;
}

.form-input:focus {
    border-color: var(--primary);
}

.form-input-sm {
    padding: 8px 10px;
    font-size: 14px;
}

select.form-input {
    appearance: auto;
}

textarea.form-input {
    resize: vertical;
    min-height: 60px;
}

.form-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}

.form-row .form-input {
    flex: 1;
}

.error-text {
    color: var(--danger);
    font-size: 14px;
    margin-top: 8px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.15s, box-shadow 0.15s;
    font-family: inherit;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--text-light);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px dashed var(--primary);
}

.btn-outline:hover {
    background: rgba(108, 92, 231, 0.05);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 17px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon-only {
    padding: 6px 10px;
    font-size: 18px;
    line-height: 1;
}

.action-bar {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-bottom: 32px;
}

/* ============================================================
   Question Builder (Teacher Create)
   ============================================================ */
.question-block {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.question-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.choice-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.choice-row .form-input {
    flex: 1;
}

.choice-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.correct-radio {
    flex-shrink: 0;
}

.correct-radio input[type="radio"] {
    display: none;
}

.correct-radio label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid var(--border);
    color: var(--text-light);
    transition: all 0.15s;
}

.correct-radio input[type="radio"]:checked + label {
    border-color: var(--success);
    background: rgba(38, 137, 12, 0.1);
    color: var(--success);
}

.time-limit-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 14px;
    color: var(--text-light);
}

.time-limit-row input {
    width: 70px;
    text-align: center;
}

/* ============================================================
   Student Count / Lobby
   ============================================================ */
.student-count-display {
    text-align: center;
    padding: 20px;
}

.count-number {
    font-size: 56px;
    font-weight: 800;
    color: var(--primary);
    display: block;
}

.count-label {
    font-size: 18px;
    color: var(--text-light);
}

.student-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    justify-content: center;
}

.student-tag {
    background: rgba(108, 92, 231, 0.1);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    animation: popIn 0.3s ease;
}

/* ============================================================
   Timer Bar
   ============================================================ */
.timer-bar-container {
    position: relative;
    height: 40px;
    background: var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    overflow: hidden;
}

.timer-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--warning), var(--danger));
    border-radius: var(--radius-sm);
    transition: width 1s linear;
    width: 100%;
}

.timer-text {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    font-weight: 800;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ============================================================
   Question Display
   ============================================================ */
.question-card {
    border-left: 4px solid var(--primary);
}

.question-text {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.5;
    margin-bottom: 16px;
}

.choices-display {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.choice-display-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    color: white;
}

/* ============================================================
   Answer Progress
   ============================================================ */
.answer-progress {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

.answer-count {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
}

.progress-bar-bg {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

/* ============================================================
   Choice Buttons (Student)
   ============================================================ */
.choice-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 12px;
}

.choice-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 17px;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s;
    text-align: left;
    box-shadow: var(--shadow);
    width: 100%;
    font-family: inherit;
}

.choice-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.choice-btn:active {
    transform: scale(0.97);
}

.choice-btn .choice-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    font-size: 18px;
    font-weight: 800;
    flex-shrink: 0;
}

/* ============================================================
   Answered / Waiting Cards
   ============================================================ */
.answered-card, .waiting-card {
    text-align: center;
    padding: 40px 20px;
}

.answered-icon, .waiting-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.answered-text {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.answered-sub, .waiting-text {
    color: var(--text-light);
    font-size: 15px;
}

.nickname-display {
    font-size: 18px;
    margin-bottom: 12px;
}

.selected-answer {
    margin-top: 16px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    display: inline-block;
    font-weight: 700;
    color: white;
    font-size: 16px;
}

/* ============================================================
   Result Banner (Student)
   ============================================================ */
.result-banner {
    padding: 20px;
    border-radius: var(--radius);
    text-align: center;
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 16px;
    color: white;
}

.result-banner.correct {
    background: linear-gradient(135deg, #26890C, #2ECC71);
    animation: correctPulse 0.6s ease;
}

.result-banner.incorrect {
    background: linear-gradient(135deg, #E21B3C, #FF6B6B);
    animation: shake 0.5s ease;
}

.result-banner.no-answer {
    background: var(--text-light);
}

/* ============================================================
   Chart
   ============================================================ */
.chart-container {
    position: relative;
    width: 100%;
    max-height: 300px;
    margin: 16px 0;
}

/* ============================================================
   Result Summary
   ============================================================ */
.result-summary {
    margin-top: 12px;
    font-size: 15px;
    color: var(--text-light);
    text-align: center;
}

/* ============================================================
   Ranking
   ============================================================ */
.ranking-list {
    margin-top: 16px;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.ranking-item:last-child {
    border-bottom: none;
}

.ranking-rank {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    width: 36px;
    text-align: center;
}

.ranking-rank.gold {
    color: #FFD700;
    font-size: 24px;
}

.ranking-rank.silver {
    color: #C0C0C0;
    font-size: 22px;
}

.ranking-rank.bronze {
    color: #CD7F32;
    font-size: 22px;
}

.ranking-name {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
}

.ranking-score {
    font-size: 16px;
    font-weight: 800;
    color: var(--primary);
}

.my-score-card {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.my-score-card .score-number {
    font-size: 48px;
    font-weight: 800;
    display: block;
}

.my-score-card .score-label {
    font-size: 16px;
    opacity: 0.9;
}

/* ============================================================
   Pulse Animation
   ============================================================ */
.pulse-dot {
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    margin: 20px auto 0;
    animation: pulse 1.5s ease infinite;
}

/* ============================================================
   Choice Colors
   ============================================================ */
.choice-color-0 { background: var(--choice-red); }
.choice-color-1 { background: var(--choice-blue); }
.choice-color-2 { background: var(--choice-yellow); }
.choice-color-3 { background: var(--choice-green); }
.choice-color-4 { background: var(--choice-purple); }
.choice-color-5 { background: var(--choice-orange); }

.dot-color-0 { background: var(--choice-red); }
.dot-color-1 { background: var(--choice-blue); }
.dot-color-2 { background: var(--choice-yellow); }
.dot-color-3 { background: var(--choice-green); }
.dot-color-4 { background: var(--choice-purple); }
.dot-color-5 { background: var(--choice-orange); }

/* ============================================================
   Animations
   ============================================================ */
@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; }
}

@keyframes correctPulse {
    0% { transform: scale(0.9); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

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

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    .question-text {
        font-size: 18px;
    }

    .choice-btn {
        padding: 16px;
        font-size: 16px;
    }

    .logo-area h1 {
        font-size: 24px;
    }

    .btn-lg {
        width: 100%;
    }

    .action-bar {
        flex-direction: column;
        align-items: stretch;
    }
}
