:root {
    --bg-color: #0f0c1b;
    --panel-bg: rgba(30, 25, 50, 0.6);
    --text-main: #f0f0f5;
    --text-muted: #8a84a6;
    --accent-gold: #d4af37;
    --accent-red: #e63946;
    --accent-blue: #457b9d;
    --card-bg: #ffffff;
    --card-text: #000000;
    --turn-glow: rgba(212, 175, 55, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at center, #1f1a30 0%, #0f0c1b 100%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    width: 100%;
    max-width: 1200px;
    height: 95vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    backdrop-filter: blur(10px);
    border-radius: 20px;
    background: var(--panel-bg);
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    position: relative;
    z-index: 1;
}

.game-header {
    text-align: center;
    margin-bottom: 5px;
    flex-shrink: 0;
}

.elegant-title {
    font-family: 'Yuji Syuku', 'Cinzel Decorative', serif;
    font-size: 42px;
    font-weight: 400;
    margin: 0;
    letter-spacing: 5px;
    background: linear-gradient(135deg, #fff5d7 0%, #d4af37 50%, #8c7322 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.4)) drop-shadow(0 4px 4px rgba(0,0,0,0.8));
    text-transform: uppercase;
}

#status-message {
    font-size: 16px;
    color: var(--text-muted);
    margin-top: 5px;
    height: 24px;
}

.play-area-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    width: 100%;
    overflow: hidden;
}

.center-vertical {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    height: 100%;
    padding: 0 20px;
}

/* Areas */
.opponent-side, .opponent-top, .player-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 10px;
    border-radius: 12px;
    transition: box-shadow 0.3s ease, background 0.3s ease;
}

