:root {
    --bg-page-top: #0a1224;
    --bg-page-bottom: #0d1b33;
    --surface-1: #111d36;
    --surface-2: #16264a;
    --surface-3: #1c3160;
    --border-subtle: #22355e;
    --border-strong: #2f4a80;
    --border-accent: #22d3ee;
    --text-heading: #eaf2ff;
    --text-body: #c3d1ea;
    --text-muted: #8ea3c7;
    --accent: #22d3ee;
    --accent-strong: #06b6d4;
    --accent-soft: rgba(34, 211, 238, 0.12);
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.14);
    --warning: #fb923c;
    --warning-soft: rgba(251, 146, 60, 0.14);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.14);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 32px;
    --space-6: 48px;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-2: 0 4px 14px rgba(0, 0, 0, .4);
    --shadow-3: 0 12px 32px rgba(0, 0, 0, .5);
    --ease: cubic-bezier(.2, .8, .2, 1);
    --dur-fast: 150ms;
    --dur-med: 250ms;
    --transition: var(--dur-med) var(--ease);
    --font-display: "Rajdhani", "Orbitron", system-ui, sans-serif;
    --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --header-height: 72px;
    --bg-primary: var(--bg-page-top);
    --bg-secondary: var(--surface-1);
    --bg-tertiary: var(--surface-2);
    --bg-card: var(--surface-1);
    --bg-hover: var(--surface-3);
    --primary-light: var(--surface-2);
    --accent-light: #67e8f9;
    --accent-dark: var(--accent-strong);
    --text-primary: var(--text-heading);
    --text-secondary: var(--text-body);
    --text-tertiary: var(--text-muted);
    --border-color: var(--border-subtle);
    --shadow-sm: var(--shadow-1);
    --shadow-md: var(--shadow-2);
    --shadow-lg: var(--shadow-3);
    --spacing-xs: var(--space-1);
    --spacing-sm: var(--space-2);
    --spacing-md: var(--space-3);
    --spacing-lg: var(--space-4);
    --spacing-xl: var(--space-5);
    --spacing-2xl: var(--space-6);
    --radius-xl: 20px;
    --font-family: var(--font-ui);
}

body.light-mode {
    --bg-page-top: #f4f7fb;
    --bg-page-bottom: #e9eff7;
    --surface-1: #ffffff;
    --surface-2: #f6f9fd;
    --surface-3: #eaf1fa;
    --border-subtle: #d5e0ee;
    --border-strong: #b7c7dd;
    --border-accent: #0e7490;
    --text-heading: #0b1a33;
    --text-body: #2b3d5c;
    --text-muted: #5b6f8f;
    --accent: #0e7490;
    --accent-strong: #155e75;
    --accent-soft: rgba(14, 116, 144, .1);
    --accent-light: #155e75;
    --success: #047857;
    --success-soft: rgba(4, 120, 87, .1);
    --warning: #c2410c;
    --warning-soft: rgba(194, 65, 12, .1);
    --danger: #b91c1c;
    --danger-soft: rgba(185, 28, 28, .1);
    --shadow-1: 0 1px 2px rgba(15, 30, 60, .1);
    --shadow-2: 0 4px 14px rgba(15, 30, 60, .12);
    --shadow-3: 0 12px 32px rgba(15, 30, 60, .16);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text-body);
    background:
        radial-gradient(1200px 600px at 15% -10%, rgba(34, 211, 238, .08), transparent 60%),
        radial-gradient(900px 500px at 100% 0%, rgba(59, 130, 246, .1), transparent 55%),
        linear-gradient(180deg, var(--bg-page-top), var(--bg-page-bottom));
    background-attachment: fixed;
    font-family: var(--font-ui);
    line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-heading);
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: .02em;
    line-height: 1.2;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.1rem; }

p { color: var(--text-body); margin-bottom: var(--space-3); }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-strong); text-decoration: underline; }

button, input, select { font: inherit; }
button { min-height: 44px; }
button, select { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: calc(var(--header-height) + var(--space-5)) max(var(--space-4), env(safe-area-inset-left)) var(--space-6) max(var(--space-4), env(safe-area-inset-right));
}

