:root {
    --red: #e63946;
    --black: #1d3557;
    --card-bg: #ffffff;
    --accent: #007bff;
    --success: #28a745;
    --hint-bg: #fff3cd;
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    min-height: 100vh; 
    background: #f8f9fa; 
    margin: 0; 
    padding: 15px; 
    box-sizing: border-box;
}

#container { 
    width: 100%; 
    max-width: 400px; 
    text-align: center; 
}

/* Setup Screens */
.mode-selector { 
    display: flex; 
    background: #eee; 
    border-radius: 12px; 
    padding: 4px; 
    margin-bottom: 20px; 
}

.mode-btn { 
    flex: 1; 
    padding: 10px; 
    border: none; 
    border-radius: 10px; 
    cursor: pointer; 
    font-weight: 600; 
    background: transparent; 
    transition: 0.2s; 
    font-size: 0.9rem; 
}

.mode-btn.active { 
    background: white; 
    box-shadow: 0 2px 6px rgba(0,0,0,0.1); 
    color: var(--accent); 
}

.input-group { 
    background: white; 
    padding: 15px; 
    border-radius: 15px; 
    margin-bottom: 15px; 
    border: 1px solid #eee; 
    text-align: left; 
}

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

input[type="number"] { 
    border: 2px solid #eee; 
    border-radius: 8px; 
    padding: 8px; 
    font-size: 1rem; 
    width: 100%; 
    box-sizing: border-box; 
    margin-top: 5px; 
}

/* Mobile-friendly Touch Range Slider Customization */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 12px;
    background: #ddd;
    border-radius: 8px;
    outline: none;
    margin: 15px 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    border: none;
}

/* Running Counters Layout */
.live-counter {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--black);
    background: #e2e8f0;
    display: inline-block;
    padding: 4px 14px;
    border-radius: 30px;
    margin-bottom: 5px;
    letter-spacing: 0.5px;
}

/* Playing Card Component & Flipping Engine */
.card { 
    width: 240px; 
    height: 340px; 
    margin: 15px auto; 
    position: relative; 
    perspective: 1000px; 
}

.card-inner { 
    width: 100%; 
    height: 100%; 
    position: relative; 
    transform-style: preserve-3d; 
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    cursor: pointer; 
}

.card-inner.flipped {
    transform: rotateY(180deg);
}

.card-face { 
    position: absolute; 
    width: 100%; 
    height: 100%; 
    backface-visibility: hidden; 
    border-radius: 15px; 
    box-shadow: 0 8px 20px rgba(0,0,0,0.12); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    background: var(--card-bg); 
    border: 1px solid #e0e0e0; 
    box-sizing: border-box; 
}

.card-back { 
    background: var(--black); 
    background-image: radial-gradient(#457b9d 1px, transparent 0); 
    background-size: 8px 8px; 
    transform: rotateY(180deg); 
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cardBackContent {
    width: 100%;
    text-align: left;
    background: rgba(29, 53, 87, 0.95);
    border: 2px solid #457b9d;
    border-radius: 12px;
    padding: 16px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.hint-line { 
    margin: 8px 0; 
    color: #f8f9fa;
    font-size: 1.1rem;
}

.hint-highlight { 
    font-weight: bold; 
    color: #ffc107; 
}

/* 4-Corner Indices Layout */
.corner { 
    position: absolute; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    font-size: 1.3rem; 
    font-weight: bold; 
    line-height: 1.05; 
}
.corner.tl { top: 12px; left: 12px; }
.corner.tr { top: 12px; right: 12px; }
.corner.bl { bottom: 12px; left: 12px; transform: rotate(180deg); }
.corner.br { bottom: 12px; right: 12px; transform: rotate(180deg); }

/* Central Pip Positioning Matrix */
.pips-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(5, 1fr);
    width: 120px;
    height: 250px; /* Locked change preserved */
    margin: auto;
    align-items: center;
    justify-items: center;
}

.pip {
    font-size: 3rem; /* Locked change preserved */
    line-height: 1;
}

/* Court Card Central Emblem */
.court-card-center {
    font-size: 4rem;
    font-weight: 800;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 0.9;
    border: 3px dashed currentColor;
    border-radius: 12px;
    width: 95px;
    height: 145px;
    opacity: 0.25;
}

.court-card-center .court-suit {
    font-size: 2.5rem; 
    margin-top: 6px;
}

/* Timers & Utility Elements */
.timer-container { 
    width: 100%; 
    height: 8px; 
    background: #e0e0e0; 
    border-radius: 4px; 
    margin-bottom: 10px; 
    overflow: hidden; 
}

#timerBar { 
    width: 0%; 
    height: 100%; 
    background: var(--accent); 
    transition: width 0.05s linear; 
}

.hidden { display: none !important; }

/* Buttons */
.btn-main { 
    background: var(--success); 
    color: white; 
    border: none; 
    padding: 18px; 
    border-radius: 50px; 
    font-size: 1.2rem; 
    font-weight: 700; 
    width: 100%; 
    cursor: pointer; 
    box-shadow: 0 4px 12px rgba(40,167,69,0.2); 
    margin-top: 10px; 
}

.btn-hint { 
    background: #ffc107; 
    color: #212529; 
    border: none; 
    padding: 12px; 
    border-radius: 8px; 
    font-weight: bold; 
    margin-bottom: 10px; 
    cursor: pointer; 
    width: 100%; 
    font-size: 1rem; 
}

.btn-warning { 
    background: #ffc107; 
    color: #212529; 
}

/* Metrics Dashboard Panel */
.stats-panel {
    background: #e9ecef; 
    padding: 14px; 
    border-radius: 10px; 
    margin-bottom: 20px; 
    font-size: 1rem; 
    text-align: left; 
    display: flex; 
    justify-content: space-between;
    box-sizing: border-box;
    border: 1px solid #ddd;
}

/* Grids & Results Output Tables */
.reveal-grid { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 10px; 
    margin: 20px 0; 
}

.mini-card { 
    height: 100px; 
    background: var(--black); 
    border-radius: 8px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    color: white; 
    cursor: pointer; 
    font-weight: bold; 
    position: relative; 
}

.mini-card.revealed { 
    background: white; 
    color: var(--black); 
    border: 1px solid #ddd; 
}

table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 20px; 
    background: white; 
    border-radius: 12px; 
    overflow: hidden; 
}

th, td { 
    padding: 12px 10px; 
    border-bottom: 1px solid #f0f0f0; 
    text-align: left; 
    font-size: 0.85rem; 
}

.pao-label { 
    display: block; 
    font-size: 0.65rem; 
    color: #999; 
    font-weight: bold; 
    text-transform: uppercase; 
}

.red-suit { color: var(--red); }
.black-suit { color: var(--black); }
.wrong { background: #fff5f5; }