/* Shikaku Premium Aesthetic & Layout */

:root {
    --bg-cream: #f9f6ef;
    --panel-bg: #ffffff;
    --accent-teal: #4c9689;
    --accent-teal-dark: #37756a;
    --text-primary: #3d4a45;
    --text-muted: #82938e;

    --grid-line: rgba(130, 147, 142, 0.2);

    --shadow-soft: 0 4px 12px rgba(61, 74, 69, 0.08);
    --shadow-btn: 0 2px 0 var(--accent-teal-dark);
    --shadow-btn-light: 0 2px 0 #d9d2c5;

    --pastel-1: #ffcfcf;
    --pastel-2: #ffe0b2;
    --pastel-3: #fff59d;
    --pastel-4: #c5e1a5;
    --pastel-5: #b2dfdb;
    --pastel-6: #b3e5fc;
    --pastel-7: #d1c4e9;
    --pastel-8: #f8bbd0;

    --heart-color: #e55c5c;
}

/* Reset any page padding to make the game feel like an app */
.game-app-root {
    background-color: var(--bg-cream);
    color: var(--text-primary);
    font-family: 'Nunito', 'Segoe UI', sans-serif;

    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    margin: -1rem;
    /* Offset the bootstrap container padding if necessary */
    padding: 1rem;
    box-sizing: border-box;
    align-items: center;
}

/* Ensure the immersive game container occupies full height and overrides the generic game-container rules */
.game-container.immersive {
    min-height: 100vh !important;
    min-height: 100dvh !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    background-image: url('../assets/images/botanical_motif.png') !important;
    background-size: cover !important;
    background-position: center !important;
    background-blend-mode: multiply !important;
    background-color: var(--bg-cream) !important;
}

#game-container.in-game {
    background-image: none !important;
}

.bg-botanical {
    background-image: url('../assets/images/botanical_motif.png');
    background-size: cover;
    background-position: center;
    background-blend-mode: multiply;
    background-color: var(--bg-cream);
}

.top-section-bg {
    border-radius: 24px;
    padding: 10px 15px;
    margin-bottom: 15px;
    width: 100%;
    border: 2px solid #F2E2C6;
    box-shadow: var(--shadow-soft);
    background-size: auto !important;
    background-repeat: repeat !important;
}

.game-play-area {
    background-color: #FDF4E5;
    border-radius: 24px;
    padding: 15px;
    border: 2px solid #F2E2C6;
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    box-shadow: var(--shadow-soft);
}

.game-content-wrapper {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Internal Menu */
.shikaku-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 20px;
}

.menu-card {
    background: var(--panel-bg);
    border-radius: 24px;
    padding: 30px;
    width: 100%;
    box-shadow: var(--shadow-soft);
}

.menu-title {
    font-weight: 800;
    color: var(--accent-teal-dark);
    font-size: 2rem;
    margin-bottom: 10px;
}

.menu-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 16px;
    border: none;
    margin-top: 15px;
    cursor: pointer;
    transition: transform 0.1s;
}

.menu-btn-primary {
    background: var(--accent-teal);
    color: white;
    box-shadow: var(--shadow-btn);
}

.menu-btn-secondary {
    background: var(--panel-bg);
    color: var(--accent-teal-dark);
    border: 2px solid var(--accent-teal);
    box-shadow: 0 4px 0 var(--accent-teal);
}

.menu-btn:active {
    transform: translateY(4px);
    box-shadow: none !important;
}

/* Calendar Styles */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin-top: 10px;
    width: 100%;
}

