/* Reset & Base - iPhone Safari optimiert */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
    background: #f5f7fa;
    color: #1c1c1e;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ============================================
   JAMES BOND CODE-EINGABE
   ============================================ */

.bond-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    overflow: hidden;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.bond-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(236, 0, 22, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(0, 122, 255, 0.1) 0%, transparent 50%),
        linear-gradient(135deg, #0a0a0a 0%, #1c1c1e 100%);
    animation: pulse 8s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.bond-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    padding: 1rem 1.5rem;
    z-index: 1;
    max-height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.bond-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-top: 1rem;
}

.classified-badge {
    display: inline-block;
    background: rgba(236, 0, 22, 0.2);
    border: 2px solid #EC0016;
    color: #EC0016;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 1.5rem;
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 10px rgba(236, 0, 22, 0.3); }
    50% { box-shadow: 0 0 20px rgba(236, 0, 22, 0.6); }
}

.bond-title {
    color: #fff;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 10px rgba(236, 0, 22, 0.3);
    line-height: 1.3;
}

.bond-subtitle {
    color: #8e8e93;
    font-size: 0.95rem;
    font-weight: 500;
}

.bond-hint {
    color: #EC0016;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(236, 0, 22, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(236, 0, 22, 0.3);
}

.bond-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.code-display {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.code-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.code-dot.filled {
    background: #EC0016;
    border-color: #EC0016;
    box-shadow: 0 0 15px rgba(236, 0, 22, 0.6);
    transform: scale(1.2);
}

.code-dot.error {
    background: transparent;
    border-color: #EC0016;
    animation: shake 0.5s ease;
}

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

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.num-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 600;
    padding: 1.2rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(10px);
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.num-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(236, 0, 22, 0.5);
}

.num-btn.clear-btn {
    background: rgba(255, 59, 48, 0.1);
    border-color: rgba(255, 59, 48, 0.3);
    font-size: 1.3rem;
}

.num-btn.enter-btn {
    background: rgba(52, 199, 89, 0.2);
    border-color: rgba(52, 199, 89, 0.4);
    color: #34c759;
    font-size: 1.8rem;
}

.bond-footer {
    margin-top: 2rem;
    text-align: center;
    padding-bottom: 1rem;
}

.security-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #34c759;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 1px;
}