/* Penalty Indicator */
.penalty-indicator {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(230, 57, 70, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    animation: pulse 2s infinite;
    z-index: 50;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

/* Active Turn Highlighting */
.active-turn {
    background: rgba(212, 175, 55, 0.05);
    box-shadow: 0 0 20px var(--turn-glow), inset 0 0 10px var(--turn-glow);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.active-turn .area-label {
    color: var(--accent-gold);
    font-weight: 800;
}

.opponent-side {
    width: 120px;
    height: 100%;
    justify-content: center;
}

.center-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    width: 100%;
    position: relative;
}

.area-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    text-align: center;
    transition: color 0.3s;
}

/* Hands */
.hand {
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
}

.north-hand {
    height: 140px;
}

.west-hand, .east-hand {
    flex-direction: column;
}

/* Card Styling */
.card {
    width: 70px;
    height: 100px;
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: -2px 0 5px rgba(0,0,0,0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease, top 0.2s ease;
    user-select: none;
    border: 1px solid #ddd;
    color: var(--card-text);
}

.card.red {
    color: var(--accent-red);
}

.card.back {
    background: repeating-linear-gradient(45deg, #2a2240, #2a2240 10px, #1a1528 10px, #1a1528 20px);
    border: 2px solid white;
    color: transparent;
}

/* New Card Info Layout to show on overlap */
.card-corner {
    position: absolute;
    top: 4px;
    left: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 14px;
    font-weight: 900;
    line-height: 1.1;
}

.card-center {
    font-size: 32px;
    opacity: 0.15;
}

/* Player Card Interaction */
.player-hand {
    height: 140px;
    margin-bottom: 10px;
}

.player-hand .card {
    margin-left: -35px;
    cursor: grab;
}

.player-hand .card:first-child {
    margin-left: 0;
}

.player-hand .card:hover {
    transform: translateY(-15px) scale(1.05);
    z-index: 10;
    box-shadow: -5px 15px 15px rgba(0,0,0,0.4);
}

.player-hand .card.selected {
    transform: translateY(-20px);
    box-shadow: 0 0 15px var(--accent-gold);
    border-color: var(--accent-gold);
}

.player-hand .card:active {
    cursor: grabbing;
}

.player-hand.dragging-active .card:not(.dragging) {
    pointer-events: none;
}
.player-hand .card.dragging {
    opacity: 0.5;
}

/* Opponent card tight overlap styling */
.north-hand .card {
    margin-left: -55px; /* Tight overlap */
    cursor: default;
}
.north-hand .card:first-child {
    margin-left: 0;
}

.west-hand .card, .east-hand .card {
    margin-top: -85px; /* Vertical tight overlap */
    transform: rotate(90deg);
}
.west-hand .card:first-child, .east-hand .card:first-child {
    margin-top: 0;
}

/* Discard Pile Area (Drop Target) */
.discard-pile-container {
    width: 200px;
    height: 180px;
    border: 2px dashed rgba(255,255,255,0.2);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    transition: all 0.3s ease;
}

.discard-pile-container.drag-over {
    border-color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.1);
    transform: scale(1.05);
}

.discard-pile-container.drag-error {
    border-color: var(--accent-red);
    background: rgba(230, 57, 70, 0.1);
}

.drop-hint {
    position: absolute;
    color: var(--text-muted);
    font-size: 14px;
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.3s;
}

.discard-pile-container.drag-over .drop-hint {
    color: var(--accent-gold);
    opacity: 1;
}
.discard-pile-container.drag-error .drop-hint {
    color: var(--accent-red);
    content: "ルール違反！";
}

.discard-pile .card {
    position: absolute;
    margin-left: 0;
    transform-origin: center;
}

/* Graveyard Area (Cheat Target) */
.graveyard-container {
    width: 140px;
    height: 180px;
    border: 2px dashed rgba(138, 132, 166, 0.2);
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transition: all 0.3s ease;
    padding-top: 10px;
}

.graveyard-container.drag-over {
    border-color: var(--accent-red);
    background: rgba(230, 57, 70, 0.1);
    transform: scale(1.05);
}

.graveyard-pile {
    flex: 1;
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.graveyard-pile .card {
    position: absolute;
    margin: 0;
    transform-origin: center;
    filter: brightness(0.6);
}

/* Center Controls */
.center-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
    align-items: center;
    background: rgba(0,0,0,0.3);
    padding: 10px 20px;
    border-radius: 30px;
}

.action-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    font-size: 14px;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
}
.secondary-btn:not(:disabled):hover { background: rgba(255,255,255,0.1); color: white; }

.danger-btn {
    background: transparent;
    border: 2px solid var(--accent-red);
    color: var(--accent-red);
    box-shadow: 0 0 10px rgba(230, 57, 70, 0.3);
}
.danger-btn:not(:disabled) {
    animation: pulse 2s infinite;
}
.danger-btn:not(:disabled):hover {
    background: var(--accent-red);
    color: white;
    box-shadow: 0 0 20px rgba(230, 57, 70, 0.6);
}

/* Cut-in Overlay */
.cutin-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.cutin-overlay.show {
    opacity: 1;
}

.cutin-text {
    font-size: 80px;
    font-weight: 900;
    color: var(--accent-gold);
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.8), 0 0 40px rgba(212, 175, 55, 0.5);
    transform: scale(0.5);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin: 0;
}

.cutin-overlay.show .cutin-text {
    transform: scale(1) rotate(-5deg);
}

.cutin-overlay.failure .cutin-text {
    color: var(--accent-red);
    text-shadow: 0 0 20px rgba(230, 57, 70, 0.8), 0 0 40px rgba(230, 57, 70, 0.5);
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.cheat-anim {
    transition: transform 1.5s cubic-bezier(0.25, 0.1, 0.25, 1), opacity 1.5s ease !important;
    opacity: 0.5;
    z-index: 100;
}

/* Pass Indicator */
.pass-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: 900;
    color: var(--text-main);
    background: rgba(0,0,0,0.7);
    padding: 10px 20px;
    border-radius: 12px;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
}
.pass-indicator.show {
    opacity: 1;
    transform: translate(-50%, -60%);
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}
.modal-content {
    background: var(--panel-bg);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--accent-gold);
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}
.modal-content h3 {
    margin-bottom: 20px;
    color: var(--accent-gold);
}
.modal-card-list {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    padding: 10px;
}
.modal-card-list .card {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.modal-card-list .card:hover {
    transform: scale(1.1) translateY(-10px);
    box-shadow: 0 10px 20px rgba(212, 175, 55, 0.4);
    border-color: var(--accent-gold);
}