.calendar-day {
    aspect-ratio: 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.calendar-day.empty {
    visibility: hidden;
    pointer-events: none;
}

.calendar-day.locked {
    background-color: var(--board-bg);
    color: var(--text-muted);
    opacity: 0.5;
    pointer-events: none;
    cursor: default;
}

.calendar-day.completed {
    background-color: var(--accent-teal);
    color: white;
    pointer-events: none;
    cursor: default;
    box-shadow: 0 0 8px rgba(74, 189, 172, 0.4);
}

.calendar-day.missed {
    background-color: var(--panel-bg);
    color: var(--text-primary);
    border: 2px solid var(--board-bg);
}

.calendar-day.missed:active {
    transform: scale(0.9);
    background-color: #e5e5e5;
}

.calendar-day.current {
    border: 3px solid var(--accent-teal-dark);
}

/* Top Plaque Area */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn-back {
    background: var(--accent-teal);
    color: white;
    box-shadow: var(--shadow-btn);
}

.icon-btn-help {
    background: #FDF4E7;
    color: var(--accent-teal-dark);
    border: 2px solid #F2E2C6;
    box-shadow: 0 2px 0 #F2E2C6;
}

.icon-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

.plaque {
    background-image: url('../assets/images/plaque-bg.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-color: transparent;
    color: white;
    padding: 8px 35px;
    font-weight: 700;
    font-size: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 150px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Hearts */
.hearts-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 0 auto 15px auto;
    background: white;
    padding: 6px 16px;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    width: fit-content;
}

.heart {
    transition: opacity 0.3s, filter 0.3s;
}

.heart.lost {
    opacity: 0.25;
    filter: grayscale(100%);
}

/* Board Wrapper */
.board-wrapper {
    background: var(--panel-bg);
    border-radius: 12px;
    padding: 0;
    border: 3px solid #675643;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    /* We handle scrolling inside the viewport */
    display: flex;
    flex-direction: column;
}

.board-viewport {
    flex: 1;
    overflow: hidden;
    border: 2px solid var(--grid-line);
    border-radius: 8px;
    background: white;
    touch-action: none;
    /* We handle all panning manually */
    cursor: grab;
}

.board-viewport:active {
    cursor: grabbing;
}

/* Board internals */
#shikaku-board {
    position: relative;
    background-color: white;
    transform-origin: 0 0;
    touch-action: none;
}

.cell {
    position: absolute;
    box-sizing: border-box;
    border: 1px solid var(--grid-line);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--accent-teal-dark);
    user-select: none;
    touch-action: none;
    cursor: pointer;
    background-color: white;
    transition: background-color 0.1s;
}

/* Thicker borders for 3x3 blocks */
.cell.border-top {
    border-top: 3px solid #675643 !important;
    z-index: 2;
}

.cell.border-bottom {
    border-bottom: 3px solid #675643;
    z-index: 2;
}

.cell.border-left {
    border-left: 3px solid #675643;
    z-index: 2;
}

.cell.border-right {
    border-right: 3px solid #675643;
    z-index: 2;
}

.cell.selected {
    background-color: rgba(76, 150, 137, 0.2) !important;
}

.cell.highlighted {
    background-color: rgba(76, 150, 137, 0.08);
}

.cell.clue {
    color: var(--text-primary);
    font-weight: 800;
    background-color: #f5f5f5;
}

.cell.error {
    color: var(--heart-color);
    background-color: rgba(229, 92, 92, 0.1);
}

/* Number Pad */
.numpad {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    width: 100%;
}

.numpad-btn {
    background: white;
    border: 2px solid #F2E2C6;
    border-radius: 12px;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-teal-dark);
    padding: 10px 0;
    cursor: pointer;
    box-shadow: 0 4px 0 #F2E2C6;
    transition: transform 0.1s, box-shadow 0.1s;
}

.numpad-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #F2E2C6;
}

.numpad-btn.control {
    background: var(--bg-cream);
    color: var(--text-muted);
    font-size: 1rem;
}



.rect {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid rgba(0, 0, 0, 0.15);
    opacity: 0.85;
    pointer-events: none;
}

.rect.invalid {
    background-color: rgba(229, 92, 92, 0.4) !important;
    border-color: var(--heart-color) !important;
}

.rect.dragging {
    background-color: rgba(76, 150, 137, 0.4) !important;
    border: 2px dashed var(--accent-teal) !important;
}

/* Status Strip */
.status-strip {
    display: flex;
    justify-content: space-between;
    background: #FCF2E2;
    padding: 10px 20px;
    border-radius: 20px;
    margin-top: 15px;
    border: 2px solid #F2E2C6;
    box-shadow: 0 4px 0 #F2E2C6, var(--shadow-soft);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.status-divider {
    width: 2px;
    background-color: #e5d5be;
    margin: 0 10px;
}

/* Bottom Controls */
.bottom-controls {
    display: flex;
    justify-content: space-between;
    background: #FCF2E2;
    padding: 15px;
    border-radius: 24px;
    margin-top: 15px;
    border: 2px solid #F2E2C6;
    box-shadow: 0 4px 0 #F2E2C6, var(--shadow-soft);
    margin-bottom: 20px;
}

.control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    position: relative;
}