.header {
    position: fixed;
    inset: 0 0 auto;
    z-index: 1000;
    height: var(--header-height);
    border-bottom: 1px solid var(--border-subtle);
    background: color-mix(in srgb, var(--surface-1) 86%, transparent);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-2);
    transition: height var(--dur-med) var(--ease), padding var(--dur-med) var(--ease);
}

.header.shrink { height: 60px; }
.header-content {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 0 max(var(--space-4), env(safe-area-inset-left));
}
.header-search-container { width: min(360px, 100%); flex: 1 1 260px; }
.header-search-container .deals-search { min-height: 44px; border-color: var(--border-subtle); background: var(--surface-2); }
.header-search-container .deals-search:hover { border-color: var(--border-strong); }
.header-search-container .deals-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.header.shrink .header-search-container { max-width: 300px; }
.header.shrink .header-search-container .deals-search { min-height: 38px; }
.logo-section { display: flex; align-items: center; gap: var(--space-2); min-width: fit-content; }
.logo-icon { color: var(--accent); font-size: 1.8rem; }
.logo-text h1 { margin: 0; color: var(--text-heading); font-size: 1.65rem; }
.tagline { margin: 0; color: var(--text-muted); font-size: .75rem; }
.header-nav { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-body);
    font-weight: 600;
    transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition);
}
.nav-btn:hover { color: var(--accent); background: var(--accent-soft); border-color: var(--border-subtle); transform: translateY(-1px); }
.nav-btn i { color: currentColor; }
.nav-label { display: none; }

.section {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto var(--space-5);
    padding: var(--space-5);
    scroll-margin-top: calc(var(--header-height) + var(--space-3));
    background: color-mix(in srgb, var(--surface-1) 92%, transparent);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    animation: fadeInUp .5s var(--ease) both;
}
.section-header { margin-bottom: var(--space-5); }
.section-header h2 { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); color: var(--text-heading); }
.section-header h2 i { color: var(--accent); font-size: 1.4rem; }
.section-subtitle { color: var(--text-muted); font-size: .95rem; }

.calc-layout { display: grid; grid-template-columns: 1fr; gap: var(--space-5); width: 100%; }
.calc-config, .calc-results { min-width: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.config-card, .per-game-breakdown {
    padding: var(--space-4);
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.config-card:hover, .per-game-breakdown:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.config-card h3, .games-header h3, .per-game-breakdown h4 { display: flex; align-items: center; gap: var(--space-2); color: var(--text-heading); }
.config-card h3 { margin-bottom: var(--space-3); font-size: 1.1rem; }
.config-card h3 i, .games-header h3 i, .per-game-breakdown h4 i { color: var(--accent); }

.config-control { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.counter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface-3);
    color: var(--text-heading);
    transition: background var(--transition), color var(--transition), transform var(--transition);
}
.counter-btn:hover { background: var(--accent); color: var(--bg-page-top); }
#gameCount { flex: 1; min-height: 44px; text-align: center; font-weight: 700; color: var(--text-heading); }
#gameCount, .tax-input, .game-input-card input {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-1);
}
#gameCount:focus, .tax-input:focus, .game-input-card input:focus { border-color: var(--border-accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }

.apply-btn, .sample-data-btn, .deals-btn, .refresh-btn {
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    background: var(--accent);
    color: #062333;
    font-weight: 700;
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
}
.apply-btn, .sample-data-btn { width: 100%; padding: 10px var(--space-3); }
.sample-data-btn { margin-top: var(--space-2); background: transparent; color: var(--accent); }
.apply-btn:hover, .sample-data-btn:hover, .deals-btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); transform: translateY(-1px); box-shadow: var(--shadow-2); }
button:active { transform: translateY(1px); }

