@charset "UTF-8";
/* === THEME VARIABLES === */
:root {
    /* Theme: Midnight (Default) - Updated to purely neutral gray */
    --bg-body: #1a1a1a;
    --bg-body-glow-1: rgba(50, 50, 50, 0.15);
    --bg-body-glow-2: rgba(40, 40, 40, 0.1);
    
    --calc-body-bg: linear-gradient(145deg, #a3a3a3 0%, #6b7280 40%, #4b5563 100%);
    --calc-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    --calc-highlight: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, transparent 50%);
    
    --display-bg: linear-gradient(180deg, #c8d8c0 0%, #a0b898 100%);
    --display-text: #1a2a1f;
    
    --btn-top-bg: linear-gradient(180deg, #a8b8c8 0%, #7888a0 100%);
    --btn-top-text: #ffffff;
    
    --btn-func-bg: linear-gradient(180deg, #4a4e55 0%, #2a2e35 100%);
    --btn-func-text: #e8e8e8;
    
    --btn-num-bg: linear-gradient(180deg, #f8f8f8 0%, #d8d8d8 100%);
    --btn-num-text: #1a1a1a;
    
    --btn-accent-bg: linear-gradient(180deg, #f87038 0%, #d04810 100%);
    --btn-exe-bg: linear-gradient(180deg, #48a0d0 0%, #3080b0 100%);
    
    --brand-color: #2d3748;
    --brand-subtitle-color: rgba(0, 0, 0, 0.65);
    --brand-text-shadow: 0 1px 1px rgba(255,255,255,0.4);
    --subtext-color: #9ca3af;
    --accent-text: #40b0a0;
}

[data-theme="classic"] {
    /* Theme: Classic (Standard Casio Look) */
    --bg-body: #536878; /* Slate background */
    --bg-body-glow-1: transparent;
    --bg-body-glow-2: transparent;
    
    --calc-body-bg: linear-gradient(180deg, #3b4854 0%, #2a343d 100%);
    --calc-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    --calc-highlight: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, transparent 50%);
    
    --display-bg: linear-gradient(180deg, #c8d8c0 0%, #a0b898 100%);
    --display-text: #1a2a1f;
    
    --btn-top-bg: linear-gradient(180deg, #4a5a6a 0%, #3a4a5a 100%);
    --btn-top-text: #ffffff;
    
    --btn-func-bg: linear-gradient(180deg, #3a3a3a 0%, #222222 100%);
    --btn-func-text: #e8e8e8;
    
    --btn-num-bg: linear-gradient(180deg, #f0f0f0 0%, #d0d0d0 100%);
    --btn-num-text: #1a1a1a;
    
    --btn-accent-bg: linear-gradient(180deg, #f08040 0%, #d06020 100%);
    --btn-exe-bg: linear-gradient(180deg, #3070a0 0%, #205080 100%);
    
    --brand-color: #f0f0f0;
    --brand-subtitle-color: var(--brand-subtitle-color);
    --brand-text-shadow: var(--brand-text-shadow);
    --subtext-color: #c8ced4;
    --accent-text: #00a090;
}

/* === BASE STYLES === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    touch-action: none !important; /* Disable zoom/pan gestures */
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    overflow: hidden !important; /* Prevent side scrollbars */
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

html::-webkit-scrollbar, body::-webkit-scrollbar, *::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent !important;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

main {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--calc-body-bg);
    box-shadow: var(--calc-shadow),
                inset 0 2px 4px rgba(255, 255, 255, 0.05),
                inset 0 -4px 8px rgba(0, 0, 0, 0.3);
    border-radius: 12px 12px 24px 24px;
    width: 320px;
    padding: 16px 12px 20px;
    position: relative;
    transform-style: preserve-3d;
    transition: background 0.5s ease, box-shadow 0.5s ease;
}

.background-effects {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background: transparent !important;
}

main::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--calc-highlight);
    pointer-events: none;
}

/* Header Section */
.heading {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 2px 12px;
    width: 100%;
    padding: 0 8px;
    margin-bottom: 16px;
    align-items: end;
}

.brand-container {
    grid-column: 1;
    grid-row: 1 / 3;
}

.logo-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.logo-line1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--brand-color);
    line-height: 1;
    text-shadow: var(--brand-text-shadow);
}

.logo-line2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 3px;
    color: var(--brand-color);
    line-height: 1.2;
    text-shadow: var(--brand-text-shadow);
}

.logo-line3 {
    font-size: 0.55rem;
    font-weight: 300;
    font-style: italic;
    color: rgba(255, 255, 255, 0.62);
    line-height: 1;
    margin-top: 2px;
}

.header-right {
    grid-column: 2;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    margin-top: 4px;
}

.headingtext1 {
    font-size: 0.5rem;
    color: var(--accent-text);
    font-weight: 700;
    font-style: italic;
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(64, 176, 160, 0.3);
    margin-bottom: 2px;
}

.headingtext2 {
    font-size: 0.4rem;
    color: rgba(255, 255, 255, 0.6);
    text-align: right;
    margin-right: 8px;
    letter-spacing: 0.3px;
}

/* Theme Toggle Button */
.theme-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: var(--subtext-color);
}

.theme-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--brand-color);
}

.icon-settings::before {
    content: "⚙️";
    font-size: 12px;
}

.solar {
    grid-column: 1 / 3;
    grid-row: 3;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    border: 2px solid #0a0c0e;
    border-radius: 6px;
    padding: 3px;
    background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
    box-shadow: 
        inset 0 2px 4px rgba(0,0,0,0.5),
        0 1px 0 rgba(255,255,255,0.05);
    width: 100%;
    margin-top: 8px;
}

.solar div {
    background: linear-gradient(180deg, #3a3a3a 0%, #252525 50%, #3a3a3a 100%);
    border-radius: 2px;
    box-shadow: inset 0 0 8px rgba(0,0,0,0.5);
    height: 14px;
}

/* Display Section */
.displayarea {
    width: 100%;
    padding: 0 8px;
    position: relative;
    margin-bottom: 12px;
}

.display-container {
    background: var(--display-bg);
    border-radius: 4px;
    padding: 12px 10px;
    box-shadow: 
        inset 0 2px 8px rgba(0, 40, 20, 0.3),
        inset 0 -2px 4px rgba(255, 255, 255, 0.1),
        0 2px 0 rgba(0,0,0,0.3);
    min-height: 155px;
    position: relative;
    transition: background 0.3s ease;
}

.sub-menu {
    display: none;
    position: absolute;
    inset: 0;
    background: var(--display-bg);
    color: var(--display-text);
    z-index: 20;
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.1rem;
    padding: 4px 8px;
    box-sizing: border-box;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 1fr);
    align-items: center;
    border-radius: inherit;
}

#data-grid td, #data-grid th {
    border: 1px solid rgba(0, 40, 20, 0.3);
    text-align: right;
    padding: 2px 4px;
    height: 1.8rem;
    position: relative;
}

#data-grid td.active {
    background: #000;
    color: #c8d8c0;
}

#data-grid th {
    text-align: center;
    background: rgba(0, 40, 20, 0.1);
    font-weight: bold;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding: 0 2px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #3d6648;
}