.control-icon-wrapper {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    transition: transform 0.1s;
}

.control-btn:active .control-icon-wrapper {
    transform: translateY(2px);
    box-shadow: none !important;
}

.btn-teal .control-icon-wrapper {
    background: var(--accent-teal);
    color: white;
    box-shadow: var(--shadow-btn);
}

.btn-cream .control-icon-wrapper {
    background: var(--bg-cream);
    color: var(--accent-teal-dark);
    border: 2px solid var(--accent-teal);
    box-shadow: var(--shadow-btn-light);
}

.btn-image .control-icon-wrapper {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    width: 50px;
    height: 50px;
}

.control-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
}

.badge {
    position: absolute;
    top: -5px;
    right: 0;
    background: var(--accent-teal-dark);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.65rem;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(61, 74, 69, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.active {
    display: flex !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-cream);
    border-radius: 24px;
    padding: 30px;
    width: 90%;
    max-width: 350px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.2s;
}

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

/* Campaign Track */
.campaign-track-container {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    scrollbar-width: none;
    /* Firefox */
    background-image: url('../assets/images/botanical_motif.png') !important;
    background-size: auto !important;
    background-repeat: repeat !important;
    background-position: center !important;
    background-blend-mode: multiply !important;
    background-color: var(--bg-cream) !important;
}

.campaign-track-container::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.campaign-track-content {
    position: relative;
    padding: 60px 0 120px 0;
    /* Extra padding at bottom for the stats bar */
    display: flex;
    flex-direction: column-reverse;
    /* Nodes go from bottom to top (1 at bottom? User image has 1 at top. Oh, "scroll downwards to see further" implies 1 is at top. Wait, image shows 1 at top, going down to 9. Let's do normal column) */
}

/* Update: user said "scroll downwards to see further", meaning 1 is at top. */
.campaign-track-content {
    position: relative;
    padding: 40px 0 120px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.track-svg-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.track-node-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.track-node {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    font-weight: 800;
    background: white;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    position: relative;
    transition: transform 0.2s;
}

.track-node:active {
    transform: scale(0.95);
}

.track-node.locked {
    background: var(--panel-bg);
    border: 3px solid #dcd5c6;
    color: var(--text-muted);
    cursor: default;
}

.track-node.locked:active {
    transform: none;
}

.track-node.locked .lock-icon {
    font-size: 1rem;
    margin-top: -5px;
}

.track-node.unlocked {
    border: 3px solid var(--accent-teal);
    color: var(--accent-teal-dark);
}

.track-node.current {
    background: var(--accent-teal);
    color: white;
    box-shadow: 0 0 15px rgba(76, 150, 137, 0.5);
}

.track-node-stars {
    display: flex;
    gap: 2px;
    position: absolute;
    bottom: -10px;
    background: white;
    padding: 2px 8px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--accent-teal);
}

.track-node-stars .star {
    color: #ffd700;
    font-size: 0.8rem;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.track-node-stars .star.empty {
    color: #e0e0e0;
    text-shadow: none;
}

/* Tooltip/Labels on nodes */
.track-node-label {
    position: absolute;
    white-space: nowrap;
    background: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--accent-teal-dark);
    box-shadow: var(--shadow-soft);
    border: 1px solid #e0d8c8;
    pointer-events: none;
}

.track-node-label::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
}

/* Label on left pointing right */
.track-node-label.left {
    right: calc(100% + 15px);
}

.track-node-label.left::before {
    left: 100%;
    border-left-color: white;
}

/* Label on right pointing left */
.track-node-label.right {
    left: calc(100% + 15px);
}

.track-node-label.right::before {
    right: 100%;
    border-right-color: white;
}

/* Bottom Stats Bar */
.campaign-stats-bar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: flex;
    padding: 15px;
    z-index: 10;
}

.campaign-stat {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.campaign-stat:first-child {
    border-right: 2px solid var(--bg-cream);
}

.campaign-stat-icon {
    font-size: 2rem;
}

.campaign-stat-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.campaign-stat-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: bold;
}

.campaign-stat-value {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--accent-teal-dark);
}

/* Desktop specific background behaviors for campaign track view */
@media (min-width: 768px) {
    #game-container.in-track {
        background-size: auto !important;
        background-repeat: repeat !important;
    }

    #game-container.in-track .campaign-track-container {
        background-image: none !important;
        background-color: transparent !important;
    }
}