.tax-display { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.tax-input { width: 100%; padding: 10px 12px; font-size: 1.5rem; font-weight: 700; text-align: center; color: var(--accent); }
.tax-symbol { color: var(--accent); font-size: 1.2rem; font-weight: 700; }
.tax-input::-webkit-outer-spin-button, .tax-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tax-input[type=number] { appearance: textfield; -moz-appearance: textfield; }
.tax-slider { width: 100%; height: 24px; margin: var(--space-2) 0; appearance: auto; border-radius: var(--radius-pill); background: transparent; accent-color: var(--accent); cursor: pointer; }
.tax-slider::-webkit-slider-runnable-track { width: 100%; height: 6px; border-radius: var(--radius-pill); background: var(--border-strong); }
.tax-slider::-webkit-slider-thumb { width: 18px; height: 18px; margin-top: -6px; appearance: none; border: 3px solid var(--surface-1); border-radius: 50%; background: var(--accent); box-shadow: var(--shadow-2); }
.tax-slider::-moz-range-progress { height: 6px; border-radius: var(--radius-pill); background: var(--accent); }
.tax-slider::-moz-range-track { height: 6px; border: 0; border-radius: var(--radius-pill); background: var(--border-strong); }
.tax-slider::-moz-range-thumb { width: 18px; height: 18px; border: 3px solid var(--surface-1); border-radius: 50%; background: var(--accent); box-shadow: var(--shadow-2); }
.slider-labels { display: flex; justify-content: space-between; color: var(--text-muted); font-size: .8rem; }
.tax-presets { display: grid; grid-template-columns: repeat(5, 1fr); margin-top: var(--space-3); }
.preset-btn { min-height: 40px; padding: 8px; border: 1px solid var(--border-strong); border-right-width: 0; background: var(--surface-1); color: var(--text-body); font-weight: 600; transition: background var(--transition), color var(--transition), border-color var(--transition); }
.preset-btn:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.preset-btn:last-child { border-right-width: 1px; border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.preset-btn:hover, .preset-btn.active { z-index: 1; background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.games-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-bottom: var(--space-3); border-bottom: 1px solid var(--border-subtle); margin-bottom: var(--space-4); }
.games-stats { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; font-size: .85rem; }
.stat { padding: 5px 9px; border: 1px solid var(--border-subtle); border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text-muted); }
.games-grid { min-width: 0; max-height: min(640px, 72vh); padding: var(--space-2); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-3); scrollbar-color: var(--border-strong) var(--surface-2); scrollbar-width: thin; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); align-content: start; gap: var(--space-2); }
.game-input-card { display: flex; flex-direction: column; gap: var(--space-1); padding: 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-2); animation: cardEnter .25s var(--ease) both; }
.game-input-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.game-input-card label { min-width: 0; overflow: hidden; color: var(--text-muted); font-size: .8rem; font-weight: 700; letter-spacing: 0; text-overflow: ellipsis; white-space: nowrap; }
.game-input-card input { width: 100%; min-height: 40px; padding: 8px 10px; color: var(--text-heading); font-size: 1rem; font-variant-numeric: tabular-nums; text-align: right; }
.game-remove-btn { padding: 8px 12px; border: 1px solid var(--danger); border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-weight: 600; transition: background var(--transition), color var(--transition); }
.game-remove-btn:hover { background: var(--danger); color: #fff; }

.results-card { padding: var(--space-4); border: 1px solid var(--border-accent); border-radius: var(--radius-md); background: linear-gradient(145deg, var(--surface-2), var(--accent-soft)); box-shadow: var(--shadow-2); }
.results-card h3 { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); color: var(--text-heading); }
.results-card h3 i { color: var(--accent); }
.result-row { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 10px 0; border-bottom: 1px solid var(--border-subtle); }
.result-label { flex: 0 0 auto; color: var(--text-muted); font-weight: 600; }
.result-value { flex: 0 1 auto; min-width: 0; max-width: calc(100% - 4rem); overflow: hidden; color: var(--text-body); font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; text-overflow: ellipsis; text-align: right; white-space: nowrap; }
.result-row:not(.total) .result-value { overflow-wrap: anywhere; white-space: normal; }
.result-row.total { min-width: 0; margin-top: var(--space-2); padding-top: var(--space-3); border-top: 1px solid var(--border-accent); border-bottom: 0; }
.result-row.total .result-label { flex: 0 0 auto; color: var(--text-heading); }
.result-row.total .result-value { flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--accent); font-family: var(--font-display); font-size: 2.1rem; text-align: right; white-space: nowrap; }
.save-calculation-btn { width: 100%; min-height: 46px; margin-top: var(--space-3); padding: 10px var(--space-3); border: 1px solid var(--success); border-radius: var(--radius-md); background: var(--success); color: #05261d; font-weight: 700; transition: all var(--transition); }
.save-calculation-btn:hover:not(:disabled) { background: #6ee7b7; transform: translateY(-1px); box-shadow: var(--shadow-2); }
.save-calculation-btn:disabled { cursor: not-allowed; opacity: .45; }
.per-game-breakdown { max-height: 500px; overflow-y: auto; scrollbar-color: var(--border-strong) var(--surface-2); scrollbar-width: thin; }
.per-game-breakdown h4 { margin-bottom: var(--space-3); }
.breakdown-list { display: flex; flex-direction: column; gap: var(--space-2); }
.breakdown-item { padding: var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--surface-1); }
.breakdown-game-name { margin-bottom: var(--space-2); color: var(--text-heading); font-weight: 700; }
.breakdown-values-detailed { display: flex; flex-direction: column; gap: var(--space-1); }
.breakdown-row { display: flex; justify-content: space-between; gap: var(--space-3); font-size: .9rem; }
.breakdown-label { color: var(--text-muted); }
.breakdown-price { color: var(--text-body); font-variant-numeric: tabular-nums; }
.breakdown-tax { color: var(--warning); font-variant-numeric: tabular-nums; }
.breakdown-total { color: var(--success); font-weight: 700; font-variant-numeric: tabular-nums; }
.total-row { padding-top: var(--space-2); border-top: 1px solid var(--border-subtle); }
.empty-state, .loading-deals { display: flex; min-height: 180px; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-5) var(--space-3); color: var(--text-muted); text-align: center; }
.empty-state i, .loading-deals .spinner { margin-bottom: var(--space-2); color: var(--accent); }
.empty-state p, .loading-deals p { margin: var(--space-1) 0; }
.empty-state .subtext { color: var(--text-muted); font-size: .9rem; }

