:root {
    --bg-dark: #0d1117;
    --bg-card: #161e2b;
    --bg-card-header: #1e293b;
    --border-gold: #c69b4e;
    --border-gold-glow: rgba(198, 155, 78, 0.4);
    --gold-text: #e6ca85;
    --gold-light: #fbecc5;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    
    --accent-red: #ef4444;
    --accent-red-glow: rgba(239, 68, 68, 0.5);
    --accent-cyan: #0ea5e9;
    --accent-cyan-glow: rgba(14, 165, 233, 0.5);
    --accent-green: #10b981;
    --accent-green-glow: rgba(16, 185, 129, 0.4);
    --accent-amber: #f59e0b;
    --accent-purple: #a855f7;

    --board-bg: #2d1d12;
    --board-line: #a67c52;
    --point-empty: #453021;
    --point-hover: #634731;

    --font-heading: 'Cinzel', 'Trajan Pro', 'Georgia', serif;
    --font-ui: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 50% 15%, rgba(30, 41, 59, 0.8) 0%, rgba(13, 17, 23, 0.96) 80%),
        radial-gradient(circle at 85% 85%, rgba(198, 155, 78, 0.08) 0%, transparent 40%);
    color: var(--text-main);
    font-family: var(--font-ui);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header */
header {
    background: linear-gradient(180deg, #161c24 0%, #0f1216 100%);
    border-bottom: 2px solid var(--border-gold);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pirate-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 8px var(--border-gold));
}

