/* ============================================
   KaoPASS - Global Styles
   ============================================ */
:root {
    --primary: #2563EB;
    --primary-dark: #1E40AF;
    --primary-light: #3B82F6;
    --primary-bg: #EBF5FF;
    --gold: #F59E0B;
    --gold-bg: #FFFBEB;
    --gold-border: #D97706;
    --silver: #9CA3AF;
    --silver-border: #6B7280;
    --bronze: #B45309;
    --bronze-border: #92400E;
    --success: #22C55E;
    --success-bg: #DCFCE7;
    --error: #EF4444;
    --error-bg: #FEE2E2;
    --pink: #EC4899;
    --bg: #F2F4F7;
    --white: #FFFFFF;
    --text: #1F2937;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-pill: 24px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #F9F7F7;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.home-screen {
    font-family: 'Noto Serif', serif;
}

.profiles-scroll::-webkit-scrollbar {
    display: none;
}

#app {
    height: 100%;
    height: 100dvh; /* Better handling of mobile browser UI */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* ============================================
   Tab Bar
   ============================================ */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 480px; /* match the container width */
    margin: 0 auto;
    height: 68px;
    background: #F9F7F7;
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid #E5E7EB;
}

.tab-bar.hidden {
    display: none;
}

.tab-item {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    flex: 1;
    background: none;
    border: none;
    color: #64748B;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    transition: var(--transition);
}

.tab-item .icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    transition: var(--transition);
}

.tab-item.active {
    color: #fff;
}

.tab-item.active .icon-wrap {
    background: #4A2F3D;
}

.tab-item:active {
    transform: scale(0.95);
}

/* ============================================
   Common Components
   ============================================ */
.screen {
    min-height: 100%;
    padding-bottom: 120px; /* Increased from 80px to prevent footer overlap */
}

.header {
    background: var(--primary);
    color: var(--white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    flex: 1;
    text-align: center;
}

.header-btn {
    background: none;
    border: none;
    color: var(--white);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-white {
    background: var(--white);
    color: var(--text);
}

.header-white .header-title {
    color: var(--text);
}

.header-white .header-btn {
    color: var(--text);
}

.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    margin: 0 16px 12px;
    box-shadow: var(--shadow);
}

.card-bordered {
    border: 1.5px solid var(--border);
    box-shadow: none;
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

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

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

.btn-dark {
    background: var(--primary-dark);
    color: var(--white);
    width: 100%;
}

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

.btn-outline {
    background: var(--white);
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 1.5px solid var(--primary);
    background: var(--white);
    color: var(--primary);
}

.pill.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.pill:active {
    transform: scale(0.95);
}

/* Avatar */
.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.avatar-sm { width: 36px; height: 36px; }
.avatar-md { width: 52px; height: 52px; }
.avatar-lg { width: 72px; height: 72px; }
.avatar-xl { width: 120px; height: 120px; }
.avatar-xxl { width: 180px; height: 180px; }

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

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

/* ============================================
   HOME SCREEN
   ============================================ */
.home-header {
    background: var(--white);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.home-logo {
    font-size: 22px;
    font-weight: 900;
    color: var(--primary-dark);
    letter-spacing: -0.5px;
}

.home-logo span {
    color: var(--primary);
}

.home-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

.home-user-name {
    font-size: 11px;
    color: var(--text-secondary);
}

.home-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

/* Review Banner */
.review-banner {
    background: var(--primary);
    border-radius: var(--radius);
    padding: 24px 20px;
    margin: 12px 16px;
    text-align: center;
    color: var(--white);
}

.review-banner h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}

.review-banner .btn-start {
    background: var(--primary-dark);
    color: var(--white);
    border: none;
    padding: 10px 32px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

/* New Members Carousel */
.new-members-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 4px 0 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.new-members-scroll::-webkit-scrollbar { display: none; }

.new-member-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 64px;
    cursor: pointer;
}

.new-member-item img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 4px;
    border: 2px solid var(--primary-light);
}

.new-member-item .name {
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.new-member-item .dept {
    font-size: 9px;
    color: var(--text-secondary);
    text-align: center;
}

/* Stats Cards */
.stats-row {
    display: flex;
    gap: 12px;
    margin: 0 16px 12px;
}

.stat-card {
    flex: 1;
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.stat-card .emoji { font-size: 18px; }
.stat-card .label { 
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}
.stat-card .value {
    font-size: 24px;
    font-weight: 800;
}
.stat-card .sub {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Learning Progress */
.progress-section .big-num {
    font-size: 32px;
    font-weight: 800;
}

.progress-section .total {
    font-size: 14px;
    color: var(--text-secondary);
}

.progress-section .pct-badge {
    background: var(--primary-bg);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 700;
    float: right;
}

.progress-section .progress-bar {
    margin-top: 10px;
}

/* Mode Grid */
.mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 0 16px 12px;
}

.mode-btn {
    background: var(--primary);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    color: var(--white);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: inherit;
}

.mode-btn:hover { background: var(--primary-dark); }
.mode-btn:active { transform: scale(0.97); }

.mode-btn i {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.mode-btn span {
    font-size: 13px;
    font-weight: 700;
}

.ranking-link-btn {
    margin: 0 16px 12px;
}

/* ============================================
   NEWCOMER MODE SCREEN
   ============================================ */
.preset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.preset-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.preset-btn i {
    color: var(--primary);
    font-size: 16px;
}

.preset-btn.active {
    background: var(--primary-bg);
    border-color: var(--primary);
}

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

.divider-text {
    text-align: center;
    color: var(--text-light);
    font-size: 12px;
    padding: 16px 0;
    position: relative;
}

.divider-text::before,
.divider-text::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 35%;
    height: 1px;
    background: var(--border);
}

.divider-text::before { left: 16px; }
.divider-text::after { right: 16px; }

.custom-period {
    display: flex;
    gap: 12px;
}

.custom-period select {
    flex: 1;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-secondary);
    appearance: none;
    background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239CA3AF' d='M2 4l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 12px center;
}

.hire-type-pills {
    display: flex;
    gap: 10px;
}

.match-count {
    display: flex;
    align-items: center;
    gap: 12px;
}

.match-count .avatars {
    display: flex;
}

.match-count .avatars img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--white);
    margin-left: -8px;
}

