/* =============================================================================
   CSS VARIABLES & ROOT CONFIGURATION
   ============================================================================= */

:root {
    /* Fixed baseline independent of browser text scaling */
    font-size: 16px; /* px-basierter Baseline-Text */
    --yellow: #FBBF24;
    --green: #196B39;
    --brown: #432B1E;
    --transparent: rgba(255, 255, 255, 0);

    --dark: #222222;
    --light: #f0fdf4;
    --medium: #d1d5db;

    --bg-canvas: #2d1b11;
    --bg-ui: rgba(255, 255, 255, 0.1);
    --button-bg: #166534;
    --button-hover: #15803d;
    --accent-color: #6366f1;
    --accent-hover: #4f46e5;

    --header-height: 60px;
    --footer-height: 60px;
    /* Scaled via UI scale (for header/footer heights) */
    --header-height-scaled: calc(var(--header-height) * var(--ui-scale, 1));
    --footer-height-scaled: calc(var(--footer-height) * var(--ui-scale, 1));
    --modal-gap: 16px; /* unified modal outer spacing on all sides */
}

/* =============================================================================
   WEBFONTS
   ============================================================================= */

/* poppins-100 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 100;
  src: url('../fonts/poppins-v23-latin-100.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* poppins-100italic - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Poppins';
  font-style: italic;
  font-weight: 100;
  src: url('../fonts/poppins-v23-latin-100italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* poppins-200 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 200;
  src: url('../fonts/poppins-v23-latin-200.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* poppins-200italic - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Poppins';
  font-style: italic;
  font-weight: 200;
  src: url('../fonts/poppins-v23-latin-200italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* poppins-300 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 300;
  src: url('../fonts/poppins-v23-latin-300.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* poppins-300italic - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Poppins';
  font-style: italic;
  font-weight: 300;
  src: url('../fonts/poppins-v23-latin-300italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* poppins-regular - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 400;
  src: url('../fonts/poppins-v23-latin-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* poppins-italic - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Poppins';
  font-style: italic;
  font-weight: 400;
  src: url('../fonts/poppins-v23-latin-italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* poppins-700 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 700;
  src: url('../fonts/poppins-v23-latin-700.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}

/* poppins-700italic - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Poppins';
  font-style: italic;
  font-weight: 700;
  src: url('../fonts/poppins-v23-latin-700italic.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}


/* =============================================================================
   BASE LAYOUT & TYPOGRAPHY
   ============================================================================= */

/* Universal Touch Focus Prevention */
* {
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    /* Disable automatic text inflation on mobile browsers */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: Poppins, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--green);
    color: var(--light);
    /* Reserve space for fixed footer (scaled) */
    padding-bottom: var(--footer-height-scaled);
    box-sizing: border-box;
    background: url('../img/layout/leaves.webp') no-repeat center center fixed;
    background-size: cover;
}

/* Offline indicator removed (design decision) */

/* Update Toast */
.update-toast {
    position: fixed;
    bottom: calc(var(--footer-height-scaled) + 12px);
    left: 50%;
    transform: translate(-50%, 120%);
    background: linear-gradient(135deg, rgba(25,107,57,0.92), rgba(30,130,70,0.92));
    border: 2px solid var(--yellow);
    color: #fff;
    padding: 12px 18px;
    border-radius: 16px;
    display: flex;
    align-items: stretch;
    gap: 16px;
    font-size: 14px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.45), 0 0 0 2px rgba(255,255,255,0.08) inset;
    z-index: 9999;
    backdrop-filter: blur(4px);
    transition: transform .4s cubic-bezier(.4,.0,.2,1), opacity .4s ease;
    opacity: 0;
}
.update-toast.show { transform: translate(-50%, 0); opacity: 1; }
.update-toast .update-toast-content { display: flex; flex-direction: column; gap: 4px; }
.update-toast-line-primary { font-weight: 700; letter-spacing: .5px; }
.update-toast-line-secondary { font-size: 12px; opacity: .9; }
.update-toast-actions { display: flex; gap: 8px; align-items: center; }
.update-toast .btn-small { font-size: 12px; padding: 4px 10px; line-height: 1.2; }
.update-toast .secondary { background: rgba(0,0,0,0.35); border-color: rgba(255,255,255,0.25); }