.title-group h1 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    color: var(--gold-text);
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.title-group p {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.header-controls {
    display: flex;
    gap: 10px;
}

/* Container & Layout */
.app-container {
    flex: 1;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 390px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 960px) {
    .app-container {
        grid-template-columns: 1fr;
        padding: 12px;
    }
}

/* Board Area */
.board-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* Game Status Banner */
.status-banner {
    width: 100%;
    max-width: 580px;
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: 8px;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.status-text-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.turn-indicator-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

.dot-user {
    background: #e53e3e;
    box-shadow: 0 0 12px var(--accent-red-glow);
}

.dot-opponent {
    background: #2d3748;
    border-color: #cbd5e0;
    box-shadow: 0 0 12px rgba(200, 200, 200, 0.3);
}

.turn-title {
    font-size: 1.05rem;
    font-weight: 700;
    font-family: var(--font-heading);
    letter-spacing: 1px;
}

.turn-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.badge-user-turn {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid #ef4444;
}

.badge-opp-turn {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid #3b82f6;
}

/* Hand Pieces Counters */
.hand-status-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    max-width: 580px;
}

.hand-box {
    background: #131923;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
}

.hand-box.active-hand {
    border-color: var(--border-gold);
    background: #1c2433;
}

.hand-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.hand-count-badge {
    font-family: monospace;
    font-weight: bold;
    color: var(--gold-text);
}

/* Morris Board Canvas Container */
.morris-board-wrapper {
    position: relative;
    padding: 16px;
    background: #23160b;
    background-image: 
        repeating-linear-gradient(45deg, rgba(0,0,0,0.12) 0, rgba(0,0,0,0.12) 10px, transparent 10px, transparent 20px),
        linear-gradient(135deg, #382312 0%, #1c1007 100%);
    border-radius: 14px;
    box-shadow: 
        0 15px 40px rgba(0,0,0,0.85),
        inset 0 0 20px rgba(0,0,0,0.9),
        0 0 0 2px #5a3d24,
        0 0 0 6px #150b04;
}

.morris-svg-board {
    width: 540px;
    height: 540px;
    max-width: 90vw;
    max-height: 90vw;
    display: block;
    user-select: none;
}

@media (max-width: 600px) {
    .morris-svg-board {
        width: 340px;
        height: 340px;
    }
}

/* SVG Elements Styling */
.board-line {
    stroke: #8b5a2b;
    stroke-width: 5px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.board-point-slot {
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.point-circle-base {
    fill: #3b2413;
    stroke: #8b5a2b;
    stroke-width: 2px;
    transition: fill 0.2s, stroke 0.2s;
}

.board-point-slot:hover .point-circle-base {
    fill: #5c3b21;
    stroke: #d4a373;
}

/* Pieces */
.piece-red {
    fill: url(#redPieceGrad);
    stroke: #fca5a5;
    stroke-width: 2.5px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.6));
    cursor: pointer;
}

.piece-black {
    fill: url(#blackPieceGrad);
    stroke: #94a3b8;
    stroke-width: 2.5px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.8));
    cursor: pointer;
}

/* Suggestion & Action Glows on Points */
.point-suggest-src {
    stroke: #38bdf8 !important;
    stroke-width: 4px !important;
    animation: pulse-svg-src 1.5s infinite ease-in-out;
}

.point-suggest-dst {
    stroke: #34d399 !important;
    stroke-width: 4px !important;
    animation: pulse-svg-dst 1.5s infinite ease-in-out;
}

.point-suggest-remove {
    stroke: #f43f5e !important;
    stroke-width: 5px !important;
    animation: pulse-svg-remove 1.2s infinite ease-in-out;
}

.point-selected {
    stroke: #facc15 !important;
    stroke-width: 4px !important;
}

.point-legal-target {
    fill: #065f46 !important;
    stroke: #10b981 !important;
    stroke-width: 3px !important;
}

@keyframes pulse-svg-src {
    0%, 100% { stroke: #38bdf8; filter: drop-shadow(0 0 6px #0ea5e9); }
    50% { stroke: #bae6fd; filter: drop-shadow(0 0 16px #38bdf8); }
}

@keyframes pulse-svg-dst {
    0%, 100% { stroke: #34d399; filter: drop-shadow(0 0 6px #10b981); }
    50% { stroke: #a7f3d0; filter: drop-shadow(0 0 16px #34d399); }
}

@keyframes pulse-svg-remove {
    0%, 100% { stroke: #f43f5e; filter: drop-shadow(0 0 8px #ef4444); }
    50% { stroke: #fda4af; filter: drop-shadow(0 0 18px #f43f5e); }
}

/* Point label text */
.point-label {
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 700;
    fill: #f1f5f9;
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: central;
}

/* Quick Action Bar */
.board-quick-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 580px;
    justify-content: center;
}

/* Side Panel */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card {
    background: var(--bg-card);
    border: 1px solid #334155;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.card-header {
    background: var(--bg-card-header);
    border-bottom: 1px solid #334155;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: var(--gold-text);
    letter-spacing: 1px;
}

.card-body {
    padding: 16px;
}

/* Suggestion Card */
.suggestion-card {
    border: 1px solid var(--border-gold);
    background: linear-gradient(180deg, #1e2632 0%, #151a22 100%);
}

.suggestion-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.engine-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.engine-eval-badge {
    background: #0f172a;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--accent-green);
    border: 1px solid #1e293b;
}

.move-instruction-box {
    background: rgba(14, 165, 233, 0.1);
    border: 1px solid rgba(14, 165, 233, 0.3);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.move-icon-badge {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--accent-cyan);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 0 12px var(--accent-cyan-glow);
    flex-shrink: 0;
}

.move-text-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.move-text-details {
    font-size: 0.85rem;
    color: #93c5fd;
    margin-top: 2px;
}

.apply-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(180deg, #10b981 0%, #059669 100%);
    border: 1px solid #34d399;
    border-radius: 8px;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px var(--accent-green-glow);
    transition: transform 0.15s, filter 0.15s;
}

.apply-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.apply-btn:active {
    transform: translateY(1px);
}

/* History / Move Log */
.move-history-list {
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    padding-right: 4px;
}

.history-entry {
    display: grid;
    grid-template-columns: 32px 1fr 1fr;
    padding: 6px 10px;
    background: #11161f;
    border-radius: 4px;
    align-items: center;
}

.history-entry:nth-child(even) {
    background: #161d28;
}

.history-num {
    color: var(--text-muted);
    font-weight: 600;
}

.history-player {
    color: #f87171;
    font-weight: 500;
}

.history-opp {
    color: #94a3b8;
}

/* Buttons and Controls */
.btn {
    background: #2d3748;
    color: var(--text-main);
    border: 1px solid #4a5568;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
    background: #3a475c;
    border-color: var(--border-gold);
}

.btn-gold {
    background: linear-gradient(180deg, #d97706 0%, #b45309 100%);
    border: 1px solid var(--border-gold);
    color: #fff;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
}

.btn-gold:hover {
    filter: brightness(1.15);
}

.btn-danger {
    background: #7f1d1d;
    border-color: #ef4444;
    color: #fee2e2;
}

.btn-danger:hover {
    background: #991b1b;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.8rem;
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Modal Windows */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #19202a;
    border: 2px solid var(--border-gold);
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 20px var(--border-gold-glow);
    text-align: center;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.25s ease;
}

.modal-backdrop.active .modal-content {
    transform: scale(1);
}

.modal-title {
    font-family: var(--font-heading);
    color: var(--gold-text);
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.modal-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* Coin Toss Animation */
.coin-stage {
    perspective: 800px;
    width: 100px;
    height: 100px;
    margin: 0 auto 24px auto;
}

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

.coin.flipping {
    animation: flip-coin 1.5s ease-out forwards;
}

@keyframes flip-coin {
    0% { transform: rotateY(0deg) translateY(0); }
    50% { transform: rotateY(1080deg) translateY(-80px); }
    100% { transform: rotateY(2160deg) translateY(0); }
}

.coin-face {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: var(--font-heading);
    font-weight: bold;
    border: 4px solid #fef08a;
    box-shadow: 0 0 15px rgba(234, 179, 8, 0.5), inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.coin-heads {
    background: radial-gradient(circle, #eab308 0%, #a16207 100%);
    color: #451a03;
}

.coin-tails {
    background: radial-gradient(circle, #94a3b8 0%, #475569 100%);
    color: #0f172a;
    transform: rotateY(180deg);
}

.coin-face-icon {
    font-size: 32px;
}

.toss-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toss-btn {
    padding: 16px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.15s, border-color 0.15s;
}

.toss-btn:hover {
    transform: translateY(-2px);
}

.toss-btn-user {
    background: linear-gradient(90deg, #991b1b 0%, #7f1d1d 100%);
    border: 2px solid #ef4444;
    color: #fff;
}

.toss-btn-opp {
    background: linear-gradient(90deg, #1e293b 0%, #0f172a 100%);
    border: 2px solid #64748b;
    color: #e2e8f0;
}

/* Edit Mode Bar */
.edit-mode-indicator {
    display: none;
    background: #854d0e;
    color: #fef08a;
    border: 1px solid #facc15;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
}

.edit-mode-indicator.active {
    display: block;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #0f172a;
    border: 1px solid var(--border-gold);
    color: var(--gold-light);
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    font-weight: 600;
    z-index: 2000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}
