:root {
    --bg-gradient-start: #0f0c29;
    --bg-gradient-mid: #302b63;
    --bg-gradient-end: #24243e;
    
    --card-bg: rgba(255, 255, 255, 0.08);
    --card-border: rgba(255, 255, 255, 0.15);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    
    --primary-color: #ff7e5f;
    --primary-gradient: linear-gradient(135deg, #ff7e5f, #feb47d);
    
    --safe-area-top: env(safe-area-inset-top, 20px);
    --safe-area-bottom: env(safe-area-inset-bottom, 20px);
}

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

html {
    background-color: var(--bg-gradient-end);
    overscroll-behavior: none;
}

body {
    overscroll-behavior: none;
}

body {
    font-family: 'Noto Sans TC', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-mid), var(--bg-gradient-end));
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    width: 100%;
    height: 100%;
    position: fixed;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.app-container {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    position: relative;
    max-width: 600px;
    margin: 0 auto;
    overflow: hidden;
}

/* Views */
.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: calc(var(--safe-area-top) + 20px) 24px calc(var(--safe-area-bottom) + 24px);
    display: flex;
    flex-direction: column;
    transition: opacity 0.4s ease, transform 0.4s ease;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

.view.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.view.hidden {
    display: none;
}

/* Home View */
.home-header {
    text-align: center;
    margin-bottom: 40px;
    margin-top: 40px;
}

.home-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.home-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

.category-selection {
    flex-grow: 1;
}

.category-selection h3 {
    font-size: 16px;
    margin-bottom: 16px;
    font-weight: 500;
}

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.chip {
    padding: 12px 20px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip.selected {
    background: var(--primary-gradient);
    border-color: transparent;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(255, 126, 95, 0.3);
}

/* Buttons */
button {
    border: none;
    outline: none;
    cursor: pointer;
    font-family: inherit;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s ease;
}

button:active {
    transform: scale(0.97);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    width: 100%;
    padding: 16px;
    background: var(--primary-gradient);
    color: white;
    margin-bottom: 16px;
    box-shadow: 0 4px 15px rgba(255, 126, 95, 0.3);
}

.btn-secondary {
    width: 100%;
    padding: 16px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--card-border);
    backdrop-filter: blur(10px);
}

.btn-large {
    padding: 18px;
    font-size: 18px;
    border-radius: 20px;
}

.btn-icon {
    background: transparent;
    color: var(--text-primary);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Game View */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
}

.header-label {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
}

.header-space {
    width: 40px; /* same as back button to center title */
}

.card-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
}

.glass-card {
    width: 100%;
    aspect-ratio: 3/4;
    max-height: 450px;
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--card-border);
    border-radius: 30px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    touch-action: none;
}

.glass-card.swipe-out {
    transform: translateX(-100%) rotate(-10deg);
    opacity: 0;
}

.glass-card.swipe-in {
    transform: translateX(100%) rotate(10deg);
    opacity: 0;
}

.card-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.card-content {
    text-align: center;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge {
    display: inline-block;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    font-size: 13px;
    color: var(--primary-color);
}

.star-icon {
    color: rgba(255, 255, 255, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.star-icon.favorited {
    color: #ffd700;
    fill: #ffd700;
    transform: scale(1.1);
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.5));
}

.card-content h2 {
    font-size: 26px;
    line-height: 1.5;
    font-weight: 500;
}

.game-controls {
    margin-top: 20px;
}

.progress-info {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
}

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

.mt-4 {
    margin-top: 24px;
}
