:root {
    --primary-blue: #007aff; /* Apple system blue */
    --bg-gray: #f2f2f7; /* iOS systemGroupedBackground (light gray) */
    --card-bg: #ffffff;
    --text-dark: #1a1a1a; /* HIG high contrast primary text */
    --text-muted: #8e8e93; /* iOS systemGray for secondary labels */
    --highlight-red: #ff3b30; /* iOS systemRed for letter highlight */
    --card-shadow: 0px 4px 6px rgba(0, 0, 0, 0.04), 0px 1px 3px rgba(0, 0, 0, 0.02);
    --card-border: 1px solid rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Icons", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background-color: var(--bg-gray);
    color: var(--text-dark);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* Header - iOS Frosted Glass Navigation Bar */
.app-header {
    background-color: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px) saturate(190%);
    -webkit-backdrop-filter: blur(20px) saturate(190%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--text-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-dots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: var(--primary-blue);
    border-radius: 50%;
}

.logo-text {
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: 0.5px;
    color: var(--text-dark);
}

.app-header h1 {
    font-size: 1.15rem;
    font-weight: 600;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-dark);
}

.help-btn {
    background: transparent;
    color: var(--primary-blue);
    border: 1.5px solid var(--primary-blue);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
}

.help-btn:active {
    background-color: rgba(0, 122, 255, 0.1);
    opacity: 0.8;
}

/* Main Content */
.app-main {
    padding: 20px 16px;
    max-width: 800px;
    margin: 0 auto;
}

.phoneme-section {
    margin-bottom: 32px;
}

/* iOS-style Section Label */
.section-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    margin-left: 4px;
    display: block;
}

/* Grid Layout */
.phoneme-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
}

/* Phoneme Card - HIG Style */
.phoneme-card {
    background-color: var(--card-bg);
    border: var(--card-border);
    border-radius: 10px; /* conforming to 10px圓角 parameter */
    box-shadow: var(--card-shadow); /* conforming to box-shadow parameter */
    width: calc(25% - 8px); /* 4 columns by default, minus gap */
    max-width: 80px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94), background-color 0.15s ease, box-shadow 0.15s ease;
}

.phoneme-card:active {
    background-color: #f2f2f7;
    transform: scale(0.94);
    box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.02);
}

.phoneme-symbol {
    font-family: -apple-system, BlinkMacSystemFont, "Times New Roman", Times, serif;
    font-size: 2.2rem;
    font-weight: 500;
    color: var(--text-dark);
}

/* Phoneme Detail Modal - iOS Sheet Style */
.phoneme-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.phoneme-modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.35); /* soft darkened backdrop overlay */
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--card-bg);
    border: none; /* remove solid blue borders */
    border-radius: 18px;
    width: 90%;
    max-width: 320px;
    padding: 24px 20px 20px;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.18); /* premium soft shadow */
    
    /* Animation: bouncy scale-up */
    transform: scale(0.85) translateY(20px);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.phoneme-modal.show .modal-content {
    transform: scale(1) translateY(0);
}

/* iOS circular close button */
.modal-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #666;
    cursor: pointer;
    line-height: 1;
    border: none;
    padding: 0;
    transition: background-color 0.2s, transform 0.1s;
}

.modal-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #000;
}

.modal-close-btn:active {
    transform: scale(0.9);
}

.modal-phoneme-large {
    font-family: -apple-system, BlinkMacSystemFont, "Times New Roman", Times, serif;
    font-size: 5rem;
    color: var(--text-dark); /* High contrast */
    font-weight: 500;
    line-height: 1;
    margin-bottom: 12px;
    cursor: pointer;
    transition: transform 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
}

.modal-phoneme-large:active {
    transform: scale(0.92);
}

.modal-divider {
    width: 40px;
    height: 4px;
    background-color: rgba(0, 0, 0, 0.08); /* Clean light grey divider */
    border-radius: 2px;
    margin-bottom: 20px;
}

.modal-word-list {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
}

/* iOS secondary control style (borderless gray buttons) */
.modal-word-item {
    padding: 14px 16px;
    font-size: 1.25rem;
    text-align: center;
    border: none;
    border-radius: 12px;
    margin-bottom: 10px;
    background-color: #f2f2f7; /* iOS secondary background gray */
    cursor: pointer;
    font-weight: 600;
    color: var(--text-dark);
    transition: background-color 0.15s, transform 0.1s;
}

.modal-word-item:last-child {
    margin-bottom: 0;
}

.modal-word-item:hover {
    background-color: #e5e5ea;
}

.modal-word-item:active {
    transform: scale(0.97);
    background-color: #d1d1d6;
}

.highlight {
    color: var(--highlight-red);
}

/* Responsive adjustments */
@media (min-width: 480px) {
    .phoneme-card {
        width: 80px;
        height: 80px;
    }
}