.deals-controls { display: flex; justify-content: flex-end; gap: var(--space-3); margin-bottom: var(--space-4); }
.deals-search-container { position: relative; }
.deals-search { display: flex; align-items: center; gap: var(--space-2); min-height: 50px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-muted); transition: border-color var(--transition), box-shadow var(--transition); }
.deals-search:focus-within { border-color: var(--border-accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#gameSearchInput { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text-heading); font-size: 1rem; }
#gameSearchInput::placeholder { color: var(--text-muted); }
.search-clear { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 6px 10px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); transition: background var(--transition), color var(--transition); }
.search-clear:hover { background: var(--accent-soft); color: var(--accent); }
.deals-filter { display: flex; flex: 1; justify-content: flex-end; gap: var(--space-2); }
#dealsSort { min-height: 44px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-body); }
#dealsSort:hover, #dealsSort:focus { border-color: var(--border-accent); outline: none; }
.refresh-btn { min-width: 44px; padding: 8px 12px; border-color: var(--border-strong); background: var(--surface-2); color: var(--text-body); }
.refresh-btn:hover { border-color: var(--border-strong); background: var(--surface-3); color: var(--text-heading); transform: translateY(-1px); box-shadow: var(--shadow-1); }
.deals-grid { min-width: 0; max-height: min(720px, 70vh); padding: 4px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: var(--border-strong) var(--surface-2); scrollbar-width: thin; background: var(--surface-2); display: grid; grid-template-columns: 1fr; align-content: start; gap: var(--space-4); }
.games-grid::-webkit-scrollbar, .deals-grid::-webkit-scrollbar, .per-game-breakdown::-webkit-scrollbar { width: 12px; height: 12px; }
.games-grid::-webkit-scrollbar-track, .deals-grid::-webkit-scrollbar-track, .per-game-breakdown::-webkit-scrollbar-track { border-radius: var(--radius-pill); background: var(--surface-2); }
.games-grid::-webkit-scrollbar-thumb, .deals-grid::-webkit-scrollbar-thumb, .per-game-breakdown::-webkit-scrollbar-thumb { border: 3px solid var(--surface-2); border-radius: var(--radius-pill); background: var(--border-strong); }
.games-grid::-webkit-scrollbar-thumb:hover, .deals-grid::-webkit-scrollbar-thumb:hover, .per-game-breakdown::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.games-grid::-webkit-scrollbar-button, .deals-grid::-webkit-scrollbar-button, .per-game-breakdown::-webkit-scrollbar-button { display: block; width: 12px; height: 12px; background-color: var(--surface-2); color: var(--accent); }
.games-grid::-webkit-scrollbar-button:vertical:decrement, .deals-grid::-webkit-scrollbar-button:vertical:decrement, .per-game-breakdown::-webkit-scrollbar-button:vertical:decrement { background: linear-gradient(135deg, transparent 50%, var(--accent) 50%) 3px 4px / 6px 6px no-repeat, linear-gradient(225deg, transparent 50%, var(--accent) 50%) 3px 4px / 6px 6px no-repeat, var(--surface-2); }
.games-grid::-webkit-scrollbar-button:vertical:increment, .deals-grid::-webkit-scrollbar-button:vertical:increment, .per-game-breakdown::-webkit-scrollbar-button:vertical:increment { background: linear-gradient(45deg, transparent 50%, var(--accent) 50%) 3px 2px / 6px 6px no-repeat, linear-gradient(315deg, transparent 50%, var(--accent) 50%) 3px 2px / 6px 6px no-repeat, var(--surface-2); }
.deals-grid > .loading-deals, .deals-grid > .empty-state, .history-grid > .empty-state { grid-column: 1 / -1; width: 100%; }

.deal-card, .history-card-item { height: 100%; overflow: hidden; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--surface-1); box-shadow: var(--shadow-1); transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
.deal-card { display: flex; flex-direction: column; animation: fadeInUp .4s var(--ease) both; }
.deal-card:hover, .history-card-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
@media (hover: hover) { .deal-card:hover { transform: translateY(-2px); } }
.deal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); padding: var(--space-3); border-bottom: 1px solid var(--border-subtle); background: var(--surface-2); }
.deal-title { flex: 1; min-width: 0; margin: 0; color: var(--text-heading); font-size: 1rem; line-height: 1.3; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.deal-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-1); }
.badge { padding: 4px 8px; border: 1px solid var(--success); border-radius: var(--radius-pill); background: var(--success-soft); color: var(--success); font-size: .75rem; font-weight: 800; white-space: nowrap; }
.deal-body { display: flex; flex: 1; flex-direction: column; gap: var(--space-3); padding: var(--space-4) var(--space-3); }
.deal-prices { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.price-item { display: flex; min-width: 0; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1); padding: var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-2); text-align: center; }
.price-label { color: var(--text-muted); font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.price-value { color: var(--success); font-family: var(--font-display); font-size: 1.65rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.price-item:first-child .original-price { color: var(--text-muted); font-size: .8rem; text-decoration: line-through; font-variant-numeric: tabular-nums; }
.discount-label { color: var(--success); font-size: .8rem; font-weight: 700; }
.deal-info-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface-2); }
.info-label { display: flex; align-items: center; gap: var(--space-1); color: var(--text-muted); font-size: .85rem; }
.info-label i { color: var(--accent); }
.info-value { color: var(--text-body); font-weight: 600; }
.deal-footer { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); border-top: 1px solid var(--border-subtle); }
.deal-link { display: flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 44px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-body); font-size: .9rem; font-weight: 700; text-align: center; transition: all var(--transition); }
.deal-link:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.deal-link[style*="background"] { color: #fff !important; text-decoration: none; }
.deal-link[style*="background"]:hover { border-color: var(--success); background: var(--success) !important; color: #fff !important; }

.pagination { display: flex; align-items: center; justify-content: center; gap: var(--space-3); width: 100%; margin: var(--space-4) auto 0; padding: var(--space-2); border-top: 1px solid var(--border-subtle); }
.pagination-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1); min-height: 44px; padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-body); font-weight: 700; transition: all var(--transition); }
.pagination-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.pagination-btn:disabled { cursor: not-allowed; opacity: .45; }
.pagination-info { color: var(--text-heading); font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; }
.deals-page-status { min-height: 24px; margin-top: var(--space-2); color: var(--text-muted); }
.deals-page-status[hidden] { display: none; }
.deals-page-status.error { color: var(--danger); }
.deals-retry-btn { min-height: 32px; margin-left: var(--space-2); padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-body); }

