:root {
    --bg-color: #F5EFE3;
    --board-color: #E9DFCD;
    --arrow-color: #6A4A3C;
    --highlight-color: #4AA3FF;
    --success-color: #52C41A;
    --warning-color: #FF4D4F;
    --text-color: #4A3B32;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="Dark Mode"] {
    --bg-color: #1E1E1E;
    --board-color: #2D2D2D;
    --arrow-color: #E0E0E0;
    --highlight-color: #108EE9;
    --success-color: #4CAF50;
    --warning-color: #F44336;
    --text-color: #F5F5F5;
}

[data-theme="Ocean Blue"] {
    --bg-color: #E0F2F1;
    --board-color: #B2DFDB;
    --arrow-color: #004D40;
    --highlight-color: #26A69A;
    --success-color: #00E676;
    --warning-color: #FF1744;
    --text-color: #002420;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: var(--font-family);
    color: var(--text-color);
    transition: background-color 0.4s ease;
}

body {
    background: url('bg.jpg') center center / cover no-repeat fixed;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transform: scale(1.02);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px;
    z-index: 10;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

/* Preloader */
#preloader-screen {
    z-index: 100;
    background-color: var(--bg-color);
    opacity: 1;
    pointer-events: auto;
}

.loader-logo {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 20px;
    letter-spacing: 2px;
    text-align: center;
}

.progress-bar-container {
    width: 240px;
    height: 8px;
    background-color: var(--board-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background-color: var(--arrow-color);
    transition: width 0.1s linear;
}

/* Home Screen */
.game-title {
    font-size: 42px;
    font-weight: 900;
    margin-bottom: 40px;
    text-align: center;
    line-height: 1.1;
    color: #fff;
    text-shadow: 2px 2px 0px #ff6b6b, 4px 4px 0px #4ecdc4, 12px 12px 20px rgba(0, 0, 0, 0.5);
    animation: titlePulse 2s ease-in-out infinite;

}

@keyframes titlePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.game-title span {
    color: var(--highlight-color);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 280px;
}

/* Buttons */
.btn {
    background-color: var(--arrow-color);
    color: var(--bg-color);
    border: none;
    padding: 16px 28px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    text-align: center;
    transition: all 0.1s ease;

    box-shadow:
        0 10px 30px color-mix(in srgb, var(--arrow-color) 50%, transparent),
        0 5px 0 color-mix(in srgb, var(--arrow-color) 70%, black);
}

#level-display-tag {
    color: #fff;
}

.btn:active {
    transform: scale(0.95);
}

.btn-secondary {
    background-color: var(--board-color);
    color: var(--text-color);
}

/* Top Bar UI */
.top-ui-layer {
    width: 100%;
    max-width: 450px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-weight: 700;
    font-size: 18px;color:#fff;
}

.stats-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--board-color);
    padding: 8px 14px;
    border-radius: 20px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--board-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    color: var(--text-color);
    transition: transform 0.1s ease;
}

.icon-btn:active {
    transform: scale(0.9);
}

/* Level Grid */
.level-container {
    width: 100%;
    max-width: 400px;
    height: 60%;
    overflow-y: auto;
    padding-right: 5px;
    margin-bottom: 20px;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.level-node {
    aspect-ratio: 1;
    background-color: var(--board-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    cursor: pointer;
    position: relative;
}

.level-node.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.level-node .stars {
    font-size: 10px;
    margin-top: 4px;
    color: #FFB300;
}

/* Game Arena Canvas Container */
.canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 450px;
    aspect-ratio: 1;
    background-color: var(--board-color);
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Footers */
.action-footer {
    width: 100%;
    max-width: 450px;
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
}

/* Modals */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.modal-box {
    background-color: var(--bg-color);
    width: 85%;
    max-width: 340px;
    border-radius: 20px;
    padding: 30px 24px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-box {
    transform: translateY(0);
}

.modal-box h3 {
    font-size: 24px;
    margin-bottom: 15px;
}

.modal-box p {
    font-size: 16px;
    margin-bottom: 24px;
    opacity: 0.8;
    line-height: 1.4;
}

.theme-selector-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.theme-chip {
    padding: 12px;
    border-radius: 8px;
    border: 2px solid var(--board-color);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}

.theme-chip.active {
    border-color: var(--highlight-color);
    background-color: var(--board-color);
}

/* Visual Feedback */
.shake {
    animation: masterShake 0.4s ease-in-out;
}

@keyframes masterShake {

    0%,
    100% {
        transform: translate(0, 0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translate(-4px, 2px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translate(4px, -2px);
    }
}

#flash-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 77, 79, 0.25);
    pointer-events: none;
    opacity: 0;
    z-index: 99;
    transition: opacity 0.1s ease;
}

:root {
  --outer-frame-color: #2a1a0f; 
  --leather-field-color: #1f053e; /* Updated to your exact requested hex */
  --pinstripe-gold: #c29f4a;      
  --content-bg: #eae3d2;          
}

.game-board {
  display: inline-block;
  position: relative;
  padding: 16px;
  border-radius: 16px;
  background-color: var(--outer-frame-color);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.4);
}

.board-field-container {
  position: relative;
  border-radius: 8px;
  background-color: var(--leather-field-color);
  border-top: 3px solid #14022a;
  border-left: 3px solid #14022a;
  border-bottom: 3px solid #361164;
  border-right: 3px solid #361164;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

/* Subtle pattern texture for the leather backing */
.board-field-container::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: repeating-radial-gradient(circle at 1px 1px, rgba(255,255,255,0.03) 0px, transparent 1px, transparent 2px);
  background-size: 4px 4px;
  pointer-events: none;
}

.board-pinstripe-frame {
  position: absolute;
  top: 8px; left: 8px; right: 8px; bottom: 8px;
  border-radius: 6px;
  border: 1px solid var(--pinstripe-gold);
  box-shadow: 0 0 4px rgba(0,0,0,0.4);
  pointer-events: none;
}

/* Handles padding and internal elements setup without breaking your canvas proportions */
.board-layout {
  position: relative;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}