.match-count .avatars img:first-child {
    margin-left: 0;
}

.bottom-action {
    position: fixed;
    bottom: 80px;
    left: 16px;
    right: 16px;
    z-index: 50;
}

/* ============================================
   QUIZ SCREEN
   ============================================ */
.quiz-screen {
    background: linear-gradient(135deg, #0A1628 0%, #1E3A5F 50%, #0F2440 100%);
    height: 100%;
    min-height: 100vh;
    color: var(--white);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.quiz-top {
    padding: 16px 20px 8px;
}

.quiz-progress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
}

.quiz-timer {
    display: flex;
    align-items: center;
    gap: 4px;
}

.quiz-progress-bar {
    width: 100%;
    height: 3px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
}

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

.quiz-photo-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.quiz-photo-circle {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 4px solid rgba(255,255,255,0.3);
    overflow: hidden;
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.3);
    margin: 0 auto;
}

.quiz-photo-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.quiz-hint {
    margin-top: 12px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    opacity: 0.9;
}

.quiz-options {
    padding: 0 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.quiz-option {
    background: rgba(255,255,255,0.12);
    border: 1.5px solid rgba(255,255,255,0.2);
    border-radius: 14px;
    padding: 16px 20px;
    color: var(--white);
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.quiz-option:hover {
    background: rgba(255,255,255,0.2);
}

.quiz-option:active {
    transform: scale(0.98);
}

.quiz-option.correct {
    background: var(--success);
    border-color: var(--success);
}

.quiz-option.correct::after {
    content: ' ✓';
}

.quiz-option.incorrect {
    background: var(--error);
    border-color: var(--error);
}

.quiz-option.incorrect::after {
    content: ' ✗';
}

.quiz-option.dimmed {
    opacity: 0.4;
}

.quiz-bottom-bar {
    background: rgba(0,0,0,0.3);
    padding: 12px 20px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-around;
}

.quiz-tab-item {
    color: rgba(255,255,255,0.6);
    font-size: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.quiz-tab-item.active {
    color: var(--white);
}

/* ============================================
   ANSWER RESULT SCREEN
   ============================================ */
.result-screen {
    background: linear-gradient(135deg, #0A1628 0%, #162D50 50%, #0F2440 100%);
    height: 100%;
    min-height: 100vh;
    color: var(--white);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px 40px;
    overflow-y: auto;
}

.result-header-icon {
    font-size: 56px;
    margin-bottom: 8px;
}

.result-header-icon.correct {
    color: var(--success);
}

.result-header-icon.incorrect {
    color: var(--error);
}

.result-title {
    font-size: 32px;
    font-weight: 900;
    margin-bottom: 24px;
}

/* ID Card */
.id-card {
    background: linear-gradient(145deg, #1a3a5c, #0d2740);
    border-radius: 16px;
    padding: 20px;
    width: 100%;
    max-width: 320px;
    text-align: center;
    position: relative;
    box-shadow: 0 0 40px rgba(34, 197, 94, 0.15);
    border: 2px solid rgba(255,255,255,0.1);
    margin-bottom: 24px;
}

.id-card.correct-glow {
    box-shadow: 0 0 40px rgba(34, 197, 94, 0.3), 0 0 80px rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
}

.id-card.incorrect-glow {
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.3), 0 0 80px rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.id-card-photo {
    width: 80px;
    height: 100px;
    border-radius: 8px;
    object-fit: cover;
    margin-bottom: 12px;
    border: 2px solid rgba(255,255,255,0.2);
}

.id-card-name {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 4px;
}

.id-card-position {
    font-size: 13px;
    color: #60A5FA;
    margin-bottom: 12px;
}

.id-card-details {
    text-align: left;
    font-size: 11px;
    line-height: 1.6;
    opacity: 0.85;
}

.id-card-details span {
    color: #93C5FD;
}

/* Result Options */
.result-options {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.result-option {
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-option.correct {
    background: var(--success);
}

.result-option.incorrect {
    background: var(--error);
}

.result-option.dimmed {
    opacity: 0.35;
}

.result-next-btn {
    width: 100%;
    max-width: 320px;
    padding: 18px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 16px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    margin-top: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.1s;
}

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

/* ============================================
   SESSION RESULT SCREEN
   ============================================ */
.session-result-screen {
    min-height: 100vh;
    background: var(--white);
    padding: 32px 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.session-result-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Circular Progress */
.circle-progress {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 32px;
}

.circle-progress svg {
    transform: rotate(-90deg);
    width: 200px;
    height: 200px;
}

.circle-progress .track {
    fill: none;
    stroke: var(--border-light);
    stroke-width: 10;
}

.circle-progress .fill {
    fill: none;
    stroke: url(#progressGradient);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.5s ease;
}

.circle-progress .center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.circle-progress .score-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.circle-progress .score-value {
    font-size: 48px;
    font-weight: 900;
    color: var(--text);
}

/* Session Stats */
.session-stats {
    display: flex;
    gap: 10px;
    margin-bottom: 32px;
}

.session-stat-card {
    flex: 1;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 8px;
    text-align: center;
}

.session-stat-card .icon { font-size: 20px; margin-bottom: 4px; }
.session-stat-card .label { font-size: 10px; color: var(--text-secondary); }
.session-stat-card .value { font-size: 18px; font-weight: 800; }

/* Incorrect List */
.incorrect-section {
    text-align: left;
    margin-bottom: 32px;
}

.incorrect-section h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
}

.incorrect-avatars {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.incorrect-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.incorrect-item img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--pink);
    margin-bottom: 4px;
}

.incorrect-item span {
    font-size: 12px;
    font-weight: 500;
}

.session-actions {
    display: flex;
    gap: 12px;
}

.session-actions .btn {
    flex: 1;
    padding: 14px 8px;
    font-size: 14px;
}

/* Confetti */
.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.confetti {
    position: absolute;
    width: 8px;
    height: 8px;
    opacity: 0.8;
    animation: confettiFall 3s ease-in-out forwards;
}

@keyframes confettiFall {
    0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ============================================
   RANKING SCREEN
   ============================================ */
.ranking-screen {
    background: #F9F7F7;
    font-family: 'Noto Serif', serif;
}

.ranking-filters {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #F9F7F7;
    position: sticky;
    top: 60px;
    z-index: 90;
}

.ranking-period-tabs {
    display: flex;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    border: none;
}

.ranking-period-tab {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    font-size: 13px;
    font-weight: 700;
    color: #64748B;
    cursor: pointer;
    font-family: 'Noto Sans JP', sans-serif;
    transition: var(--transition);
}

.ranking-period-tab.active {
    background: #4A2F3D;
    color: var(--white);
    border-radius: 12px;
}

.ranking-filter-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-tag {
    padding: 6px 16px;
    border: 1px solid #E2D8DD;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    color: #64748B;
    background: var(--white);
    cursor: pointer;
    font-family: 'Noto Sans JP', sans-serif;
    transition: var(--transition);
}

.filter-tag.active {
    background: #4A2F3D;
    border-color: #4A2F3D;
    color: var(--white);
}

/* Ranking Sub Tabs */
.ranking-sub-tabs {
    display: flex;
    background: var(--white);
    border-bottom: 1.5px solid var(--border);
    padding: 0 4px;
    margin-bottom: 12px;
}

.ranking-sub-tab {
    flex: 1;
    padding: 10px 4px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
    white-space: nowrap;
    text-align: center;
    margin-bottom: -1.5px;
}

.ranking-sub-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.ranking-sub-tab:active {
    opacity: 0.7;
}

/* Top 3 Podium */
.podium-section {
    padding: 0 16px 12px;
}

.podium-first {
    background: var(--gold-bg);
    border: 2px solid var(--gold);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    position: relative;
}

.podium-first .rank-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 900;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.podium-first .avatar-ring {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid var(--gold);
    overflow: hidden;
    flex-shrink: 0;
}

.podium-first .avatar-ring img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.podium-first .info .name {
    font-size: 18px;
    font-weight: 800;
}

.podium-first .info .dept {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.podium-first .info .score {
    font-size: 24px;
    font-weight: 900;
    color: var(--primary);
}

.podium-first .info .voters {
    font-size: 11px;
    color: var(--text-light);
}

.podium-row {
    display: flex;
    gap: 12px;
}

.podium-card {
    flex: 1;
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
}

.podium-card .rank-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 900;
}

.podium-card .rank-badge.silver { background: var(--silver-border); }
.podium-card .rank-badge.bronze { background: var(--bronze); }

.podium-card .avatar-ring {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 3px solid;
    overflow: hidden;
    margin: 0 auto 8px;
}

.podium-card .avatar-ring.silver { border-color: var(--silver); }
.podium-card .avatar-ring.bronze { border-color: var(--bronze); }

.podium-card .avatar-ring img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.podium-card .name {
    font-size: 14px;
    font-weight: 700;
}

.podium-card .dept {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.podium-card .score {
    font-size: 20px;
    font-weight: 900;
    color: var(--primary);
}

.podium-card .voters {
    font-size: 10px;
    color: var(--text-light);
}

/* Ranking List Items */
.ranking-list {
    padding: 0 16px;
}

.ranking-list-item {
    background: var(--white);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
}

.ranking-list-item:active { transform: scale(0.98); }

.rank-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-bg);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    flex-shrink: 0;
}

.ranking-list-item .avatar-wrap {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.ranking-list-item .avatar-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ranking-list-item .info {
    flex: 1;
    min-width: 0;
}

.ranking-list-item .info .name {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-list-item .info .dept {
    font-size: 11px;
    color: var(--text-secondary);
}

.ranking-list-item .score-area {
    text-align: right;
    flex-shrink: 0;
}

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

.ranking-list-item .score-area .voters {
    font-size: 10px;
    color: var(--text-light);
}

.ranking-list-item .mini-bar {
    width: 60px;
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    margin-top: 4px;
}

.ranking-list-item .mini-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
}

/* Sub badges */
.sub-badge {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
}

.dark-badge {
    background: #1e1b4b;
    color: #c7d2fe;
}

.rise-badge {
    background: #dcfce7;
    color: #16a34a;
}

/* ============================================
   DETAIL POPUP
   ============================================ */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.popup-content {
    background: var(--white);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px 20px 40px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.popup-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 20px;
}

.popup-profile {
    text-align: center;
    margin-bottom: 24px;
}

.popup-profile img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    margin-bottom: 12px;
}

.popup-profile .name {
    font-size: 22px;
    font-weight: 800;
}

.popup-profile .kana {
    font-size: 12px;
    color: var(--text-secondary);
}

.popup-profile .nickname {
    font-size: 14px;
    color: var(--primary);
    font-weight: 600;
    margin-top: 4px;
}

.popup-info {
    margin-bottom: 16px;
}

.popup-info-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.popup-info-row .label {
    width: 100px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    flex-shrink: 0;
}

.popup-info-row .value {
    font-size: 13px;
    font-weight: 600;
    flex: 1;
}

.popup-score {
    background: var(--primary-bg);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    margin-bottom: 16px;
}

.popup-score .score-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.popup-score .score-value {
    font-size: 36px;
    font-weight: 900;
    color: var(--primary);
}

.popup-score .voters {
    font-size: 12px;
    color: var(--text-secondary);
}

.popup-intro {
    background: var(--border-light);
    border-radius: 12px;
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

/* ============================================
   DEPARTMENT / WEAKNESS MODE SCREENS
   ============================================ */
.dept-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dept-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.dept-btn.active {
    background: var(--primary-bg);
    border-color: var(--primary);
}

.dept-btn .count {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================
   FILTER POPUP
   ============================================ */
.filter-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.filter-popup-content {
    background: var(--white);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 480px;
    padding: 24px 20px 40px;
    animation: slideUp 0.3s ease;
}

/* ============================================
   ANIMATIONS
   ============================================ */
.profile-card {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease, opacity 0.2s ease;
}

.profile-card:hover, .profile-card:focus-visible {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.08) !important;
    opacity: 0.9;
    outline: none;
}

.profile-card:active {
    transform: translateY(0) scale(0.95);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
    opacity: 1;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes flipCard {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(90deg); }
    100% { transform: rotateY(0deg); }
}

.animate-pulse { animation: pulse 0.5s ease; }
.animate-shake { animation: shake 0.3s ease; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 480px) {
    #app {
        max-width: 480px;
        margin: 0 auto;
    }
    
    .tab-bar {
        max-width: 480px;
        left: 50%;
        transform: translateX(-50%);
    }

    .bottom-action {
        max-width: 448px;
        left: 50%;
        transform: translateX(-50%);
    }

    .popup-content,
    .filter-popup-content {
        max-width: 480px;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    color: var(--border);
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 16px;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Scrollbar */
#app::-webkit-scrollbar { width: 0; }