.status-indicators {
    display: flex;
    gap: 8px;
}

.indicator {
    opacity: 0.15;
    transition: opacity 0.2s, color 0.2s;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    color: #1a1a1a;
}

.indicator.active {
    opacity: 1;
    color: #1a1a1a;
}

/* Specific colors can be set if needed, but the LCD uses solid dark pixels */
.indicator.shift { color: #1a1a1a; }
.indicator.alpha { color: #1a1a1a; }
.indicator.sto   { color: #1a1a1a; }
.indicator.rcl   { color: #1a1a1a; }
.indicator.deg   { color: #1a1a1a; }
.indicator.rad   { color: #1a1a1a; }

.display {
    background: transparent;
    padding-top: 15px;
    padding-bottom: 5px;
    border: none;
    outline: none;
    width: 100%;
    min-height: 50px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.4rem;
    color: var(--display-text);
    --caret-color: var(--display-text);
    --selection-background-color: rgba(0, 0, 0, 0.1);
    --selection-color: var(--display-text);
    --contains-highlight-background-color: transparent;
}

.display::part(virtual-keyboard-toggle) {
    display: none;
}

.display::part(menu-toggle) {
    display: none;
}

.display::part(container) {
    padding-top: 10px;
    align-items: flex-start;
}

.display::part(mathfield) {
    padding-top: 10px;
    line-height: 1.5;
}

#casiotext {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    color: #7a9a82;
    opacity: 1;
    animation: startupFade 3s forwards;
    pointer-events: none;
}

@keyframes startupFade {
    0%, 60% { opacity: 1; }
    100% { opacity: 0; }
}

/* Replay Button */
#replay {
    grid-column: 3 / 5;
    grid-row: 1 / 3;
    background: linear-gradient(180deg, #b8c8d8 0%, #8898a8 100%);
    box-shadow: 
        inset 0 1px 0 rgba(255,255,255,0.3),
        0 4px 6px rgba(0,0,0,0.3);
    border: none;
    border-radius: 50%;
    width: 90%;
    height: 95%;
    margin: auto;
    font-size: 0.55rem;
    font-weight: 700;
    color: #4a5a6a;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#replay .main-label {
    pointer-events: none;
    z-index: 2;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.replay-dir {
    position: absolute;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #334;
    font-size: 0.6rem;
}

.replay-dir:hover {
    background: rgba(255,255,255,0.2);
}

.replay-dir:active {
    background: rgba(0,0,0,0.1);
}

.replay-dir.up { top: 0; left: 0; right: 0; height: 35%; align-items: flex-start; padding-top: 6px; }
.replay-dir.down { bottom: 0; left: 0; right: 0; height: 35%; align-items: flex-end; padding-bottom: 6px; }
.replay-dir.left { top: 0; bottom: 0; left: 0; width: 35%; justify-content: flex-start; padding-left: 6px; }
.replay-dir.right { top: 0; bottom: 0; right: 0; width: 35%; justify-content: flex-end; padding-right: 6px; }

/* Button Areas */
.buttonarea1, .buttonarea2 {
    display: grid;
    width: 100%;
    padding: 0 4px;
    gap: 6px;
}

.buttonarea1 {
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(5, 1fr);
    margin-bottom: 14px;
    row-gap: 14px; /* extra vertical gap so shift-labels (shown above buttons) have visual breathing room */
}

.buttonarea2 {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

/* Button Styles */
.btn {
    position: relative;
    border: none;
    cursor: pointer;
    font-family: 'Segoe UI', sans-serif;
    font-weight: 600;
    transition: all 0.1s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
    border-radius: 4px 4px 40% 40%;
    box-sizing: border-box;
    overflow: hidden;
    padding: 2px;
    box-shadow: 
        0 3px 0 rgba(0,0,0,0.3),
        0 4px 6px rgba(0,0,0,0.2),
        inset 0 1px 0 rgba(255,255,255,0.15);
}

.btn:hover {
    filter: brightness(1.1);
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 
        0 1px 0 rgba(0,0,0,0.3),
        0 2px 4px rgba(0,0,0,0.2),
        inset 0 1px 2px rgba(0,0,0,0.2);
}

.btn .main-label {
    font-size: 0.6rem;
    z-index: 1;
    max-width: 70%;
    max-height: 70%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn .main-label svg {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
}

.btn .shift-label,
.btn .base-label {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.45rem;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: flex-start;
    pointer-events: none;
    white-space: nowrap;
}

.key-fraction {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

.btn .shift-label svg,
.btn .base-label svg,
.btn .alpha-label svg {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
}

.btn .shift-label {
    color: #f0a030;
}

.btn .base-label {
    color: #00bcd4;
}

.btn .alpha-label {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.45rem;
    color: #c01844;
    font-weight: 700;
}

/* Button Types */
.button1 {
    background: var(--btn-func-bg);
    color: var(--btn-func-text);
    height: 36px;
    min-height: 36px;
    /* shift-label sits top-left via absolute; main-label centers in remaining space */
    justify-content: center;
    padding-top: 8px; /* push main-label down below the shift-label */
}

.button2 {
    background: var(--btn-num-bg);
    color: var(--btn-num-text);
    height: 38px;
    min-height: 38px;
}

.button2 .main-label {
    font-size: 1rem;
    font-weight: 700;
}

.button3 {
    background: var(--btn-top-bg);
    color: var(--btn-top-text);
    height: 32px;
    min-height: 32px;
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}

.button3.active-shift {
    background: linear-gradient(180deg, #f0a030 0%, #d08020 100%) !important;
    box-shadow: 
        0 3px 0 rgba(0,0,0,0.3),
        0 4px 6px rgba(0,0,0,0.2),
        inset 0 1px 0 rgba(255,255,255,0.3),
        0 0 12px rgba(240, 160, 48, 0.4);
}

.button3.active-alpha {
    background: linear-gradient(180deg, #e63946 0%, #b32a35 100%) !important;
    color: white !important;
    box-shadow: 
        0 3px 0 rgba(0,0,0,0.3),
        0 4px 6px rgba(0,0,0,0.2),
        inset 0 1px 0 rgba(255,255,255,0.3),
        0 0 12px rgba(230, 57, 70, 0.5);
}

#del, #ac {
    background: var(--btn-accent-bg);
    color: white;
}

#del .main-label, #ac .main-label {
    font-size: 0.75rem;
}

[data-action="equals"] {
    background: var(--btn-exe-bg);
    color: white;
}

/* Responsive */
@media (max-width: 360px) {
    main {
        width: 290px;
        padding: 12px 8px 16px;
    }
    .button1, .button3 { height: 28px; min-height: 28px; }
    .button2 { height: 34px; min-height: 34px; }
    .btn .main-label { font-size: 0.6rem; }
    .button2 .main-label { font-size: 0.9rem; }
}

@media (min-width: 500px) {
    main {
        width: 340px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Placeholder and Cursor UI Tweaks */
math-field {
    --placeholder-color: transparent; /* Hides solid black block */
    --primary-color: var(--display-text) !important;
    --smart-fence-color: var(--display-text) !important;
    --selection-background-color: rgba(26, 42, 31, 0.2) !important;
    --contains-highlight-color: var(--display-text) !important;
    --contains-highlight-background-color: transparent !important;
    color: var(--display-text) !important;
    fill: var(--display-text) !important;
}
math-field::part(placeholder) {
    border: 1px dashed #555 !important;
    min-width: 14px;
    min-height: 16px;
    display: inline-block;
    background: transparent;
}
math-field::part(cursor) {
    border-left: 2px solid #000 !important;
}
/* Fallback for older browsers / MathLive internals without part support */
.ML__placeholder {
    border: 1px dashed #555 !important;
    color: transparent !important;
    min-width: 14px;
    min-height: 16px;
    display: inline-block;
    background: transparent;
}

#result-display {
    overflow: hidden;
    white-space: nowrap;
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    min-height: 28px;
    width: 100%;
}

.casio-res-val {
    display: inline-flex;
    align-items: baseline;
}

.casio-mem-tag {
    margin-left: 8px;
    font-size: 0.65em;
    font-weight: 700;
    font-family: 'Share Tech Mono', monospace;
    color: var(--display-text);
    opacity: 0.95;
    line-height: 1;
    align-self: baseline;
    letter-spacing: 0.5px;
}

.casio-fraction {
    display: inline-flex;
    flex-direction: column;
    vertical-align: middle;
    text-align: center;
    line-height: 1;
    font-family: inherit;
    font-size: 0.85em;
    margin: 0 4px;
}

.casio-fraction .casio-num {
    border-bottom: 2px solid currentColor;
    padding: 0 4px 2px 4px;
    display: block;
}

.casio-fraction .casio-den {
    padding: 2px 4px 0 4px;
    display: block;
}

.display-container.is-off {
    background: var(--display-bg);
}
.display-container.is-off .status-bar,
.display-container.is-off math-field,
.display-container.is-off #result-display,
.display-container.is-off .indicator,
.display-container.is-off .sub-menu {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}
.display-container.is-off #casiotext {
    display: block !important;
    opacity: 1 !important;
    animation: none !important;
}


