/* ==========================================================================
   Cat Go - Design System & Stylesheet
   Theme: Rich Dark Slate & Warm Wood with Glassmorphism & Gold Accents
   ========================================================================== */

:root {
    --bg-dark: #090d16;
    --bg-gradient: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #0f172a 50%, #090d16 100%);
    --card-bg: rgba(30, 41, 59, 0.75);
    --card-border: rgba(255, 255, 255, 0.12);
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --accent-gold: #f59e0b;
    --accent-gold-hover: #d97706;
    --accent-purple: #8b5cf6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    
    /* Board colors */
    --board-bg-gradient: radial-gradient(circle at 50% 50%, #eab308 0%, #d97706 50%, #b45309 100%);
    --board-line-color: #451a03;
    --board-star-color: #292524;
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-glass: 0 20px 40px rgba(0, 0, 0, 0.45);
    --font-heading: 'Fredoka', cursive, sans-serif;
    --font-body: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-dark);
    background-image: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1.5rem;
    overflow-x: hidden;
}

/* Ambient glow blobs */
.ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.25;
    pointer-events: none;
    z-index: 0;
}

.glow-1 {
    top: -10%;
    left: 10%;
    width: 450px;
    height: 450px;
    background: #8b5cf6;
}

.glow-2 {
    bottom: -10%;
    right: 10%;
    width: 500px;
    height: 500px;
    background: #f59e0b;
}

/* Glassmorphism Panel Utility */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-glass);
}

.app-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 960px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
}

.logo-paw {
    color: var(--accent-gold);
    animation: pawBounce 2s infinite ease-in-out;
}

@keyframes pawBounce {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-4px) rotate(-8deg); }
}

.logo-sub {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--accent-gold);
    background: rgba(245, 158, 11, 0.15);
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    border: 1px solid rgba(245, 158, 11, 0.3);
    margin-left: 0.5rem;
    vertical-align: middle;
}

.header-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

/* Buttons */
.btn {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-gold) 0%, var(--accent-gold-hover) 100%);
    color: #1e1b4b;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.45);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.35);
    transform: translateY(-2px);
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
}

/* Main Arena Layout */
.game-arena {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Emmy AI Section */
.emmy-section {
    display: flex;
    align-items: center;
    padding: 1.25rem;
    gap: 1.25rem;
}

.emmy-avatar-container {
    position: relative;
    width: 90px;
    height: 90px;
    flex-shrink: 0;
}

.emmy-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--accent-gold);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

.status-indicator {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    background: var(--accent-green);
    border: 3px solid #1e293b;
    border-radius: 50%;
}

.status-indicator.active {
    box-shadow: 0 0 10px var(--accent-green);
    animation: statusPulse 1.5s infinite;
}

@keyframes statusPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.8; }
}

.emmy-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.emmy-name-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.emmy-name {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--text-primary);
}

.badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-weight: 600;
}

.badge-ai {
    background: rgba(139, 92, 246, 0.2);
    color: #c084fc;
    border: 1px solid rgba(139, 92, 246, 0.4);
}

.badge-color {
    background: rgba(245, 158, 11, 0.2);
    color: #fde047;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

/* Speech Bubble */
.speech-bubble-container {
    position: relative;
}

.speech-bubble {
    position: relative;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 0.85rem 1.1rem;
    border-radius: 14px;
    font-size: 0.95rem;
    line-height: 1.45;
    color: #e2e8f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.speech-bubble p {
    margin: 0;
    font-style: italic;
}

.bubble-arrow {
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 10px solid rgba(15, 23, 42, 0.9);
}

/* Status Bar & Scoreboard */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    gap: 1rem;
}

.player-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 140px;
}

.player-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
}

.player-color {
    font-size: 0.85rem;
    color: var(--accent-gold);
    font-weight: 600;
}

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

.turn-center {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.status-text {
    font-weight: 600;
    font-size: 1rem;
    color: #f1f5f9;
}

.resume-badge {
    font-size: 0.75rem;
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.4);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}

.hidden {
    display: none !important;
}

/* Controls Bar */
.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
}

.board-size-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.select-input {
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
}

