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

:root {
    --primary-color: #4A90E2;
    --secondary-color: #50C878;
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e0e0e0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 20px;
    padding: 15px 10px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

.api-key-section {
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.api-key-section input {
    width: 100%;
    max-width: 500px;
    padding: 12px 15px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 10px;
    font-family: 'Noto Sans KR', sans-serif;
}

.api-key-section input:focus {
    outline: none;
    border-color: white;
    background: white;
}

.api-key-section button {
    padding: 14px 30px;
    background: white;
    color: var(--primary-color);
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Noto Sans KR', sans-serif;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.api-key-section button:hover {
    background: var(--secondary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.api-key-hint {
    margin-top: 10px;
    font-size: 0.85rem;
    opacity: 0.9;
    line-height: 1.5;
}

main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.weather-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.weather-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.weather-card h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-weight: 500;
}

.current-weather {
    grid-column: 1 / -1;
}

.weather-content {
    animation: fadeIn 0.5s ease-in;
}

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

.weather-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

.temperature {
    display: flex;
    align-items: flex-start;
}

.temp-value {
    font-size: 5rem;
    font-weight: 300;
    line-height: 1;
    color: var(--primary-color);
}

.temp-unit {
    font-size: 2rem;
    margin-left: 5px;
    color: var(--text-secondary);
}

.weather-icon {
    font-size: 5rem;
    animation: float 3s ease-in-out infinite;
}

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

.weather-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    background: rgba(74, 144, 226, 0.1);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.detail-item:hover {
    background: rgba(74, 144, 226, 0.2);
}

.detail-item .label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 400;
}

.detail-item .value {
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--primary-color);
}

.weather-description {
    text-align: center;
    font-size: 1.2rem;
    color: var(--text-primary);
    padding: 15px;
    background: rgba(80, 200, 120, 0.1);
    border-radius: 10px;
    font-weight: 400;
}

.hourly-forecast {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}

.hourly-forecast::-webkit-scrollbar {
    height: 8px;
}

.hourly-forecast::-webkit-scrollbar-track {
    background: var(--border-color);
    border-radius: 10px;
}

.hourly-forecast::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.hourly-item {
    min-width: 90px;
    flex-shrink: 0;
    text-align: center;
    padding: 12px 10px;
    background: rgba(74, 144, 226, 0.05);
    border-radius: 12px;
    transition: all 0.3s ease;
    scroll-snap-align: start;
}

.hourly-item:hover {
    background: rgba(74, 144, 226, 0.15);
    transform: scale(1.05);
}

.hourly-item .time {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 400;
}

.hourly-item .icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.hourly-item .temp {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--primary-color);
}

.hourly-item .pop {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

.daily-forecast {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.daily-item {
    padding: 20px;
    background: rgba(74, 144, 226, 0.05);
    border-radius: 15px;
    text-align: center;
    transition: all 0.3s ease;
}

.daily-item:hover {
    background: rgba(74, 144, 226, 0.15);
    transform: translateY(-5px);
}

.daily-item .date {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-weight: 400;
}

.daily-item .icon {
    font-size: 3rem;
    margin: 15px 0;
}

.daily-item .temp-range {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-weight: 500;
}

.daily-item .description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 10px;
}

.daily-item .pop {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%, 100% {
        content: '...';
    }
}

footer {
    text-align: center;
    color: white;
    padding: 20px;
    opacity: 0.9;
}

footer p {
    margin: 5px 0;
    font-size: 0.9rem;
}

.update-time {
    font-size: 0.85rem;
    opacity: 0.8;
}

.error {
    background: #ff6b6b;
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: left;
    margin: 20px 0;
    box-shadow: var(--shadow);
    line-height: 1.6;
    font-size: 0.95rem;
    max-width: 100%;
    word-wrap: break-word;
}

/* 반응형 디자인 - 모바일 최적화 */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    header {
        padding: 12px 8px;
        margin-bottom: 15px;
    }

    header h1 {
        font-size: 1.8rem;
        margin-bottom: 8px;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    main {
        gap: 12px;
        margin-bottom: 15px;
    }

    .weather-card {
        padding: 18px;
        border-radius: 14px;
    }

    .weather-card h2 {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }

    .weather-main {
        margin-bottom: 20px;
        padding-bottom: 20px;
    }

    .temp-value {
        font-size: 3.5rem;
    }

    .temp-unit {
        font-size: 1.3rem;
    }

    .weather-icon {
        font-size: 3.5rem;
    }

    .weather-details {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .detail-item {
        padding: 12px;
    }

    .detail-item .label {
        font-size: 0.85rem;
    }

    .detail-item .value {
        font-size: 1.1rem;
    }

    .weather-description {
        font-size: 1rem;
        padding: 12px;
    }

    .hourly-forecast {
        gap: 8px;
        padding: 8px 0;
    }

    .hourly-item {
        min-width: 75px;
        padding: 10px 8px;
    }

    .hourly-item .time {
        font-size: 0.8rem;
    }

    .hourly-item .icon {
        font-size: 1.6rem;
        margin-bottom: 8px;
    }

    .hourly-item .temp {
        font-size: 1rem;
    }

    .hourly-item .pop {
        font-size: 0.75rem;
    }

    .daily-forecast {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .daily-item {
        padding: 16px;
    }

    .daily-item .date {
        font-size: 0.9rem;
    }

    .daily-item .icon {
        font-size: 2.5rem;
    }

    .daily-item .temp-range {
        font-size: 1rem;
    }

    .api-key-section {
        padding: 15px;
        margin-top: 15px;
    }

    .api-key-section input {
        padding: 14px 12px;
        font-size: 0.95rem;
        min-height: 44px;
    }

    footer {
        padding: 15px 10px;
    }

    footer p {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    header {
        padding: 10px 5px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .weather-card {
        padding: 15px;
        border-radius: 12px;
    }

    .weather-card h2 {
        font-size: 1.2rem;
        margin-bottom: 12px;
    }

    .temp-value {
        font-size: 3rem;
    }

    .temp-unit {
        font-size: 1.2rem;
    }

    .weather-icon {
        font-size: 3rem;
    }

    .weather-details {
        gap: 10px;
    }

    .detail-item {
        padding: 10px;
    }

    .detail-item .value {
        font-size: 1rem;
    }

    .hourly-item {
        min-width: 70px;
        padding: 8px 6px;
    }

    .hourly-item .icon {
        font-size: 1.4rem;
    }

    .daily-item {
        padding: 14px;
    }

    .daily-item .icon {
        font-size: 2.2rem;
    }
}

/* 매우 작은 화면 (아이폰 SE 등) */
@media (max-width: 360px) {
    header h1 {
        font-size: 1.4rem;
    }

    .temp-value {
        font-size: 2.5rem;
    }

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

    .hourly-item {
        min-width: 65px;
    }
}

/* 가로 모드 최적화 */
@media (max-width: 768px) and (orientation: landscape) {
    header {
        padding: 10px;
        margin-bottom: 10px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    main {
        gap: 10px;
    }

    .weather-card {
        padding: 15px;
    }
}
