/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-green: #1a5f3c;
    --dark-green: #0d3320;
    --felt-green: #1e7847;
    --card-white: #ffffff;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --red: #dc3545;
    --light-red: #ff6b6b;
    --green: #28a745;
    --light-green: #51cf66;
    --gold: #ffd700;
    --text-light: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.7);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--dark-green) 0%, var(--primary-green) 50%, var(--dark-green) 100%);
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text-light);
    -webkit-tap-highlight-color: transparent;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 500px;
    margin: 0 auto;
    padding: 0 16px;
    overflow: hidden;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stats {
    display: flex;
    gap: 12px;
    font-size: 0.875rem;
}

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

.stat-value {
    font-weight: 700;
    min-width: 1.5em;
    text-align: center;
}

.stat.correct .stat-value {
    color: var(--light-green);
}

.stat.wrong .stat-value {
    color: var(--light-red);
}

/* Game Area */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 12px 0;
    gap: 8px;
    min-height: 0;
    overflow: hidden;
}

.section-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-align: center;
}

/* Cards Container */
.cards {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    min-height: 0;
    flex-wrap: nowrap;
    perspective: 1000px;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 16px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar but keep functionality */
.cards::-webkit-scrollbar {
    display: none;
}

.cards {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Center cards when they fit */
.cards::before,
.cards::after {
    content: '';
    flex: 1;
}

.cards .card {
    flex-shrink: 0;
    scroll-snap-align: center;
}

/* Card Styles */
.card {
    width: 55px;
    height: 80px;
    background: var(--card-white);
    border-radius: 6px;
    box-shadow: 0 4px 12px var(--card-shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 6px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: dealCard 0.4s ease-out backwards;
}

.card:nth-child(1) { animation-delay: 0s; }
.card:nth-child(2) { animation-delay: 0.15s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(4) { animation-delay: 0.45s; }
.card:nth-child(5) { animation-delay: 0.6s; }
.card:nth-child(6) { animation-delay: 0.75s; }
.card:nth-child(7) { animation-delay: 0.9s; }

@keyframes dealCard {
    from {
        opacity: 0;
        transform: translateY(-50px) rotateX(30deg) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotateX(0) scale(1);
    }
}

.card.red {
    color: #c41e3a;
}

.card.black {
    color: #1a1a2e;
}

.card-corner {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.card-corner.top-left {
    align-self: flex-start;
}

.card-corner.bottom-right {
    align-self: flex-end;
    transform: rotate(180deg);
}

.card-value {
    font-size: 1rem;
    font-weight: 700;
}

.card-suit {
    font-size: 0.875rem;
}

.card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
}

/* Face-down card */
.card.face-down {
    background: linear-gradient(135deg, #1a3a5c 0%, #2d5a87 50%, #1a3a5c 100%);
    background-size: 200% 200%;
}

.card.face-down::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.card.face-down::after {
    content: '♠♥♦♣';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.6rem;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.3);
}

/* Card flip animation */
.card.flipping {
    animation: flipCard 0.6s ease-in-out;
}

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

/* Hand Value */
.hand-value {
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 6px;
    min-height: 28px;
    transition: transform 0.2s ease;
}

.hand-value.highlight {
    animation: pulse 0.3s ease;
}

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

.hand-value .soft-indicator {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-muted);
}

/* Feedback */
.feedback-container {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feedback {
    text-align: center;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.875rem;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.feedback.show {
    opacity: 1;
    transform: scale(1);
}

.feedback.correct {
    background: rgba(40, 167, 69, 0.2);
    border: 2px solid var(--green);
    color: var(--light-green);
}

.feedback.wrong {
    background: rgba(220, 53, 69, 0.2);
    border: 2px solid var(--red);
    color: var(--light-red);
}

.feedback.info {
    background: rgba(255, 215, 0, 0.15);
    border: 2px solid var(--gold);
    color: var(--gold);
}

.feedback-detail {
    font-size: 0.875rem;
    font-weight: 400;
    margin-top: 4px;
    opacity: 0.9;
}

/* Action Buttons */
.actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    flex-shrink: 0;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 12px 10px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
}

.action-btn:active {
    transform: scale(0.95);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: 1.125rem;
}

.hit-btn {
    background: linear-gradient(180deg, #4dabf7 0%, #339af0 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(77, 171, 247, 0.4);
}

.hit-btn:active:not(:disabled) {
    box-shadow: 0 2px 6px rgba(77, 171, 247, 0.4);
}

.stand-btn {
    background: linear-gradient(180deg, #ffd43b 0%, #fab005 100%);
    color: #1a1a2e;
    box-shadow: 0 4px 12px rgba(255, 212, 59, 0.4);
}

.stand-btn:active:not(:disabled) {
    box-shadow: 0 2px 6px rgba(255, 212, 59, 0.4);
}

.double-btn {
    background: linear-gradient(180deg, #69db7c 0%, #40c057 100%);
    color: #1a1a2e;
    box-shadow: 0 4px 12px rgba(105, 219, 124, 0.4);
}

.double-btn:active:not(:disabled) {
    box-shadow: 0 2px 6px rgba(105, 219, 124, 0.4);
}

.split-btn {
    background: linear-gradient(180deg, #da77f2 0%, #be4bdb 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(218, 119, 242, 0.4);
}

.split-btn:active:not(:disabled) {
    box-shadow: 0 2px 6px rgba(218, 119, 242, 0.4);
}

/* New Hand Button */
.new-hand-container {
    display: none;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    flex-shrink: 0;
}

.new-hand-container.show {
    display: block;
}

.new-hand-btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(180deg, #ffffff 0%, #e9ecef 100%);
    color: var(--dark-green);
    font-family: inherit;
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.new-hand-btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Start Screen */
.start-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--dark-green) 0%, var(--primary-green) 50%, var(--dark-green) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.start-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.start-content {
    text-align: center;
    padding: 32px;
    max-width: 320px;
}

.start-content h2 {
    font-size: 1.75rem;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.start-content p {
    font-size: 1.125rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.start-content .subtitle {
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 32px;
}

.start-btn {
    padding: 18px 48px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(180deg, var(--gold) 0%, #e6b800 100%);
    color: var(--dark-green);
    font-family: inherit;
    font-size: 1.25rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

.start-btn:active {
    transform: scale(0.95);
    box-shadow: 0 3px 10px rgba(255, 215, 0, 0.4);
}

/* Responsive adjustments for larger screens */
/* Only increase card size on taller screens */
@media (min-height: 700px) and (min-width: 380px) {
    .card {
        width: 65px;
        height: 95px;
        padding: 6px;
    }
    
    .card-value {
        font-size: 1rem;
    }
    
    .card-suit {
        font-size: 0.875rem;
    }
    
    .card-center {
        font-size: 2rem;
    }
    
    .game-area {
        padding: 16px 0;
        gap: 12px;
    }
    
    .action-btn {
        padding: 14px 12px;
        font-size: 0.9375rem;
    }
    
    .hand-value {
        font-size: 1.375rem;
        margin-top: 10px;
    }
    
    .feedback-container {
        min-height: 70px;
    }
}

@media (min-height: 800px) and (min-width: 400px) {
    .card {
        width: 70px;
        height: 100px;
    }
    
    .game-area {
        padding: 20px 0;
    }
    
    .action-btn {
        padding: 16px 12px;
        font-size: 1rem;
    }
}

@media (min-width: 500px) {
    .app {
        padding: 0 24px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .card {
        width: 85px;
        height: 120px;
    }
}

/* Dark mode preference */
@media (prefers-color-scheme: dark) {
    .card {
        background: #f8f9fa;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .card,
    .feedback,
    .hand-value,
    .action-btn,
    .start-screen {
        animation: none;
        transition: none;
    }
}

/* Dealer/Player sections */
.dealer-section,
.player-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    min-height: 0;
    overflow: visible;
}

/* Blackjack indicator */
.blackjack-indicator {
    display: inline-block;
    background: linear-gradient(90deg, var(--gold), #ffeaa7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Bust indicator */
.bust-indicator {
    color: var(--light-red);
    font-weight: 700;
}

/* Card highlight for new cards */
.card.new-card {
    animation: dealCard 0.4s ease-out, glow 0.5s ease-out 0.4s;
}

@keyframes glow {
    0% { box-shadow: 0 4px 12px var(--card-shadow), 0 0 20px rgba(255, 215, 0, 0.5); }
    100% { box-shadow: 0 4px 12px var(--card-shadow); }
}

/* ============================================
   SETTINGS DROPDOWN
   ============================================ */

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-container {
    position: relative;
}

.settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.settings-btn:active {
    transform: scale(0.95);
}

.settings-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: #1a1a2e;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 50;
}

.settings-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.9375rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dropdown-item:active {
    background: rgba(255, 255, 255, 0.15);
}

.dropdown-icon {
    font-size: 1.125rem;
}

/* ============================================
   STRATEGY CHART MODAL
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    overflow-y: auto;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #1a1a2e;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    background: #1a1a2e;
    z-index: 1;
}

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-light);
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 16px;
}

/* Strategy Chart Tables */
.chart-section {
    margin-bottom: 24px;
}

.chart-section:last-child {
    margin-bottom: 0;
}

.chart-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 12px;
    text-align: center;
}

.strategy-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.6875rem;
    table-layout: fixed;
}

.strategy-table th,
.strategy-table td {
    padding: 6px 2px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.strategy-table th {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.625rem;
}

.strategy-table .row-header {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    font-weight: 600;
}

/* Cell colors by action */
.strategy-table td.hit {
    background: #4dabf7;
    color: white;
}

.strategy-table td.stand {
    background: #fab005;
    color: #1a1a2e;
}

.strategy-table td.double {
    background: #40c057;
    color: #1a1a2e;
}

.strategy-table td.split {
    background: #be4bdb;
    color: white;
}

/* Chart Legend */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.legend-color.hit {
    background: #4dabf7;
}

.legend-color.stand {
    background: #fab005;
}

.legend-color.double {
    background: #40c057;
}

.legend-color.split {
    background: #be4bdb;
}

/* ============================================
   CONTENT SECTION
   ============================================ */

.content-section {
    background: var(--dark-green);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 48px 16px;
}

.content-wrapper {
    max-width: 640px;
    margin: 0 auto;
}

.content-section h2 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 16px;
}

.content-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 12px;
}

.content-section p {
    font-size: 1rem;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.85);
}

.strategy-tips {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.strategy-tips .tip {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 16px;
}

.strategy-tips .tip h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.strategy-tips .tip p {
    font-size: 0.875rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.75);
}

.tips-list {
    margin-top: 12px;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tips-list li {
    font-size: 1rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.85);
}

.how-to-list {
    margin-top: 12px;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.how-to-list li {
    font-size: 1rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.85);
}

.how-to-list ul {
    margin-top: 8px;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.how-to-list ul li {
    font-size: 0.9375rem;
}

/* ============================================
   FAQ SECTION
   ============================================ */

.faq-section {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.faq-item {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: background 0.2s ease;
}

.faq-item[open] {
    background: rgba(255, 255, 255, 0.04);
}

.faq-item summary {
    padding: 16px 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    -webkit-user-select: none;
    user-select: none;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.25rem;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.faq-item[open] summary::after {
    content: '−';
}

.faq-answer {
    padding: 0 20px 16px;
}

.faq-answer p {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.75);
}

@media (max-width: 500px) {
    .strategy-tips {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   FOOTER
   ============================================ */

.site-footer {
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 24px 16px;
    text-align: center;
}

.site-footer p {
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.5);
}

/* Responsive adjustments for chart */
@media (min-width: 400px) {
    .strategy-table {
        font-size: 0.75rem;
    }
    
    .strategy-table th {
        font-size: 0.6875rem;
    }
    
    .strategy-table th,
    .strategy-table td {
        padding: 8px 4px;
    }
}