.search-suggestions { position: absolute; z-index: 1000; top: calc(100% + var(--space-1)); left: 0; right: 0; max-height: 300px; overflow-y: auto; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-3); box-shadow: var(--shadow-3); }
.search-suggestion-item { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-subtle); cursor: pointer; transition: background var(--transition), box-shadow var(--transition); }
.search-suggestion-item:last-child { border-bottom: 0; }
.search-suggestion-item:hover, .search-suggestion-item.active, .search-suggestion-item[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
.search-suggestion-thumbnail { width: 40px; height: 40px; flex: 0 0 40px; border-radius: var(--radius-sm); background: var(--surface-1); object-fit: cover; }
.search-suggestion-info { min-width: 0; flex: 1; }
.search-suggestion-name { overflow: hidden; color: var(--text-heading); font-size: .9rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.search-suggestion-meta { color: var(--text-muted); font-size: .8rem; }

.history-controls { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); padding: var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-2); }
.history-count { display: flex; align-items: center; gap: var(--space-2); color: var(--text-body); font-weight: 600; }
.history-count i { color: var(--accent); }
.history-count span { color: var(--accent); font-variant-numeric: tabular-nums; }
.clear-history-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; padding: 8px 12px; border: 1px solid var(--danger); border-radius: var(--radius-md); background: var(--danger-soft); color: var(--danger); transition: all var(--transition); }
.clear-history-btn:hover { background: var(--danger); color: #fff; }
.history-grid { min-width: 0; max-height: min(720px, 70vh); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: var(--border-strong) var(--surface-2); scrollbar-width: thin; background: var(--surface-2); display: grid; grid-template-columns: 1fr; align-content: start; gap: var(--space-4); }
.history-grid::-webkit-scrollbar { width: 12px; height: 12px; }
.history-grid::-webkit-scrollbar-track { border-radius: var(--radius-pill); background: var(--surface-2); }
.history-grid::-webkit-scrollbar-thumb { border: 3px solid var(--surface-2); border-radius: var(--radius-pill); background: var(--border-strong); }
.history-grid::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.history-grid::-webkit-scrollbar-button { display: block; width: 12px; height: 12px; background-color: var(--surface-2); color: var(--accent); }
.history-card-item { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); animation: fadeInUp .4s var(--ease) both; }
.history-timestamp { display: flex; align-items: center; gap: var(--space-2); padding-bottom: var(--space-2); border-bottom: 1px solid var(--border-subtle); color: var(--text-muted); font-size: .85rem; }
.history-timestamp i { color: var(--accent); }
.history-detail-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 6px 0; }
.history-detail-label { color: var(--text-muted); font-size: .9rem; }
.history-detail-value { color: var(--text-body); font-weight: 600; font-variant-numeric: tabular-nums; }
.history-actions { display: flex; gap: var(--space-2); margin-top: auto; }
.history-action-btn { display: flex; flex: 1; align-items: center; justify-content: center; gap: var(--space-1); min-height: 44px; padding: 8px 10px; border: 1px solid var(--accent); border-radius: var(--radius-md); background: var(--accent-soft); color: var(--accent); font-weight: 700; transition: all var(--transition); }
.history-action-btn:hover { background: var(--accent); color: #062333; }
.history-action-btn.delete { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.history-action-btn.delete:hover { background: var(--danger); color: #fff; }

.settings-panel { display: none; position: fixed; z-index: 999; top: var(--header-height); right: 0; width: min(100%, 360px); max-height: calc(100vh - var(--header-height)); overflow-y: auto; border: 1px solid var(--border-strong); border-top: 0; border-radius: 0 0 0 var(--radius-lg); background: var(--surface-3); box-shadow: var(--shadow-3); }
.settings-panel.active { display: flex; flex-direction: column; }
.settings-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4); border-bottom: 1px solid var(--border-subtle); }
.settings-header h2 { display: flex; align-items: center; gap: var(--space-2); font-size: 1.3rem; }
.settings-header h2 i { color: var(--accent); }
.close-btn { min-width: 44px; border: 0; background: transparent; color: var(--text-body); font-size: 1.25rem; }
.close-btn:hover { color: var(--accent); }
.settings-body { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4); }
.settings-group { display: flex; flex-direction: column; gap: var(--space-2); }
.settings-group h3 { padding-bottom: var(--space-2); border-bottom: 1px solid var(--border-subtle); color: var(--text-muted); font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; }
.setting-btn { display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-body); font-weight: 600; text-align: left; transition: all var(--transition); }
.setting-btn:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.setting-btn.danger { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.setting-btn.danger:hover { background: var(--danger); color: #fff; }

.footer { width: 100%; margin-top: auto; padding: var(--space-4) max(var(--space-4), env(safe-area-inset-left)); border-top: 1px solid var(--border-subtle); background: var(--surface-1); }
.footer-content { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); max-width: 1400px; margin: 0 auto; text-align: center; }
.footer-info { display: flex; align-items: center; gap: var(--space-2); color: var(--text-muted); font-size: .85rem; }
.footer-info i { color: var(--accent); }
.footer-links, .footer-links p { color: var(--text-muted); font-size: .8rem; }
.footer-links p { margin: 0; }

.notification { border: 1px solid rgba(255, 255, 255, .2); box-shadow: var(--shadow-3) !important; }
.value-updating { animation: valueFlash .3s var(--ease); }
.game-count-changing { animation: valueFlash .3s var(--ease); }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cardEnter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes valueFlash { 0% { background: transparent; } 45% { background: var(--accent-soft); } 100% { background: transparent; } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }

@media (min-width: 768px) {
    .main-content { padding: calc(var(--header-height) + var(--space-6)) var(--space-5) var(--space-6); }
    .calc-layout { grid-template-columns: 1fr 1fr; }
    .deals-grid { grid-template-columns: repeat(2, 1fr); }
    .history-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .calc-layout { grid-template-columns: 280px minmax(0, 1fr) 380px; }
    .deals-grid { grid-template-columns: repeat(3, 1fr); }
    .history-grid { grid-template-columns: repeat(3, 1fr); }
    .calc-results { position: sticky; top: calc(var(--header-height) + var(--space-3)); align-self: start; }
}

@media (min-width: 1400px) { .deals-grid { grid-template-columns: repeat(4, 1fr); } }

@media (max-width: 900px) {
    .calc-results { position: static; }
}

@media (max-width: 640px) {
    html { font-size: 14px; }
    :root { --header-height: 112px; }
    .main-content { padding: calc(var(--header-height) + var(--space-3)) max(var(--space-3), env(safe-area-inset-left)) var(--space-3) max(var(--space-3), env(safe-area-inset-right)); }
    .header-content { padding: 0 max(var(--space-2), env(safe-area-inset-left)); gap: var(--space-2); }
    .header { height: 112px; }
    .header.shrink { height: 100px; }
    .header-content { flex-wrap: wrap; align-content: center; }
    .logo-text h1, .tagline, .nav-label { display: none; }
    .logo-icon { font-size: 1.5rem; }
    .header-search-container { order: 3; width: 100%; min-width: 0; flex: 1 0 100%; }
    .header-search-container .deals-search { min-height: 40px; padding: 6px 8px; }
    .header-search-container #gameSearchInput { font-size: .85rem; }
    .header-search-container .search-clear { min-height: 30px; padding: 4px 6px; }
    .header.shrink .header-search-container { max-width: none; }
    .header-nav { gap: var(--space-1); overflow-x: auto; flex-wrap: nowrap; }
    .nav-btn { min-width: 40px; padding: 6px 7px; }
    .section { padding: var(--space-3); margin-bottom: var(--space-3); border-radius: var(--radius-md); }
    h1 { font-size: 1.75rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.2rem; }
    .deals-controls { justify-content: stretch; }
    .deals-filter { width: 100%; flex-wrap: wrap; justify-content: stretch; }
    #dealsSearchInput { flex: 1 1 100%; width: 100%; }
    #dealsSort { flex: 1; }
    .deal-prices { grid-template-columns: 1fr; }
    .tax-presets { grid-template-columns: repeat(3, 1fr); gap: var(--space-1); }
    .preset-btn { border-width: 1px; border-radius: var(--radius-sm); }
    .games-header { align-items: flex-start; flex-direction: column; }
    .games-stats { justify-content: flex-start; }
    .settings-panel { width: 100%; border-radius: 0; }
    .footer { padding: var(--space-3); }
    .footer-info { align-items: flex-start; font-size: .78rem; }
    .pagination { gap: var(--space-2); }
    .pagination-btn { padding: 8px 10px; font-size: .85rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    .header, .nav-btn, .settings-panel { display: none; }
    .main-content { padding: 0; }
    .section { border: 1px solid #000; box-shadow: none; }
}
