:root {
    --color-bg: #0f172a;
    --color-surface: rgba(30, 41, 59, 0.7);
    --color-surface-hover: rgba(51, 65, 85, 0.9);
    --color-primary: #0ea5e9;
    --color-primary-glow: rgba(14, 165, 233, 0.5);
    --color-secondary: #f43f5e;
    --color-secondary-glow: rgba(244, 63, 94, 0.5);
    --color-text: #f8fafc;
    --color-text-dim: #94a3b8;
    --font-main: 'Outfit', 'Noto Sans JP', sans-serif;

    --card-width: 80px;
    --card-height: 112px;
    --card-border-radius: 8px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--color-bg);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(14, 165, 233, 0.15), transparent 40%),
        radial-gradient(circle at 85% 30%, rgba(244, 63, 94, 0.15), transparent 40%);
    color: var(--color-text);
    overflow: hidden;
    /* Prevent scrolling for app feel */
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    zoom: 0.8;
}

#app {
    position: relative;
    width: 100%;
    max-width: 1400px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 10;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

/* ==================== Modal & Menu ==================== */
.menu-content,
.modal-content {
    margin: auto;
    text-align: center;
    z-index: 20;
    background: var(--color-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 3rem;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-width: 600px;
    width: 90%;
}

.title {
    font-size: 4rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.vs {
    font-size: 2rem;
    font-weight: 600;
    color: var(--color-text-dim);
    -webkit-text-fill-color: initial;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--color-text-dim);
    margin-bottom: 3rem;
}

.menu-actions,
.choice-actions {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.player-select-container {
    margin-bottom: 2rem;
    font-size: 1.1rem;
    color: var(--color-text);
}

.player-select {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(30, 41, 59, 0.8);
    color: white;
    font-family: var(--font-main);
    cursor: pointer;
    margin-left: 0.5rem;
}

.player-select option {
    background: #1e293b;
}

.variant-rule-container {
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.custom-checkbox {
    width: 1.2rem;
    height: 1.2rem;
    cursor: pointer;
}

.checkbox-label {
    font-size: 1rem;
    color: var(--color-text-dim);
    cursor: pointer;
}

.btn {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-main);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}

.primary-btn {
    background: linear-gradient(135deg, var(--color-primary), #3b82f6);
    color: white;
    box-shadow: 0 4px 15px var(--color-primary-glow);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--color-primary-glow);
    filter: brightness(1.1);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.rules-content {
    text-align: left;
    max-height: 80vh;
    overflow-y: auto;
}

.rules-text {
    margin: 1.5rem 0;
    line-height: 1.6;
    font-size: 0.95rem;
}

.rules-text ul {
    margin: 0.5rem 0 1rem 1.5rem;
}

.rules-text p {
    margin-bottom: 0.5rem;
}

/* ==================== Game Layout ==================== */
#screen-game {
    padding: 1rem;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 1rem;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--color-surface);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-weight: 600;
}

.phase-indicator {
    font-size: 1.2rem;
    color: var(--color-primary);
    text-shadow: 0 0 10px var(--color-primary-glow);
}

.game-board {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto auto;
    gap: 1rem 1.5rem;
    justify-items: center;
    align-items: center;
    border-radius: 24px;
    background: radial-gradient(circle, rgba(30, 41, 59, 0.4) 0%, transparent 70%);
    padding: 1.5rem;
}

/* Opponent placements */
.opponent {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--color-surface);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.opponent-top {
    grid-area: 1 / 1 / 2 / 2;
    justify-self: end;
}

.opponent-left {
    grid-area: 2 / 1 / 3 / 2;
    justify-self: end;
}

.opponent-right {
    grid-area: 1 / 3 / 2 / 4;
    justify-self: start;
}

.opponent-top-right {
    grid-area: 2 / 3 / 3 / 4;
    justify-self: start;
}

.opponent.hidden {
    display: none !important;
}

.opp-info {
    font-weight: 700;
    font-size: 1rem;
}

.opp-stats {
    font-size: 0.8rem;
    color: var(--color-text-dim);
}

.score-badge {
    color: #fbbf24;
    margin-left: 0.5rem;
}

/* Central Field */
.central-field {
    grid-area: 1 / 2 / 3 / 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: 440px;
}

.field-zone {
    width: 100%;
    min-height: calc(var(--card-height) + 40px);
    padding: 1rem;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.market-zone {
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed rgba(255, 255, 255, 0.2);
}

.pending-zone {
    background: rgba(0, 0, 0, 0.1);
    border: 1px dashed rgba(255, 255, 255, 0.1);
}

.zone-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-dim);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.market-cards,
.pending-cards {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    padding: 0.5rem;
}

.market-cards .card,
.pending-cards .card {
    margin-right: -40px;
    box-shadow: -4px 0 10px rgba(0, 0, 0, 0.5);
}

.market-cards .card:last-child,
.pending-cards .card:last-child {
    margin-right: 0;
}

.field-stats {
    display: flex;
    width: 100%;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
}

.stat-box {
    text-align: center;
    font-size: 0.8rem;
    color: var(--color-text-dim);
}

.stat-box span.highlight {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--color-text);
}