.indicator-dot {
    width: 8px;
    height: 8px;
    background: #34c759;
    border-radius: 50%;
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ============================================
   HAUPTSEITE
   ============================================ */

.db-header {
    background: #EC0016;
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.db-logo {
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
}

.header-snow {
    font-size: 1.5rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Live-Ticker */
.live-ticker-wrapper {
    background: #282d37;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.live-ticker {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    gap: 0.75rem;
}

.ticker-label {
    flex-shrink: 0;
    background: #EC0016;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.7rem;
    color: white;
    margin-left: 1rem;
}

.ticker-scroll {
    flex: 1;
    overflow: hidden;
    margin-right: 1rem;
}

.ticker-content {
    display: inline-block;
    white-space: nowrap;
    color: white;
    font-size: 0.9rem;
    animation: scroll-left 40s linear infinite;
    will-change: transform;
}

@keyframes scroll-left {
    0% { transform: translateX(0); }
    100% { transform: translateX(-25%); }
}

/* Container */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    padding-bottom: 100px;
}

/* Cards */
.db-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.card-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1c1c1e;
    margin-bottom: 1rem;
}

.user-badge {
    background: #EC0016;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Countdown */
.countdown-card {
    background: linear-gradient(135deg, #EC0016 0%, #c40012 100%);
    color: white;
}

.countdown-display {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.countdown-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

.countdown-number {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    background: rgba(255,255,255,0.2);
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    min-width: 70px;
    text-align: center;
}

.countdown-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    opacity: 0.9;
    margin-top: 0.5rem;
    font-weight: 600;
}

.departure-info {
    display: flex;
    justify-content: center;
    gap: 2rem;
    font-size: 0.95rem;
}

.platform {
    background: rgba(255,255,255,0.2);
    padding: 0.4rem 0.9rem;
    border-radius: 8px;
    font-weight: 600;
}

.delay {
    color: #90EE90;
    font-weight: 600;
}

/* Nächster Event */
.next-event-card {
    border-left: 4px solid #EC0016;
    background: linear-gradient(90deg, rgba(236,0,22,0.05) 0%, white 100%);
}

.next-label {
    display: inline-block;
    background: #EC0016;
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: 0.5px;
}

.current-event {
    display: flex;
    gap: 1rem;
}

.event-time {
    font-size: 2rem;
    font-weight: 700;
    color: #EC0016;
    min-width: 80px;
}

.event-details {
    flex: 1;
}

.event-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.event-type {
    color: #666;
    font-size: 0.95rem;
}

/* Fahrplan Toggle */
.timetable-card {
    padding: 0;
    overflow: hidden;
}

.timetable-toggle {
    width: 100%;
    padding: 1.5rem;
    background: white;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.3s ease;
}

.timetable-toggle:active {
    background: #f5f7fa;
}

.toggle-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1c1c1e;
}

.toggle-icon {
    font-size: 1.2rem;
    color: #EC0016;
    transition: transform 0.3s ease;
}

.timetable-toggle.active .toggle-icon {
    transform: rotate(180deg);
}

.timetable-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    padding: 0 1.5rem;
}

.timetable-content.expanded {
    max-height: 3000px;
    padding: 1.5rem;
}

.date-badge {
    display: inline-block;
    background: #EC0016;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* Timetable */
.timetable {
    position: relative;
    padding-left: 0;
}

/* Rote Verbindungslinie zwischen den Punkten */
.timetable::before {
    content: '';
    position: absolute;
    left: 85px;
    top: 2rem;
    bottom: 2rem;
    width: 3px;
    background: linear-gradient(180deg, #EC0016 0%, #c40012 100%);
    z-index: 0;
}

.journey-item {
    display: flex;
    align-items: flex-start;
    gap: 3rem;
    padding: 1.5rem 0;
    position: relative;
}

.time {
    font-size: 1.3rem;
    font-weight: 700;
    color: #EC0016;
    min-width: 70px;
    position: relative;
    flex-shrink: 0;
    padding-top: 0.2rem;
}

/* Roter Punkt rechts neben der Uhrzeit */
.time::after {
    content: '';
    position: absolute;
    right: -21px;
    top: 0.5rem;
    width: 14px;
    height: 14px;
    background: #EC0016;
    border-radius: 50%;
    box-shadow: 0 0 0 4px white, 0 0 0 6px #EC0016;
    z-index: 2;
}

.journey-details {
    flex: 1;
    padding-top: 0.2rem;
}

.station {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.train-info {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0.5rem 0;
}

.train-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.8rem;
    color: white;
}

.train-badge.rex { background: #007A3D; }
.train-badge.r { background: #2E75B6; }
.train-badge.s { background: #006F35; }

.train-number {
    color: #666;
    font-size: 0.85rem;
}

.direction {
    color: #666;
    font-size: 0.9rem;
}

.transfer {
    color: #EC0016;
    font-weight: 600;
    font-size: 0.95rem;
}

.location {
    color: #666;
    font-size: 0.9rem;
}

.duration {
    color: #EC0016;
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.journey-type {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.journey-type.start {
    background: #90EE90;
    color: #006400;
}

.journey-type.end {
    background: #FFD700;
    color: #8B4513;
}

.journey-item.highlight {
    background: rgba(236,0,22,0.03);
    margin: 0 -1.5rem;
    padding: 1.5rem;
    border-radius: 8px;
}

/* Name Form */
.name-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.name-form input {
    padding: 1rem;
    font-size: 1.1rem;
    border: 2px solid #e5e8eb;
    border-radius: 12px;
}

.name-form input:focus {
    outline: none;
    border-color: #EC0016;
}

.db-button {
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    background: #EC0016;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
}

.db-button:active {
    transform: scale(0.98);
}

/* Drink Buttons */
.drink-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 1.5rem 0;
}

.drink-btn {
    background: #f5f7fa;
    border: 2px solid #e5e8eb;
    border-radius: 12px;
    padding: 1.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.drink-btn:active {
    transform: scale(0.95);
    background: #EC0016;
    color: white;
    border-color: #EC0016;
}

.drink-icon {
    font-size: 2.5rem;
}

.drink-name {
    font-weight: 600;
    font-size: 1rem;
}

/* Cancel Overlay */
.cancel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.cancel-content {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    width: 90%;
    max-width: 350px;
    text-align: center;
}

.cancel-message {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.cancel-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.2rem;
    font-weight: 700;
    background: #EC0016;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 1rem;
}

.cancel-timer {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.cancel-progress {
    height: 100%;
    background: linear-gradient(90deg, #90EE90 0%, #32CD32 100%);
    transition: width 0.1s linear;
    width: 100%;
}

/* Stats */
.stats-section {
    margin-top: 2rem;
}

.stats-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-align: center;
}

#drinkChart {
    max-width: 100%;
    height: 400px !important;
    margin-bottom: 1.5rem;
    display: block;
}

.leaderboard {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1rem;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: white;
    border-radius: 8px;
}

.leaderboard-rank {
    font-size: 1.5rem;
    min-width: 40px;
}

.leaderboard-name {
    flex: 1;
    font-weight: 600;
}

.leaderboard-drinks {
    font-weight: 700;
    color: #EC0016;
}

/* Footer */
.db-footer {
    background: #282d37;
    color: white;
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 3rem;
}

.footer-small {
    font-size: 0.85rem;
    opacity: 0.7;
    margin-top: 0.5rem;
}

/* iPhone Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .bond-overlay {
        height: -webkit-fill-available;
        min-height: -webkit-fill-available;
    }
    
    .bond-container {
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Safe area padding for iPhone notch */
@supports (padding: max(0px)) {
    .db-header {
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}