/* High Contrast Anpassung */
.high-contrast .update-toast { background: #000 !important; border-color: #fff; box-shadow: 0 0 0 2px #fff inset, 0 4px 12px rgba(0,0,0,.6); }
.high-contrast .update-toast .secondary { background: #222; border-color: #fff; }
.high-contrast .update-toast-line-secondary { opacity: 1; }

h1{
    font-size: 32px; /* px statt rem, vermeidet OS-Textskalierung */
    font-weight: bold;
    color: var(--yellow);
}

h2 {
    font-size: 24px; /* px statt rem */
    font-weight: bold;
    color: var(--yellow);
}

h3 {
    font-size: 20px; /* px statt rem */
    font-weight: bold;
    color: var(--yellow);
}

.hidden {
    display: none !important;
}

.pattern-yellow {
	background:
		  conic-gradient(from -45deg at calc(100%/3) calc(100%/3), #FFD024 90deg, #0000 0),
		  conic-gradient(from -135deg at calc(100%/3) calc(2*100%/3), #FFD024 90deg, #FFED23 0 135deg, #0000 0),
		  conic-gradient(from 135deg at calc(2*100%/3) calc(2*100%/3), #FFD024 90deg, #FFED23 0 135deg, #0000 0),
		  conic-gradient(from 45deg at calc(2*100%/3) calc(100%/3), #FFD024 90deg, #FFED23 0 135deg, #0000 0,#FFD024 0 225deg,#FFED23 0);
	background-size: 48px 48px;
    color: var(--dark)
}

.pattern-brown {
	background:
		  conic-gradient(from -45deg at calc(100%/3) calc(100%/3), #2F1E15 90deg, #0000 0),
		  conic-gradient(from -135deg at calc(100%/3) calc(2*100%/3), #2F1E15 90deg, #432B1E 0 135deg, #0000 0),
		  conic-gradient(from 135deg at calc(2*100%/3) calc(2*100%/3), #2F1E15 90deg, #432B1E 0 135deg, #0000 0),
		  conic-gradient(from 45deg at calc(2*100%/3) calc(100%/3), #2F1E15 90deg, #432B1E 0 135deg, #0000 0,#2F1E15 0 225deg,#432B1E 0);
	background-size: 48px 48px;
    color: var(--light);
}

.pattern-green {
	background:
		  radial-gradient(35.36% 35.36% at 100% 25%,#0000 66%,#196B39 68% 70%,#0000 72%) 24px 24px/calc(2*24px) calc(2*24px),
		  radial-gradient(35.36% 35.36% at 0    75%,#0000 66%,#196B39 68% 70%,#0000 72%) 24px 24px/calc(2*24px) calc(2*24px),
		  radial-gradient(35.36% 35.36% at 100% 25%,#0000 66%,#196B39 68% 70%,#0000 72%) 0 0/calc(2*24px) calc(2*24px),
		  radial-gradient(35.36% 35.36% at 0    75%,#0000 66%,#196B39 68% 70%,#0000 72%) 0 0/calc(2*24px) calc(2*24px),
		  repeating-conic-gradient(#14522C 0 25%,#0000 0 50%) 0 0/calc(2*24px) calc(2*24px),
		  radial-gradient(#0000 66%,#196B39 68% 70%,#0000 72%) 0 calc(24px/2)/24px 24px
		  #14522C;
    color: var(--light);
}

/* =============================================================================
   CANVAS & GAME BOARD STYLING
   ============================================================================= */

canvas#game-board {
    border-radius: 8px;
    cursor: pointer;
    display: block;
    border: 3px solid var(--yellow);
    margin: 0; /* Flush with content area; JS controls size in exact pixels */
    width: auto; /* No CSS scaling; JS sets style.width/height */
    height: auto;
    max-width: none;
    max-height: none;
    box-sizing: content-box; /* Content box is draw area; border does not stretch content */
    /* Prevent flex shrinking/compression in column container */
    flex: 0 0 auto;
    align-self: center;

    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    outline: none !important;
    
    /* Touch-Device Focus Prevention */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    
    /* Prevent any focus outline or border changes */
    border: 3px solid var(--yellow) !important;
}

canvas#game-board:focus,
canvas#game-board:active,
canvas#game-board:focus-visible,
canvas#game-board:focus-within {
    outline: none !important;
    /* Prevent layout shift: keep border width equal to default state */
    border: 3px solid var(--yellow) !important;
    /* Optional focus glow without size change */
    box-shadow: 0 0 0 3px rgba(255, 187, 36, 0.25);
}

/* Earth-like canvas texture for game board */
canvas#game-board {
	background:
		  radial-gradient(50% 50% at 100% 0,#2F1E15 0%  5% ,#432B1E 6%  15%,#2F1E15 16% 25%,#432B1E 26% 35%,#2F1E15 36% 45%,
		   #432B1E 46% 55%,#2F1E15 56% 65%,#432B1E 66% 75%,#2F1E15 76% 85%,#432B1E 86% 95%,
		   #0000 96%),
		  radial-gradient(50% 50% at 0 100%,#2F1E15 0%  5% ,#432B1E 6%  15%,#2F1E15 16% 25%,#432B1E 26% 35%,#2F1E15 36% 45%,
		   #432B1E 46% 55%,#2F1E15 56% 65%,#432B1E 66% 75%,#2F1E15 76% 85%,#432B1E 86% 95%,
		   #0000 96%),
		  radial-gradient(50% 50%,#2F1E15 0%  5% ,#432B1E 6%  15%,#2F1E15 16% 25%,#432B1E 26% 35%,#2F1E15 36% 45%,
		   #432B1E 46% 55%,#2F1E15 56% 65%,#432B1E 66% 75%,#2F1E15 76% 85%,#432B1E 86% 95%,
		   #0000 96%),
		  radial-gradient(50% 50%,#2F1E15 0%  5% ,#432B1E 6%  15%,#2F1E15 16% 25%,#432B1E 26% 35%,#2F1E15 36% 45%,
		   #432B1E 46% 55%,#2F1E15 56% 65%,#432B1E 66% 75%,#2F1E15 76% 85%,#432B1E 86% 95%,
		   #0000 96%) 24px 24px;
	background-size: 48px 48px;
	background-color: #2F1E15;
    color: var(--light);
}

#overlay-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 60;
    pointer-events: none;
}

/* Sunflower colors for SVG rendering */
.sunflower-color-0 { fill: #ff1c1c; }
.sunflower-color-1 { fill: #008d28; }
.sunflower-color-2 { fill: #00c3ff; }
.sunflower-color-3 { fill: #FBBF24; }
.sunflower-color-4 { fill: #7100d4; }
.sunflower-color-5 { fill: #fcaeff; }

.sunflower-svg {
    width: 100%;
    height: 100%;
}

/* =============================================================================
   HEADER & FOOTER SYSTEM
   ============================================================================= */

.global-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height-scaled);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 100;
    background: 
        linear-gradient(to bottom, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0.25) 15%, rgba(255,255,255,0.1) 30%, rgba(255,255,255,0.02) 50%, rgba(0,0,0,0.05) 70%, rgba(0,0,0,0.15) 85%, rgba(0,0,0,0.25) 100%),
        conic-gradient(from -45deg at calc(100%/3) calc(100%/3), #FFD024 90deg, #0000 0),
		  conic-gradient(from -135deg at calc(100%/3) calc(2*100%/3), #FFD024 90deg, #FFED23 0 135deg, #0000 0),
		  conic-gradient(from 135deg at calc(2*100%/3) calc(2*100%/3), #FFD024 90deg, #FFED23 0 135deg, #0000 0),
		  conic-gradient(from 45deg at calc(2*100%/3) calc(100%/3), #FFD024 90deg, #FFED23 0 135deg, #0000 0,#FFD024 0 225deg,#FFED23 0);
    background-size: 100% 100%, 48px 48px, 48px 48px, 48px 48px, 48px 48px;



    box-shadow: 
        0 4px 6px rgba(0, 0, 0, 0.2),
        0 6px 12px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.3),
        inset 0 -1px 0 rgba(0,0,0,0.15);
    box-sizing: border-box;
    padding: 0 16px;
}

.main-menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.main-menu-header .game-title {
    font-size: 32px; /* px statt 2rem */
}

.main-menu-header #sunny-avatar {
    width: 40px;
    height: 40px;
}

.game-header-stats {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* New header stats layout */
.header-level-badge {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 64px;
    height: 52px;
    border-radius: 8px;
    color: var(--light);
    line-height: 1;
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 2px 4px rgba(0,0,0,0.1),
        0 3px 6px rgba(0,0,0,0.08),
        inset 0 1px 0 rgba(255,255,255,0.2),
        inset 0 -1px 0 rgba(0,0,0,0.1);
}

.header-level-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0.2) 15%, rgba(255,255,255,0.08) 30%, rgba(255,255,255,0.02) 50%, rgba(0,0,0,0.05) 70%, rgba(0,0,0,0.15) 85%, rgba(0,0,0,0.2) 100%);
    pointer-events: none;
    border-radius: inherit;
}

.header-level-badge .lvl-label {
    font-size: 10px; /* px statt 0.65rem */
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

.header-level-badge .lvl-number {
    font-size: 24px; /* px statt 1.5rem */
    font-weight: 800;
    margin-top: 3.2px;
    position: relative;
    z-index: 1;
}

.header-goals {
    display: flex;
    flex-direction: column;
    gap: 1.6px;
}

.header-goals .goal-line {
    white-space: nowrap;
}

.header-goals .goal-strong {
    font-weight: 700;
}

.global-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    /* Use correct footer height (scaled) */
    height: var(--footer-height-scaled);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 100;
    background: 
        linear-gradient(to bottom, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0.25) 15%, rgba(255,255,255,0.1) 30%, rgba(255,255,255,0.02) 50%, rgba(0,0,0,0.05) 70%, rgba(0,0,0,0.15) 85%, rgba(0,0,0,0.25) 100%),
        conic-gradient(from -45deg at calc(100%/3) calc(100%/3), #FFD024 90deg, #0000 0),
		  conic-gradient(from -135deg at calc(100%/3) calc(2*100%/3), #FFD024 90deg, #FFED23 0 135deg, #0000 0),
		  conic-gradient(from 135deg at calc(2*100%/3) calc(2*100%/3), #FFD024 90deg, #FFED23 0 135deg, #0000 0),
		  conic-gradient(from 45deg at calc(2*100%/3) calc(100%/3), #FFD024 90deg, #FFED23 0 135deg, #0000 0,#FFD024 0 225deg,#FFED23 0);
    background-size: 100% 100%, 48px 48px, 48px 48px, 48px 48px, 48px 48px;
    box-shadow: 
        0 -4px 6px rgba(0, 0, 0, 0.2),
        0 -6px 12px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.3),
        inset 0 -1px 0 rgba(0,0,0,0.15);
    box-sizing: border-box;
    /* Respect safe areas on mobile devices */
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-top: 0;
    padding-bottom: max(0px, env(safe-area-inset-bottom));
}

.footer-content {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--light);
}

.footer-content .button-group {
    display: none;
}

.global-footer.main-menu-mode #main-menu-buttons {
    display: flex;
    gap: 12px;
}

.global-footer.main-menu-mode #game-buttons {
    display: none;
}

.global-footer.game-mode #main-menu-buttons {
    display: none;
}

.global-footer.game-mode #game-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* =============================================================================
   NAVIGATION & MENU SYSTEM
   ============================================================================= */

#main-menu {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: calc(100vh - 2 * var(--header-height-scaled));
    animation: fadeIn 1s ease-in-out;
}

.main-menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

main#game-content {
    width: 100%;
    max-width: 576px;
    margin: 0 auto;
    z-index: 10;
    display: flex;
    flex-direction: column;
    /* Fallback for browsers without d*vh support */
    height: calc(100vh - var(--header-height-scaled) - var(--footer-height-scaled));
    padding: 16px;
    box-sizing: border-box;
    position: relative;
    top: var(--header-height-scaled);
}

/* Use dynamic viewport units when available */
@supports (height: 100dvh) {
    #main-menu {
    height: calc(100dvh - 2 * var(--header-height-scaled));
    }
    main#game-content {
    height: calc(100dvh - var(--header-height-scaled) - var(--footer-height-scaled));
    }
}

.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 0;
    padding: 0;
    box-sizing: border-box;
}

/* =============================================================================
   BUTTON & FORM ELEMENTS
   ============================================================================= */

.btn {
    font-family: Poppins, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background:
		  linear-gradient(to bottom, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0.25) 15%, rgba(255,255,255,0.1) 30%, rgba(255,255,255,0.02) 50%, rgba(0,0,0,0.05) 70%, rgba(0,0,0,0.15) 85%, rgba(0,0,0,0.25) 100%),
		  conic-gradient(from -45deg at calc(100%/3) calc(100%/3), #2F1E15 90deg, #0000 0),
		  conic-gradient(from -135deg at calc(100%/3) calc(2*100%/3), #2F1E15 90deg, #432B1E 0 135deg, #0000 0),
		  conic-gradient(from 135deg at calc(2*100%/3) calc(2*100%/3), #2F1E15 90deg, #432B1E 0 135deg, #0000 0),
		  conic-gradient(from 45deg at calc(2*100%/3) calc(100%/3), #2F1E15 90deg, #432B1E 0 135deg, #0000 0,#2F1E15 0 225deg,#432B1E 0);
	background-size: 100% 100%, 48px 48px, 48px 48px, 48px 48px, 48px 48px;
    color: var(--light);
    outline: var(--transparent) solid 2px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    padding: 5px 10px;
    position: relative;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow: 
        0 2px 4px rgba(0,0,0,0.1),
        0 4px 8px rgba(0,0,0,0.08),
        inset 0 1px 0 rgba(255,255,255,0.4),
        inset 0 -1px 0 rgba(0,0,0,0.2);
    transform: scale(1);
}

.btn:hover {
    color: var(--yellow);
    outline: var(--yellow) solid 2px;
    transform: scale(1);
    box-shadow: 
        0 3px 6px rgba(0,0,0,0.12),
        0 6px 12px rgba(0,0,0,0.1),
        inset 0 1px 0 rgba(255,255,255,0.5),
        inset 0 -1px 0 rgba(0,0,0,0.08);
}

.btn:active {
    transform: scale(1);
    box-shadow: 
        0 1px 2px rgba(0,0,0,0.1),
        0 2px 4px rgba(0,0,0,0.08),
        inset 0 1px 0 rgba(255,255,255,0.15),
        inset 0 -1px 0 rgba(0,0,0,0.12);
}

.btn:focus {
    outline: none;
    box-shadow: 
        0 2px 4px rgba(0,0,0,0.1),
        0 4px 8px rgba(0,0,0,0.08),
        inset 0 1px 0 rgba(255,255,255,0.4),
        inset 0 -1px 0 rgba(0,0,0,0.2),
        0 0 0 3px rgba(255,187,36,0.3);
}

.btn:focus:hover {
    box-shadow: 
        0 3px 6px rgba(0,0,0,0.12),
        0 6px 12px rgba(0,0,0,0.1),
        inset 0 1px 0 rgba(255,255,255,0.5),
        inset 0 -1px 0 rgba(0,0,0,0.08),
        0 0 0 3px rgba(255,187,36,0.3);
}

.btn-main {
    width: 100%;
    max-width: 320px;
    box-sizing: border-box;
    padding: 16px 32px;
    font-size: 20px; /* px statt 1.25rem */
}

.btn-main:hover {
    transform: scale(1.05);
}

.btn-main:active {
    transform: scale(0.95);
}

.btn-main.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-main.disabled:hover,
.btn-main.disabled:active {
    transform: scale(1);
    box-shadow: 
        0 2px 4px rgba(0,0,0,0.1),
        0 4px 8px rgba(0,0,0,0.08),
        inset 0 1px 0 rgba(255,255,255,0.25),
        inset 0 -1px 0 rgba(0,0,0,0.1);
}

.btn-secondary {
    padding: 12px 24px;
    font-size: 19px; /* px statt 1.2rem */
}

.button-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Deprecated .action-button replaced by .btn */

.modal-button {
    background-color: var(--button-bg);
    color: var(--light);
    font-weight: 700;
    padding: 12px 24px;
    font-size: 18px; /* px statt 1.125rem */
    border-radius: 8px;
    border: 2px solid var(--yellow);
    cursor: pointer;
    transition: background-color 150ms ease-in-out, opacity 150ms ease-in-out;
    text-align: center;
    min-width: 120px;
}

.modal-button:hover {
    background-color: var(--button-hover);
}

.checkbox-container {
    margin-top: 32px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
}

.checkbox-container input {
    width: 24px;
    height: 24px;
    margin-right: 12px;
    cursor: pointer;
}

.checkbox-container label {
    font-size: 18px; /* px statt 1.125rem */
    cursor: pointer;
}

/* =============================================================================
   UNIFIED MODAL SYSTEM
   ============================================================================= */

/* Unified Modal Overlay */
.unified-modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 150;
    padding: var(--modal-gap);
    box-sizing: border-box;
    animation: fadeIn 0.3s ease-out;
}

.unified-modal-overlay.hidden {
    display: none;
}

/* Unified Modal Container */
.unified-modal-container {
    background-color: #14532D;
    color: var(--light);
    border-radius: 16px;
    border: 2px solid var(--yellow);
    max-width: min(600px, 96vw);
    width: 100%;
    max-height: 90vh;
    overflow: hidden; /* content scrolls inside body; container stays bounded */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* Unified Modal Header */
.unified-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px 16px 32px;
    border-bottom: 1px solid rgba(251, 191, 36, 0.2);
    flex-shrink: 0;
}

.unified-modal-title {
    font-size: 28px; /* px statt 1.75rem */
    font-weight: 700;
    color: var(--yellow);
    margin: 0;
    flex: 1;
    text-align: left;
}

.unified-modal-close {
    background: none;
    border: none;
    padding: 0;
    width: auto;
    height: auto;
    transition: all 0.2s ease-in-out;
    flex-shrink: 0;
    margin-left: 16px;
    transform: scale(1);
}

.unified-modal-close:hover { 
    background-color: transparent;
    transform: scale(1.05);
}

.unified-modal-close:active {
    transform: scale(0.95);
}

/* Ensure the close icon uses a clean 48x48 graphic without button chrome */
.unified-modal-close .ui-icon {
    width: 48px;
    height: 48px;
}

/* Removed: close area scaling followed header row */

/* Unified Modal Body */
.unified-modal-body {
    padding: 16px 32px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.unified-modal-body h3 {
    color: var(--yellow);
    font-size: 20px; /* px statt 1.25rem */
    margin: 24px 0 12px 0;
    font-weight: 600;
}

.unified-modal-body h3:first-child {
    margin-top: 0;
}

.unified-modal-body h4 {
    color: var(--light);
    font-size: 18px; /* px statt 1.1rem (~17.6px) */
    margin: 16px 0 8px 0;
    font-weight: 600;
}

.unified-modal-body p, 
.unified-modal-body ul, 
.unified-modal-body ol {
    font-size: 18px; /* px statt 1.125rem */
    line-height: 1.6;
    margin-bottom: 16px;
}

.unified-modal-body ul {
    padding-left: 24px;
}

.unified-modal-body ul li {
    margin-bottom: 8px;
}

.unified-modal-body a {
    color: var(--yellow);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease-in-out;
}

.unified-modal-body a:hover {
    color: var(--light);
    border-bottom: 1px solid var(--light);
}

/* Unified Modal Footer */
.unified-modal-footer {
    padding: 16px 32px 24px 32px;
    border-top: 1px solid rgba(251, 191, 36, 0.2);
    flex-shrink: 0;
    display: flex;
    gap: 16px;
    justify-content: center; /* centered alignment instead of right-aligned */
    flex-wrap: wrap;
}

.unified-modal-footer.hidden {
    display: none;
}

/* Unified Modal Buttons now use global .btn .btn-main styles */
.unified-modal-footer .btn {
    min-width: 120px;
    white-space: nowrap;
}

/* Special content styling for unified modals */
.unified-modal-body .checkbox-container {
    margin: 24px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.unified-modal-body .checkbox-container input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.unified-modal-body .checkbox-container label {
    cursor: pointer;
    color: var(--light);
}

/* Game-specific content styling */
.unified-modal-score-breakdown {
    background: #3c271b;
    padding: 24px;
    border-radius: 8px;
    margin: 16px 0;
    color: white;
}

.unified-modal-score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 12px 0;
    font-size: 18px; /* px statt 1.1rem */
}

.unified-modal-score-item .label {
    color: #f5deb3;
}

.unified-modal-score-item .value {
    font-weight: bold;
    color: #fff;
}

.unified-modal-score-item.total {
    border-top: 2px solid #f5deb3;
    padding-top: 12px;
    margin-top: 16px;
    font-size: 19px; /* px statt 1.2rem */
}

.unified-modal-score-item.total .value {
    color: #FFD700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Credits/Legal Content Styling */
.unified-modal-body #unified-legal-name,
.unified-modal-body #unified-legal-street,
.unified-modal-body #unified-legal-city {
    display: inline;
    font-weight: normal;
}

.unified-modal-body p strong {
    color: var(--yellow);
    font-weight: 600;
}

/* Enhanced styling for license text */
.unified-modal-body p:has(strong:contains("Copyright")) {
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 8px;
    border-left: 3px solid var(--yellow);
    font-size: 16px; /* px statt 1rem */
    line-height: 1.5;
    margin: 16px 0;
}

/* Mobile Responsiveness for Unified Modal */
@media (max-width: 600px) {
    .unified-modal-overlay {
        /* account for safe areas on mobile devices */
        padding-top: calc(var(--modal-gap) + env(safe-area-inset-top));
        padding-bottom: calc(var(--modal-gap) + env(safe-area-inset-bottom));
        padding-left: calc(var(--modal-gap) + env(safe-area-inset-left));
        padding-right: calc(var(--modal-gap) + env(safe-area-inset-right));
    }
    .unified-modal-container {
    margin: 0;
    border-radius: 12px;
    /* Equal spacing top/bottom/left/right; respect dynamic viewport */
    max-height: calc(100dvh - (var(--modal-gap) * 2));
    height: auto;
    }
    
    .unified-modal-header {
        padding: 16px 24px 12px 24px;
    }
    
    .unified-modal-title {
    font-size: 24px; /* px statt 1.5rem */
    }
    
    .unified-modal-close {
    font-size: 28px; /* px statt 1.75rem */
        width: auto;
        height: auto;
    }
    
    .unified-modal-body {
    padding: 12px 24px;
    }
    
    .unified-modal-body h3 {
    font-size: 18px; /* px statt 1.1rem */
    }
    
    .unified-modal_body h4 {
    font-size: 16px; /* px statt 1rem */
    }
    
    .unified-modal-body p,
    .unified-modal-body ul,
    .unified-modal-body ol {
    font-size: 16px; /* px statt 1rem */
    }
    
    .unified-modal-footer {
    padding: 12px 24px 16px 24px;
        flex-direction: column;
    }
    
    .unified-modal-footer .btn {
        width: 100%;
        margin: 0;
    }
}

@media (max-width: 360px) {
    .unified-modal-header {
    padding: 12px 16px 8px 16px;
    }
    
    .unified-modal-title {
    font-size: 20px; /* px statt 1.25rem */
    }
    
    .unified-modal-body {
    padding: 8px 16px;
    }
    
    .unified-modal-body h3 {
    font-size: 16px; /* px statt 1rem */
        margin: 16px 0 8px 0;
    }
    
    .unified-modal-body h4 {
    font-size: 15px; /* px statt 0.95rem */
    }
    
    .unified-modal-body p,
    .unified-modal-body ul,
    .unified-modal-body ol {
    font-size: 14px; /* px statt 0.9rem */
    }
    
    .unified-modal-footer {
    padding: 8px 16px 12px 16px;
    }
}

/* =============================================================================
   MODAL SYSTEM
   ============================================================================= */

.checkbox-container {
    margin-top: 32px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
}

.checkbox-container input {
    width: 24px;
    height: 24px;
    margin-right: 12px;
    cursor: pointer;
}

.checkbox-container label {
    font-size: 18px; /* px statt 1.125rem */
    cursor: pointer;
}

/* =============================================================================
   GAME UI COMPONENTS
   ============================================================================= */

/* =====================
   UI-Status-Row Layout
   ===================== */
.ui-status-row {
    display: flex;
    flex-direction: row;
    gap: 19.2px;
    justify-content: center;
    align-items: stretch;
}
.moves-box, .score-box {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    background:
		  linear-gradient(to bottom, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0.25) 15%, rgba(255,255,255,0.1) 30%, rgba(255,255,255,0.02) 50%, rgba(0,0,0,0.05) 70%, rgba(0,0,0,0.15) 85%, rgba(0,0,0,0.25) 100%),
		  conic-gradient(from -45deg at calc(100%/3) calc(100%/3), #2F1E15 90deg, #0000 0),
		  conic-gradient(from -135deg at calc(100%/3) calc(2*100%/3), #2F1E15 90deg, #432B1E 0 135deg, #0000 0),
		  conic-gradient(from 135deg at calc(2*100%/3) calc(2*100%/3), #2F1E15 90deg, #432B1E 0 135deg, #0000 0),
		  conic-gradient(from 45deg at calc(2*100%/3) calc(100%/3), #2F1E15 90deg, #432B1E 0 135deg, #0000 0,#2F1E15 0 225deg,#432B1E 0);
	background-size: 100% 100%, 48px 48px, 48px 48px, 48px 48px, 48px 48px;
    color: var(--light);
    box-shadow:
        0 2px 4px rgba(0,0,0,0.08),
        0 4px 8px rgba(0,0,0,0.06),
        inset 0 1px 0 rgba(255,255,255,0.4),
        inset 0 -1px 0 rgba(0,0,0,0.15);
    border-radius: 8px;
    font-size: 17px; /* px statt 1.05rem für konsistente UI-Größe */
}

@media (max-width: 600px) {
    .ui-status-row {
        flex-direction: column;
    gap: 8px;
    }
    .moves-box, .score-box {
    font-size: 16px; /* px statt 1rem */
    padding: 9.6px 12.8px;
    }
}   

.ui-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.stats-box {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 12px 20px;
	background:
		  linear-gradient(to bottom, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0.2) 15%, rgba(255,255,255,0.08) 30%, rgba(255,255,255,0.02) 50%, rgba(0,0,0,0.05) 70%, rgba(0,0,0,0.15) 85%, rgba(0,0,0,0.2) 100%),
		  conic-gradient(from -45deg at calc(100%/3) calc(100%/3), #FFD024 90deg, #0000 0),
		  conic-gradient(from -135deg at calc(100%/3) calc(2*100%/3), #FFD024 90deg, #FFED23 0 135deg, #0000 0),
		  conic-gradient(from 135deg at calc(2*100%/3) calc(2*100%/3), #FFD024 90deg, #FFED23 0 135deg, #0000 0),
		  conic-gradient(from 45deg at calc(2*100%/3) calc(100%/3), #FFD024 90deg, #FFED23 0 135deg, #0000 0,#FFD024 0 225deg,#FFED23 0);
	background-size: 100% 100%, 48px 48px, 48px 48px, 48px 48px, 48px 48px;
    color: var(--dark);
    box-shadow: 
        0 2px 4px rgba(0,0,0,0.08),
        0 4px 8px rgba(0,0,0,0.06),
        inset 0 1px 0 rgba(255,255,255,0.4),
        inset 0 -1px 0 rgba(0,0,0,0.15);
    border-radius: 8px;
}

.moves-box .important-number,
.score-box .important-number {
    font-weight: 700;
    font-size: 1.5em;
    line-height: 1;
    display: inline;
    margin-left: 6.4px;
}

.objective-box {
    min-width: 240px;
    margin: auto;
    background-color: var(--yellow) !important;
    background-size: 40px 40px !important;
    color: var(--dark) !important;
    font-weight: 700 !important;
    border: 2px solid #FF8C00 !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
}

/* =============================================================================
   ACCESSIBILITY: UI SCALING
   ============================================================================= */

:root {
    /* Global UI scaling (not the board canvas). 1 = 100% */
    --ui-scale: 1;
}

/* Apply scaling to central UI containers and compensate width
    so layout flow remains stable. Canvas stays unscaled. */
/* Scale central UI regions while keeping layout centered */
.main-menu-buttons,
.main-menu-header,
.game-header-stats,
.footer-content {
    transform: scale(var(--ui-scale));
    transform-origin: center;
}

/* Status UI above board (scaled, top-center aligned) */
.ui-container {
    transform: scale(var(--ui-scale));
    transform-origin: top center;
}


/* =============================================================================
   ICON SYSTEM & SVG STYLING
   ============================================================================= */

/* PNG icon inside buttons */
.ui-icon {
    width: 20px;
    height: 20px;
    display: block;
    pointer-events: none; /* clicks pass through to button */
    -webkit-user-drag: none;
}
button img.ui-icon {
    -webkit-user-drag: none;
}

/* =============================================================================
   ANIMATION & EFFECTS
   ============================================================================= */

@keyframes zoomIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* =============================================================================
   RESPONSIVE DESIGN & MEDIA QUERIES
   ============================================================================= */

@media (max-width: 480px) {
    main#game-content {
    padding: 8px;
    height: calc(100vh - var(--header-height-scaled) - var(--footer-height-scaled));
    }
    
    .game-container {
        padding: 0; /* bündig zu den UI-Boxen */
        justify-content: center;
    }
    
    .ui-container {
    margin-bottom: 12px;
        flex-shrink: 0;
    }
    
    .stats-box {
    padding: 8px 12px;
    font-size: 15px;
    }
    
    .stats-box .important-number {
        font-size: 1.2em;
    margin-left: 4.8px;
    }
    
    :root {
        --header-height: 55px;
        --footer-height: 55px;
    }

    @supports (height: 100dvh) {
        main#game-content {
            height: calc(100dvh - var(--header-height-scaled) - var(--footer-height-scaled));
        }
    }
}

@media (max-width: 360px) {
    main#game-content {
    padding: 4px;
    height: calc(100vh - var(--header-height-scaled) - var(--footer-height-scaled));
    }
    
    .game-container {
        padding: 0;
        justify-content: center;
    }
    
    .ui-container {
    margin-bottom: 8px;
    }
    
    .stats-box {
    padding: 6.4px 9.6px;
    font-size: 14px;
    }
    
    .stats-box .important-number {
        font-size: 1.15em;
    margin-left: 4px;
    }
    
    :root {
        --header-height: 50px;
        --footer-height: 50px;
    }

    @supports (height: 100dvh) {
        main#game-content {
            height: calc(100dvh - var(--header-height-scaled) - var(--footer-height-scaled));
        }
    }
    
    .footer-content .btn {
    padding: 8px 14.4px;
    font-size: 15px;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .footer-content .btn:hover,
    .footer-content .btn:active,
    .footer-content .btn:focus {
        transform: scale(1);
    }
    
    .footer-content .btn .ui-icon {
        width: 18px;
        height: 18px;
    }
}

/* =============================================================================
   SETTINGS DIALOG STYLES
   ============================================================================= */

.settings-dialog {
    max-width: 500px;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    color: var(--yellow);
    font-size: 20px; /* px statt 1.25rem */
    margin-bottom: 16px;
    font-weight: 600;
}

.setting-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-info {
    flex: 1;
    min-width: 0; /* erlaubt Textumbruch innerhalb flex item */
}

.setting-label {
    display: block;
    font-size: 18px; /* px statt 1.1rem */
    font-weight: 500;
    margin-bottom: 8px; /* px statt 0.5rem */
    color: var(--light);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.setting-description {
    font-size: 14px; /* px statt 0.9rem */
    color: var(--medium);
    margin: 0;
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Choice group for discrete UI scale buttons */
.setting-choice-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.setting-choice-group .btn {
    padding: 6.4px 12.8px;
    min-width: 64px;
}

.ui-scale-btn.is-active {
    background: linear-gradient(180deg, #FDE68A, #F59E0B);
    color: #3c271b;
    border-color: rgba(0,0,0,0.15);
}

/* Toggle Switch Styles */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 32px;
    flex-shrink: 0;
    margin-top: 2px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    border-radius: 32px;
    border: 2px solid rgba(251, 191, 36, 0.3);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 2px;
    top: 2px;
    background-color: var(--medium);
    transition: all 0.3s ease;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--yellow);
    border-color: var(--yellow);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(28px);
    background-color: white;
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.toggle-switch:hover .toggle-slider {
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.3);
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .settings-dialog {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        height: 100vh;
        max-height: 100vh;
    }
    
    .setting-item {
        flex-direction: column;
    gap: 8px;
    }
    
    .toggle-switch {
        align-self: flex-start;
    }
}

/* Privacy Modal Content */
.privacy-content {
    text-align: left;
    line-height: 1.6;
}

.privacy-content h3 {
    color: #4CAF50;
    margin: 20px 0 10px 0;
    font-size: 1.1em;
}

.privacy-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

.privacy-content li {
    margin: 8px 0;
}

.privacy-guarantee {
    background-color: #3c271b;
    color: white;
    border-radius: 8px;
    padding: 20px;
    margin: 15px 0;
}

.privacy-guarantee h3 {
    color: #FFD700;
    margin-top: 0;
    margin-bottom: 15px;
}

.privacy-guarantee p {
    margin: 8px 0;
    font-weight: 500;
}

/* =============================
   High Contrast Mode Overrides
   ============================= */
/* Root hook used via class="high-contrast" on :root */

:root.high-contrast body {
    color: #000;
    background: #e6f4ea; /* plain green background for the page */
}

/* Remove patterned backgrounds and gradients; replace with flat colors */
:root.high-contrast .pattern-green,
:root.high-contrast .pattern-yellow,
:root.high-contrast .pattern-brown,
:root.high-contrast .global-header,
:root.high-contrast .global-footer,
:root.high-contrast .unified-modal-header,
:root.high-contrast .unified-modal-footer {
    background-image: none !important;
}

/* Header/Footer: black background, white text */
:root.high-contrast .global-header,
:root.high-contrast .global-footer {
    background-color: #000 !important;
    color: #fff !important;
    box-shadow: none !important;
}

/* Modal header/footer must keep black text for readability */
:root.high-contrast .unified-modal-header,
:root.high-contrast .unified-modal-footer {
    background-color: #fff !important;
    color: #000 !important;
}

/* High contrast: privacy guarantee block in clear black/white */
:root.high-contrast .privacy-guarantee {
    background-color: #000 !important;
    color: #fff !important;
    border: 2px solid #fff !important;
}
:root.high-contrast .privacy-guarantee h3,
:root.high-contrast .privacy-guarantee p,
:root.high-contrast .privacy-guarantee strong {
    color: #fff !important;
}

/* Modal container and body with clear borders */
:root.high-contrast .unified-modal-container {
    background: #fff !important;
    color: #000 !important;
    border: 2px solid #000 !important;
    box-shadow: none !important;
}

/* Ensure all modal/dialog texts and form labels stay black */
:root.high-contrast .unified-modal-container,
:root.high-contrast .unified-modal-container * {
    color: #000 !important;
}

/* Buttons: default black, white text */
:root.high-contrast .btn,
:root.high-contrast .btn-main,
:root.high-contrast .btn-secondary {
    background-image: none !important;
    background-color: #000 !important;
    color: #fff !important;
    border: 2px solid #000 !important;
}
:root.high-contrast .btn:hover,
:root.high-contrast .btn:focus,
:root.high-contrast .btn-main:hover,
:root.high-contrast .btn-main:focus,
:root.high-contrast .btn-secondary:hover,
:root.high-contrast .btn-secondary:focus {
    background-color: #222 !important;
    color: #fff !important;
}

/* Footer buttons must be white */
:root.high-contrast .global-footer .btn,
:root.high-contrast .global-footer .btn-main,
:root.high-contrast .global-footer .btn-secondary {
    background-color: #fff !important;
    color: #000 !important;
    border-color: #000 !important;
}
:root.high-contrast .global-footer .btn:hover,
:root.high-contrast .global-footer .btn:focus,
:root.high-contrast .global-footer .btn-main:hover,
:root.high-contrast .global-footer .btn-main:focus,
:root.high-contrast .global-footer .btn-secondary:hover,
:root.high-contrast .global-footer .btn-secondary:focus {
    background-color: #f2f2f2 !important;
    color: #000 !important;
}

/* High Contrast: remove all box shadows */
:root.high-contrast *:not(:hover) {
    outline-color: #000 !important;
}
:root.high-contrast *:not(:hover) {
    border-color: #000 !important;
}

/* High Contrast: no button borders anywhere */
:root.high-contrast .btn,
:root.high-contrast .btn-main,
:root.high-contrast .btn-secondary,
:root.high-contrast .global-footer .btn,
:root.high-contrast .global-footer .btn-main,
:root.high-contrast .global-footer .btn-secondary {
    border: none !important;
    box-shadow: none !important;
}

/* Toggle switches simplified */
:root.high-contrast .toggle-slider {
    background: #fff !important;
    border: 2px solid #000 !important;
}
/* Toggle states: off red, on green */
:root.high-contrast input[type="checkbox"]:not(:checked) + .toggle-slider,
:root.high-contrast input[type="radio"]:not(:checked) + .toggle-slider {
    background-color: #d32f2f !important; /* red off */
}
:root.high-contrast input[type="checkbox"]:checked + .toggle-slider,
:root.high-contrast input[type="radio"]:checked + .toggle-slider {
    background-color: #2e7d32 !important; /* green on */
}

/* Form controls and labels in settings stay black */
:root.high-contrast label,
:root.high-contrast .setting-label,
:root.high-contrast .setting-description,
:root.high-contrast input,
:root.high-contrast select,
:root.high-contrast textarea {
    color: #000 !important;
}

/* Cards/boxes */
:root.high-contrast .ui-status-row {
    background: #fff !important;
    color: #000 !important;
}

/* Remove border from stats row */
:root.high-contrast .ui-status-row {
    border: none !important;
}

/* Game layout decorative backgrounds off */
:root.high-contrast .game-container,
:root.high-contrast #game-content {
  background-image: none !important;
}

/* Icon images remain; ensure sufficient contrast where used */
:root.high-contrast .ui-icon {
  filter: contrast(150%);
}

/* Level Badge: white background, black text, no gradients */
:root.high-contrast .header-level-badge {
    background-image: none !important;
    background-color: #fff !important;
    color: #000 !important;
}
:root.high-contrast .header-level-badge .lvl-label,
:root.high-contrast .header-level-badge .lvl-number {
    color: #000 !important;
    text-shadow: none !important;
}

/* Moves and Score boxes: black background, white text, no patterns/gradients */
:root.high-contrast .moves-box,
:root.high-contrast .score-box {
    background-image: none !important;
    background-color: #000 !important;
    color: #fff !important;
    box-shadow: none !important;
}

/* Game field: container without background; board itself solid black + black border */
:root.high-contrast .game-container {
    background: none !important;
    background-image: none !important;
    background-color: transparent !important;
    border: none !important;
}
:root.high-contrast #game-board {
    background-image: none !important;
    background-color: #000 !important;
    border: 2px solid #000 !important;
}

/* High Contrast: main menu buttons default without outline; outline only on hover/focus */
:root.high-contrast #main-menu .btn,
:root.high-contrast #main-menu .btn-main,
:root.high-contrast #main-menu .btn-secondary {
    outline: none !important;
    box-shadow: none !important;
}
:root.high-contrast #main-menu .btn:hover,
:root.high-contrast #main-menu .btn:focus,
:root.high-contrast #main-menu .btn-main:hover,
:root.high-contrast #main-menu .btn-main:focus,
:root.high-contrast #main-menu .btn-secondary:hover,
:root.high-contrast #main-menu .btn-secondary:focus {
    outline: 2px solid #FFD700 !important; /* yellow */
    outline-offset: 2px !important;
}

/* High Contrast: all buttons get yellow outline on hover/focus */
:root.high-contrast .btn:hover,
:root.high-contrast .btn:focus,
:root.high-contrast .btn-main:hover,
:root.high-contrast .btn-main:focus,
:root.high-contrast .btn-secondary:hover,
:root.high-contrast .btn-secondary:focus {
    outline: 2px solid #FFD700 !important;
    outline-offset: 2px !important;
}

/* High Contrast — remove separators in Settings and modal chrome borders */
:root.high-contrast .unified-modal-body .settings-section {
    border-bottom: none !important;
}
:root.high-contrast .unified-modal-header {
    border-bottom: none !important;
}
:root.high-contrast .unified-modal-footer {
    border-top: none !important;
}

