@import url('https://fonts.googleapis.com/css2?family=Cabin+Sketch:wght@400;700&family=Fredericka+the+Great&display=swap');

/* Base Styles */
:root {
    /* Ghibli Rustic Theme Colors (Warm, Organic, Parchment) */
    --glass-bg: rgba(244, 236, 216, 0.85); /* Warm parchment paper */
    --glass-border: rgba(139, 69, 19, 0.3); /* Brownish ink border */
    --text-main: #3e2723; /* Dark brown ink */
    --magic-gold: #b45309; /* Deep amber/gold */
    
    /* Player colours (Vibrant but grounded) */
    --ink-blue: #1d4ed8;   /* Deep Blue */
    --ink-red: #b91c1c;    /* Deep Red */
    --ink-green: #15803d;  /* Forest Green */
    --ink-yellow: #a16207; /* Dark Gold */
    
    --goti-size: 28px;
    
    --font-handwriting: 'Cabin Sketch', cursive; /* Sketched chalk/charcoal look */
    --font-marker: 'Fredericka the Great', cursive; /* Highly textured sketched title font */
}

body.aampa-game-body {
    margin: 0;
    padding: 0;
    background-color: #0f172a;
    color: var(--text-main);
    overflow: hidden; /* Prevent scrolling, it's a full screen game */
}

/* Hide standard utilnode header/footer */
body.aampa-game-body utilnode-header,
body.aampa-game-body utilnode-footer {
    display: none;
}

#game-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Ghibli Horizon Background */
    background-image: url("/game/aampa-tamarind-seed-game/ghibli-bg.jpg");
    background-size: cover;
    background-position: center bottom;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.screen.active {
    display: flex;
}

/* Common UI Elements */
.aampa-btn {
    font-family: var(--font-marker);
    font-size: 1.8rem;
    padding: 12px 30px;
    background: var(--glass-bg);
    color: var(--text-main);
    border: 3px solid var(--text-main);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 2px;
    text-transform: uppercase;
    box-shadow: 4px 4px 0px rgba(62, 39, 35, 0.5); /* Solid offset shadow for rustic feel */
}

.aampa-btn:hover {
    background: var(--text-main);
    color: #f4ecd8;
    transform: translateY(-2px) rotate(-1deg);
}

.aampa-btn:active {
    transform: translateY(2px) translateX(2px);
    box-shadow: 1px 1px 0px rgba(62, 39, 35, 0.5);
}

/* Intro Screen */
#screen-intro {
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.intro-content {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border: 2px solid var(--text-main);
    padding: 3rem;
    border-radius: 8px;
    box-shadow: 10px 10px 20px rgba(0,0,0,0.6);
    max-width: 500px;
    text-align: center;
    font-family: var(--font-handwriting);
    font-size: 1.8rem;
    color: var(--text-main);
}

.intro-content h1 {
    font-family: var(--font-marker);
    font-size: 5rem;
    margin: 0 0 1rem 0;
    color: var(--text-main);
    letter-spacing: 4px;
}

.intro-content p {
    margin: 1rem 0;
    line-height: 1.4;
}

.intro-content .aampa-btn {
    margin-top: 2rem;
}

/* Setup Screen */
#screen-setup {
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.setup-content {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border: 2px solid var(--text-main);
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 450px;
    text-align: center;
    box-shadow: 10px 10px 20px rgba(0,0,0,0.6);
}

.setup-content h2 {
    font-family: var(--font-marker);
    color: var(--text-main);
    font-size: 3rem;
    margin-top: 0;
}

.players-setup {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    margin-bottom: 2.5rem;
}

.player-input-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.5rem;
    border: 1px dashed var(--text-main);
    border-radius: 4px;
    background: rgba(255,255,255,0.4);
}

.player-input-card label {
    font-family: var(--font-marker);
    font-size: 1.4rem;
    width: 80px;
    text-align: left;
}

.player-top label { color: var(--ink-blue); }
.player-right label { color: var(--ink-red); }
.player-bottom label { color: var(--ink-green); }
.player-left label { color: var(--ink-yellow); }

.player-input-card input {
    font-family: var(--font-handwriting);
    font-size: 1.8rem;
    border: none;
    background: transparent;
    border-bottom: 2px dashed var(--text-main);
    outline: none;
    flex-grow: 1;
    margin-left: 20px;
    text-align: left;
    color: var(--text-main);
    padding: 0 5px;
}
.player-input-card input:focus { border-bottom: 2px solid var(--text-main); }

.setup-content .aampa-btn {
    font-size: 1.5rem;
}

/* Game Layout */
#screen-game {
    background: transparent;
}