.select-input:focus {
    outline: 1px solid var(--accent-gold);
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

/* The Go Board Wrapper */
.board-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.go-board-container {
    position: relative;
    width: 100%;
    max-width: 580px;
    aspect-ratio: 1 / 1;
    background: var(--board-bg-gradient);
    border-radius: var(--radius-md);
    border: 4px solid #78350f;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5), 0 15px 35px rgba(0, 0, 0, 0.6);
    user-select: none;
    overflow: hidden;
}

/* SVG Go Board inside Container */
.go-board-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Intersections & Click Targets */
.intersection-target {
    cursor: pointer;
}

.intersection-target:hover .hover-stone {
    opacity: 0.5;
}

/* Stones Styling */
.stone {
    transition: transform 0.15s ease-out;
    filter: drop-shadow(2px 4px 5px rgba(0, 0, 0, 0.6));
}

.stone-black {
    fill: url(#blackStoneGrad);
    stroke: #334155;
    stroke-width: 0.5;
}

.stone-white {
    fill: url(#whiteStoneGrad);
    stroke: #cbd5e1;
    stroke-width: 0.5;
}

.stone-paw {
    pointer-events: none;
}

.stone-paw-black {
    fill: #f59e0b;
}

.stone-paw-white {
    fill: #475569;
}

.last-move-ring {
    fill: none;
    stroke: #ef4444;
    stroke-width: 2;
    animation: ringPulse 1.5s infinite;
}

@keyframes ringPulse {
    0%, 100% { stroke-opacity: 0.9; stroke-width: 2; }
    50% { stroke-opacity: 0.4; stroke-width: 3; }
}

/* Game Log Section */
.log-container {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--accent-gold);
}

.log-content-wrapper {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    height: 150px;
    max-height: 220px;
    overflow-y: auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(245, 158, 11, 0.4) rgba(15, 23, 42, 0.5);
}

/* Custom Scrollbar for Game Log & Scrollable Areas */
.log-content-wrapper::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 7px;
}

.log-content-wrapper::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 4px;
}

.log-content-wrapper::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(245, 158, 11, 0.4);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.log-content-wrapper::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(245, 158, 11, 0.75);
}

.log-content {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.85rem;
}

.log-entry {
    line-height: 1.4;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
    padding: 0.3rem 0.4rem;
    border-radius: 4px;
    animation: fadeInLog 0.25s ease-out;
    transition: background 0.15s ease;
}

.log-entry:hover {
    background: rgba(255, 255, 255, 0.04);
}

@keyframes fadeInLog {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.log-placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* Modals */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.modal-backdrop.active {
    display: flex;
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 580px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 1.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--accent-gold);
    margin-bottom: 1rem;
}

.modal-body {
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #cbd5e1;
    padding-right: 0.5rem;
}

.modal-body h3 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    margin: 1rem 0 0.4rem 0;
    font-size: 1.1rem;
}

.modal-body ul {
    margin-left: 1.2rem;
    margin-bottom: 0.8rem;
}

.modal-body li {
    margin-bottom: 0.4rem;
}

.modal-footer {
    margin-top: 1.25rem;
    display: flex;
    justify-content: flex-end;
}

/* Games List in More Modal */
.games-list {
    list-style: none;
    margin: 0 !important;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.games-list li a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.8rem;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.games-list li a:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--accent-gold);
    transform: translateY(-2px);
}

.game-favicon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

/* Footer */
.app-footer {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 0.5rem 0;
}

/* Responsive Media Queries */
@media (max-width: 640px) {
    body {
        padding: 0.75rem;
    }
    
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .emmy-section {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }

    .bubble-arrow {
        left: 50%;
        top: -10px;
        transform: translateX(-50%);
        border-right: 8px solid transparent;
        border-left: 8px solid transparent;
        border-bottom: 10px solid rgba(15, 23, 42, 0.9);
        border-top: none;
    }

    .status-bar {
        flex-direction: column;
        text-align: center;
    }

    .player-card {
        align-items: center;
    }

    .controls-bar {
        flex-direction: column;
        gap: 0.75rem;
    }
}


/* Sound / Mute Toggle Button */
.sound-toggle-btn, #sound-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
  box-sizing: border-box;
}
@media (max-width: 600px) {
  .sound-toggle-btn, #sound-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    font-size: 0.85rem;
  }
}

/* Clear visual distinction for Muted state */
.sound-toggle-btn.muted, #sound-btn.muted {
  opacity: 0.55 !important;
  background: rgba(20, 20, 25, 0.7) !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
  color: #94a3b8 !important;
  box-shadow: none !important;
}