.round-progress-container {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.round-progress-text {
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.5rem;
}

.highlight-urgent {
    color: #fca5a5;
    font-size: 1.5rem;
    font-weight: 900;
    text-shadow: 0 0 10px rgba(248, 113, 113, 0.5);
}

.progress-bar-bg {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #fbbf24, #f43f5e);
    border-radius: 6px;
    transition: width 0.3s ease;
}

.market-ratio {
    font-size: 1.5rem;
    font-weight: 800;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.white-text {
    color: #f8fafc;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.red-text {
    color: var(--color-secondary);
    text-shadow: 0 0 10px var(--color-secondary-glow);
}

/* Player Area */
.player-area {
    background: var(--color-surface);
    border-radius: 24px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-info {
    font-size: 1.2rem;
    font-weight: 800;
}

.action-prompt {
    color: #fbbf24;
    font-weight: 600;
    animation: pulse 2s infinite;
}

.player-zones {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.dropzone {
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 1rem;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.dropzone.active-target {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.dropzone.active-target:hover {
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
}

.zone-central-drop {
    border-color: var(--color-primary);
    background: rgba(14, 165, 233, 0.05);
}

.zone-central-drop.active-target:hover {
    background: rgba(14, 165, 233, 0.15);
    box-shadow: 0 0 20px var(--color-primary-glow);
}

.zone-hand {
    margin-top: 1rem;
}

.cards-container {
    display: flex;
    gap: 0.5rem;
    min-height: var(--card-height);
    flex-wrap: wrap;
}

/* ==================== Cards ==================== */
.card {
    width: var(--card-width);
    height: var(--card-height);
    border-radius: var(--card-border-radius);
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
}

.card:active {
    cursor: grabbing;
}

.card.selectable {
    cursor: pointer;
}

.card.selectable:hover,
.card.selected {
    transform: translateY(-10px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.5);
}

.card.selected {
    border-color: #fbbf24;
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.5);
}

/* Card faces */
.card.back {
    background-image: url('./images/back.jpg');
    background-size: cover;
    background-position: center;
    border: 1px solid #334155;
}

.card.back::after {
    /* Clear text since image handled it */
    content: '';
}

.card.white {
    background-image: url('./images/bull.jpg');
    background-size: cover;
    background-position: center;
    border: 1px solid #e2e8f0;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.card.white::after {
    /* Clear text since image handled it */
    content: '';
}

.card.red {
    background-image: url('./images/bear.jpg');
    background-size: cover;
    background-position: center;
    border: 1px solid #fb7185;
    box-shadow: 0 0 10px rgba(244, 63, 94, 0.3);
}

.card.red::after {
    /* Clear text since image handled it */
    content: '';
}

.mini-card {
    width: 20px;
    height: 30px;
    background: #334155;
    border-radius: 2px;
    display: inline-block;
    margin: 0 2px;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* ==================== Results ==================== */
.result-content h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.1rem;
}

.score-row:last-child {
    border-bottom: none;
}

.score-row.winner {
    color: #fbbf24;
    font-weight: 800;
    background: rgba(251, 191, 36, 0.1);
    border-radius: 8px;
}