.game-layout {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Player Turn Indicators (4 sides) */
.player-corner {
    position: absolute;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border: 2px solid var(--text-main);
    padding: 10px 20px;
    border-radius: 8px;
    font-family: var(--font-marker);
    font-size: 1.5rem;
    box-shadow: 4px 4px 10px rgba(0,0,0,0.4);
    z-index: 50;
    transition: all 0.3s ease;
    opacity: 0.6;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-corner.active-turn {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 0 20px var(--magic-gold), inset 0 0 10px var(--magic-gold);
    border-color: var(--magic-gold);
    background: rgba(255, 255, 255, 0.9);
}

.corner-top { 
    top: -5px; 
    left: 50%; 
    transform: translate(-50%, -100%); 
}
.corner-top.active-turn { transform: translate(-50%, -100%) scale(1.1); }

.corner-bottom { 
    bottom: -5px; 
    left: 50%; 
    transform: translate(-50%, 100%);
}
.corner-bottom.active-turn { transform: translate(-50%, 100%) scale(1.1); }

.corner-right { 
    top: 50%; 
    right: -5px; 
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: translate(100%, -50%);
    padding: 15px 5px;
}
.corner-right.active-turn { transform: translate(100%, -50%) scale(1.1); }

.corner-left { 
    top: 50%; 
    left: -5px; 
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: translate(-100%, -50%) rotate(180deg);
    padding: 15px 5px;
}
.corner-left.active-turn { transform: translate(-100%, -50%) rotate(180deg) scale(1.1); }

/* Rules Panel & Info Button */
.btn-info {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--glass-bg);
    border: 2px solid var(--text-main);
    color: var(--text-main);
    font-family: var(--font-marker);
    font-size: 1.8rem;
    cursor: pointer;
    z-index: 200;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-info:hover {
    background: var(--text-main);
    color: var(--glass-bg);
}

.rules-panel {
    display: none; /* Hidden by default, toggled via JS */
    position: absolute;
    top: 75px;
    left: 20px;
    width: 280px;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border: 2px solid var(--text-main);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 10px 10px 20px rgba(0,0,0,0.6);
    color: var(--text-main);
    z-index: 190;
    max-height: 80vh;
    overflow-y: auto;
}
.rules-panel.show {
    display: block;
}

.rules-panel h3 {
    font-family: var(--font-marker);
    font-size: 2rem;
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 2px dashed var(--text-main);
    padding-bottom: 5px;
}

.rules-panel ul {
    font-family: var(--font-handwriting);
    font-size: 1.6rem;
    line-height: 1.4;
    padding-left: 20px;
    margin: 0;
}

.rules-panel li {
    margin-bottom: 12px;
}


/* Board Area */
.board-area {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

#board-container {
    /* Better board size: Massive but contained so it doesn't overlap UI */
    width: min(95vw, 80vh);
    max-width: 100%;
    aspect-ratio: 1/1;
    position: relative;
    /* Rustic parchment/canvas board */
    background: rgba(244, 236, 216, 0.95);
    border: 3px solid #3e2723;
    box-shadow: 10px 10px 20px rgba(0,0,0,0.6), inset 0 0 40px rgba(139,69,19,0.2);
    border-radius: 8px;
    /* subtle rustic rotation */
    transform: rotate(-0.5deg);
}

#aampa-board {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* SVG Styles */
.cell-path {
    fill: none;
    stroke: #1a0f0d; /* Much darker */
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cell-fill {
    fill: rgba(139, 69, 19, 0.05);
}

.home-cross {
    fill: transparent;
    stroke: var(--text-main);
    stroke-width: 5;
    stroke-linecap: round;
}

.home-cross-bg {
    fill: rgba(139, 69, 19, 0.1);
}

.destination-bg {
    fill: rgba(0, 0, 0, 0.05);
}

.destination-text {
    font-family: var(--font-marker);
    font-size: 50px;
    fill: var(--text-main);
    text-anchor: middle;
    dominant-baseline: middle;
    opacity: 0.8;
    letter-spacing: 4px;
}

.arrow-path {
    fill: none;
    stroke: #1a0f0d;
    stroke-width: 5;
    stroke-linecap: round;
}

/* Gotis Layer */
#gotis-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass to SVG if needed, but gotis should be clickable */
}

/* 
  Clean Gotis: Pure CSS Colored Glass Beads 
  Removing the image dependencies for pawns. 
*/
.goti {
    position: absolute;
    width: var(--goti-size);
    height: var(--goti-size);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    transition: top 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), left 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    
    /* Clean glass styling */
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8), currentColor 60%, rgba(0,0,0,0.8));
    border: 1px solid rgba(255,255,255,0.4);
    box-shadow: 0 4px 8px rgba(0,0,0,0.8);
    
    z-index: 20;
    cursor: pointer;
}

.goti-top { color: var(--ink-blue); }
.goti-right { color: var(--ink-red); }
.goti-bottom { color: var(--ink-green); }
.goti-left { color: var(--ink-yellow); }

/* Interactive States */
.goti.my-turn {
    animation: gentle-bounce 1s infinite alternate ease-in-out;
    filter: drop-shadow(0 0 8px currentColor);
    z-index: 25;
}

@keyframes gentle-bounce {
    from { transform: translate(-50%, -50%) scale(1); box-shadow: 0 4px 8px rgba(0,0,0,0.8); }
    to { transform: translate(-50%, -60%) scale(1.1); box-shadow: 0 10px 15px rgba(0,0,0,0.5); }
}

.goti.selectable {
    animation: pulse 1s infinite alternate;
    z-index: 30;
}

.goti.selectable:hover {
    transform: translate(-50%, -50%) scale(1.2);
}

@keyframes pulse {
    from { filter: drop-shadow(0 0 0px currentColor) brightness(1); }
    to { filter: drop-shadow(0 0 15px currentColor) brightness(1.3); }
}

/* Moving animation class */
.goti.moving {
    z-index: 40;
    transform: translate(-50%, -50%) scale(1.3);
    box-shadow: 0 15px 20px rgba(0,0,0,0.6);
}

/* Throw Controls */
.throw-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border: 2px solid var(--text-main);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 10px 10px 20px rgba(0,0,0,0.6);
    z-index: 100;
}

.action-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin-top: 15px;
}

#action-message {
    font-family: var(--font-marker);
    font-size: 1.5rem;
    color: var(--text-main);
    text-align: center;
}

#btn-throw {
    font-size: 1.2rem;
    padding: 8px 30px;
    width: 100%;
}

#btn-throw:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.tamarind-area {
    width: 100%;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.4);
    border-radius: 12px;
    border: 1px dashed rgba(255,255,255,0.2);
    box-shadow: inset 0 5px 10px rgba(0,0,0,0.5);
}

#tamarind-pieces {
    position: relative;
    width: 200px;
    height: 60px;
}

/* Tamarind Pieces (The thrown seeds) */
.tamarind-piece {
    position: absolute;
    width: 28px;
    height: 44px;
    border-radius: 15px 15px 10px 10px;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.8);
    /* Clean CSS styling for the dark shell side */
    background: linear-gradient(135deg, #3e2723, #1a0b07); 
    border: 1px solid #1a0b07;
}

.tamarind-piece.white-side {
    /* Clean CSS styling for the cut white side */
    background: linear-gradient(135deg, #fffaf0, #e6d5c3);
    border: 1px solid #c8a282;
    box-shadow: inset 0 0 10px rgba(139,69,19,0.3), 0 4px 6px rgba(0,0,0,0.8);
}

/* Game Over Screen */
#screen-gameover {
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
}

.gameover-content {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border: 2px solid var(--text-main);
    padding: 3rem;
    border-radius: 8px;
    width: 90%;
    max-width: 450px;
    text-align: center;
    font-family: var(--font-handwriting);
    box-shadow: 10px 10px 20px rgba(0,0,0,0.6);
}

.gameover-content h2 {
    font-family: var(--font-marker);
    font-size: 3.5rem;
    color: var(--text-main);
    margin-top: 0;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 2rem;
    margin-bottom: 2rem;
    text-align: left;
    padding-left: 15%;
    color: var(--text-main);
}

.loser-message {
    font-size: 1.8rem;
    color: var(--ink-red);
    font-family: var(--font-marker);
    margin-bottom: 2rem;
    line-height: 1.3;
}

#btn-play-again {
    font-size: 1.5rem;
}

.seo-hidden {
    display: none;
}

/* Debug Panel */
.debug-panel {
    display: none; 
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px;
    border-radius: 8px;
    z-index: 1000;
    font-family: monospace;
    gap: 8px;
    align-items: center;
}

.debug-panel button {
    padding: 5px 12px;
    cursor: pointer;
    background: var(--ink-red);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: bold;
}
.debug-panel button:hover {
    background: var(--ink-blue);
}

@media (max-width: 1300px) {
    .rules-panel {
        width: 240px;
        padding: 15px;
        left: 10px;
    }
    .rules-panel h3 { font-size: 1.5rem; }
    .rules-panel ul { font-size: 0.9rem; }
}

/* Responsive Mobile */
@media (max-width: 600px) {
    :root {
        --goti-size: 20px;
    }
    
    .intro-content h1 { font-size: 3.5rem; }
    .setup-content h2 { font-size: 2.5rem; }
    
    #board-container {
        width: 75vw;
        max-width: none;
    }
    
    .player-corner {
        font-size: 1.1rem;
    }
    
    .throw-controls {
        bottom: max(50px, env(safe-area-inset-bottom, 50px));
        right: 15px;
        left: 15px;
        border-radius: 8px;
        border: 2px solid var(--text-main);
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 20px;
        padding: 8px 10px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    }
    
    .action-area {
        width: auto;
        flex-direction: row;
        align-items: center;
        margin: 0;
    }
    
    #action-message {
        position: absolute;
        top: -45px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 1.1rem;
        padding: 4px 15px;
        background: var(--glass-bg);
        border: 2px solid var(--text-main);
        border-radius: 20px;
        box-shadow: 0 4px 6px rgba(0,0,0,0.4);
        white-space: nowrap;
    }
    
    #btn-throw {
        font-size: 1.1rem;
        padding: 6px 15px;
    }

    .tamarind-area {
        width: auto;
        height: 35px;
        min-height: 35px;
        gap: 5px;
        margin: 0;
    }
    .tamarind-piece { width: 16px; height: 26px; }
}
