.casio-calculator-wrapper * { margin: 0; padding: 0; box-sizing: border-box; }

.casio-calculator-wrapper {
  --body-1: #2a3a5c;
  --body-2: #1a2845;
  --body-3: #0f1830;
  --screen-bg-1: #b9c7ac;
  --screen-bg-2: #a5b599;
  --screen-border: #3a4a2a;
  --screen-text: #141414;
  --btn-num-1: #f0ece0;
  --btn-num-2: #d6d0c0;
  --btn-num-shadow: #a8a294;
  --btn-fn-1: #475a7a;
  --btn-fn-2: #2e3e5e;
  --btn-fn-shadow: #1a2540;
  --btn-op-1: #5a6a8a;
  --btn-op-2: #445270;
  --btn-eq-1: #6a7a9a;
  --btn-eq-2: #525c80;
  --btn-ac-1: #9a5a5a;
  --btn-ac-2: #6a3a3a;
  --shift-yellow: #f4c430;
  --alpha-red: #e74c3c;
  --text-light: #e2e8f0;
  --text-dim: #94a3b8;

  font-family: 'Inter', sans-serif;
  width: 100%;
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--text-light);
  background: transparent;
}

.casio-calculator-wrapper .app {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}

.casio-calculator-wrapper .calculator {
  width: 402px;
  background: linear-gradient(160deg, var(--body-1) 0%, var(--body-2) 60%, var(--body-3) 100%);
  border-radius: 20px;
  padding: 22px;
  box-shadow:
    0 30px 70px rgba(0,0,0,0.6),
    0 0 0 1px rgba(255,255,255,0.06),
    inset 0 1px 0 rgba(255,255,255,0.18),
    inset 0 -2px 0 rgba(0,0,0,0.3);
  position: relative;
  user-select: none;
}

.casio-calculator-wrapper .calculator::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 13px;
  pointer-events: none;
}

.casio-calculator-wrapper .brand-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 6px 4px;
}
.casio-calculator-wrapper .brand-casio {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 1.5px;
  line-height: 1;
}
.casio-calculator-wrapper .brand-right { text-align: right; }
.casio-calculator-wrapper .brand-model {
  display: block;
  font-size: 13px;
  color: #dbe4f0;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.casio-calculator-wrapper .brand-vpam {
  display: block;
  font-size: 9px;
  color: #8b9bb5;
  letter-spacing: 2px;
  margin-top: 2px;
}

.casio-calculator-wrapper .solar {
  height: 16px;
  margin: 8px 4px 12px;
  border-radius: 2px;
  background:
    repeating-linear-gradient(90deg, #1a1a28 0, #1a1a28 6px, #2a2a3a 6px, #2a2a3a 7px),
    linear-gradient(180deg, #2a2a38, #15151f);
  border: 1px solid #050510;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.05);
  position: relative;
}
.casio-calculator-wrapper .solar::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 50%);
  border-radius: 2px;
}

.casio-calculator-wrapper .screen {
  background: linear-gradient(180deg, var(--screen-bg-1) 0%, var(--screen-bg-2) 100%);
  border-radius: 4px;
  padding: 8px 12px 10px;
  margin-bottom: 16px;
  font-family: 'Share Tech Mono', monospace;
  min-height: 96px;
  border: 2px solid var(--screen-border);
  box-shadow:
    inset 0 2px 10px rgba(0,0,0,0.25),
    0 1px 0 rgba(255,255,255,0.1);
  color: var(--screen-text);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.casio-calculator-wrapper .screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0, transparent 2px, rgba(0,0,0,0.025) 2px, rgba(0,0,0,0.025) 3px);
  pointer-events: none;
}

.casio-calculator-wrapper .status-bar {
  display: flex;
  gap: 14px;
  font-size: 11px;
  height: 14px;
  color: var(--screen-text);
  font-weight: 700;
  letter-spacing: 1px;
  position: relative;
  z-index: 1;
}
.casio-calculator-wrapper .status-bar span { visibility: hidden; }
.casio-calculator-wrapper .status-bar span.active { visibility: visible; }
.casio-calculator-wrapper .status-bar .spacer { flex: 1; }

.casio-calculator-wrapper .expr-line {
  flex: 1;
  font-size: 19px;
  min-height: 26px;
  display: flex;
  align-items: center;
  overflow-x: auto;
  white-space: nowrap;
  margin-top: 2px;
  position: relative;
  z-index: 1;
  scrollbar-width: none;
}
.casio-calculator-wrapper .expr-line::-webkit-scrollbar { display: none; }

.casio-calculator-wrapper .cursor {
  display: inline-block;
  width: 1.5px;
  height: 18px;
  background: var(--screen-text);
  animation: blink 1.1s steps(1) infinite;
  margin-left: 1px;
  vertical-align: middle;
}
@keyframes blink { 0%,50% { opacity: 1; } 51%,100% { opacity: 0; } }

.casio-calculator-wrapper .result-line {
  font-size: 16px;
  min-height: 22px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  overflow-x: auto;
  white-space: nowrap;
  opacity: 0.78;
  position: relative;
  z-index: 1;
  scrollbar-width: none;
}
.casio-calculator-wrapper .result-line::-webkit-scrollbar { display: none; }
.casio-calculator-wrapper .result-line.error { color: #8a2222; opacity: 1; }

.casio-calculator-wrapper .control-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.6fr 1fr 1fr;
  gap: 7px;
  margin-bottom: 10px;
  align-items: center;
}

.casio-calculator-wrapper .replay {
  background: #142040;
  border-radius: 32px;
  padding: 5px;
  height: 62px;
  display: grid;
  grid-template-areas: ". up ." "left center right" ". down .";
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 2px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}
.casio-calculator-wrapper .replay button {
  background: linear-gradient(180deg, #4a5a7a, #3a4a6a);
  border: none;
  color: #cbd5e1;
  font-size: 9px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}
.casio-calculator-wrapper .replay button:hover { background: linear-gradient(180deg, #5a6a8a, #4a5a7a); }
.casio-calculator-wrapper .replay button:active { transform: scale(0.95); }
.casio-calculator-wrapper .replay-up { grid-area: up; }
.casio-calculator-wrapper .replay-down { grid-area: down; }
.casio-calculator-wrapper .replay-left { grid-area: left; }
.casio-calculator-wrapper .replay-right { grid-area: right; }
.casio-calculator-wrapper .replay-center {
  grid-area: center;
  background: linear-gradient(180deg, #2a3a5a, #1a2845);
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}
.casio-calculator-wrapper .replay-center::after {
  content: '';
  width: 6px; height: 6px;
  background: #4a5a7a;
  border-radius: 50%;
  margin: auto;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

.casio-calculator-wrapper .keypad {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
}

.casio-calculator-wrapper .btn {
  position: relative;
  height: 44px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.06s, box-shadow 0.06s, background 0.15s;
  overflow: hidden;
  padding-top: 4px;
}
.casio-calculator-wrapper .btn:active { transform: translateY(2px); }
.casio-calculator-wrapper .btn .shift-lbl {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 8px;
  color: var(--shift-yellow);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.3px;
}
.casio-calculator-wrapper .btn .alpha-lbl {
  position: absolute;
  bottom: 3px;
  right: 5px;
  font-size: 8px;
  color: var(--alpha-red);
  font-weight: 700;
  line-height: 1;
}
.casio-calculator-wrapper .btn .main-lbl {
  font-size: 14px;
  line-height: 1;
  margin-top: 5px;
}
.casio-calculator-wrapper .btn .main-lbl.small { font-size: 11px; }
.casio-calculator-wrapper .btn .main-lbl.tiny { font-size: 9px; letter-spacing: 0.3px; }

.casio-calculator-wrapper .btn-fn {
  background: linear-gradient(180deg, var(--btn-fn-1), var(--btn-fn-2));
  color: #fff;
  box-shadow: 0 2px 0 var(--btn-fn-shadow), inset 0 1px 0 rgba(255,255,255,0.15);
}
.casio-calculator-wrapper .btn-fn:active { box-shadow: 0 0 0 var(--btn-fn-shadow), inset 0 1px 0 rgba(255,255,255,0.15); }

.casio-calculator-wrapper .btn-num {
  background: linear-gradient(180deg, var(--btn-num-1), var(--btn-num-2));
  color: #1a1a1a;
  box-shadow: 0 2px 0 var(--btn-num-shadow), inset 0 1px 0 rgba(255,255,255,0.6);
}
.casio-calculator-wrapper .btn-num:active { box-shadow: 0 0 0 var(--btn-num-shadow); }
.casio-calculator-wrapper .btn-num .main-lbl { margin-top: 0; font-size: 16px; }

.casio-calculator-wrapper .btn-op {
  background: linear-gradient(180deg, var(--btn-op-1), var(--btn-op-2));
  color: #fff;
  box-shadow: 0 2px 0 var(--btn-fn-shadow), inset 0 1px 0 rgba(255,255,255,0.15);
}
.casio-calculator-wrapper .btn-op:active { box-shadow: 0 0 0 var(--btn-fn-shadow); }
.casio-calculator-wrapper .btn-op .main-lbl { margin-top: 0; font-size: 16px; }

.casio-calculator-wrapper .btn-eq {
  background: linear-gradient(180deg, var(--btn-eq-1), var(--btn-eq-2));
  color: #fff;
  box-shadow: 0 2px 0 var(--btn-fn-shadow), inset 0 1px 0 rgba(255,255,255,0.2);
}
.casio-calculator-wrapper .btn-eq:active { box-shadow: 0 0 0 var(--btn-fn-shadow); }
.casio-calculator-wrapper .btn-eq .main-lbl { margin-top: 0; font-size: 18px; font-weight: 700; }

.casio-calculator-wrapper .btn-ac {
  background: linear-gradient(180deg, var(--btn-ac-1), var(--btn-ac-2));
  color: #fff;
  box-shadow: 0 2px 0 #4a2020, inset 0 1px 0 rgba(255,255,255,0.15);
}
.casio-calculator-wrapper .btn-ac:active { box-shadow: 0 0 0 #4a2020; }
.casio-calculator-wrapper .btn-ac .main-lbl { margin-top: 0; font-size: 14px; }

.casio-calculator-wrapper .btn-shift {
  background: linear-gradient(180deg, #4a3a20, #2e2410);
  color: var(--shift-yellow);
  box-shadow: 0 2px 0 #1a1208, inset 0 1px 0 rgba(255,255,255,0.1);
  font-size: 11px;
  letter-spacing: 0.5px;
}
.casio-calculator-wrapper .btn-shift:active { box-shadow: 0 0 0 #1a1208; }
.casio-calculator-wrapper .btn-shift.active {
  background: linear-gradient(180deg, #f4c430, #d4a410);
  color: #1a1208;
  box-shadow: 0 0 12px rgba(244,196,48,0.5), 0 2px 0 #8a6a00;
}

.casio-calculator-wrapper .btn-alpha {
  background: linear-gradient(180deg, #4a2020, #2e1010);
  color: var(--alpha-red);
  box-shadow: 0 2px 0 #1a0808, inset 0 1px 0 rgba(255,255,255,0.1);
  font-size: 11px;
  letter-spacing: 0.5px;
}
.casio-calculator-wrapper .btn-alpha:active { box-shadow: 0 0 0 #1a0808; }
.casio-calculator-wrapper .btn-alpha.active {
  background: linear-gradient(180deg, #e74c3c, #c43c2c);
  color: #fff;
  box-shadow: 0 0 12px rgba(231,76,60,0.5), 0 2px 0 #8a1a1a;
}

.casio-calculator-wrapper .btn-mode, .casio-calculator-wrapper .btn-on {
  background: linear-gradient(180deg, #3d4a6a, #2a3550);
  color: #cbd5e1;
  font-size: 11px;
  box-shadow: 0 2px 0 #1a2540, inset 0 1px 0 rgba(255,255,255,0.1);
}
.casio-calculator-wrapper .btn-mode:active, .casio-calculator-wrapper .btn-on:active { box-shadow: 0 0 0 #1a2540; }

.casio-calculator-wrapper .history-panel {
  width: 340px;
  background: rgba(15, 24, 48, 0.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 18px;
  padding: 20px;
  border: 1px solid rgba(255,255,255,0.06);
  max-height: 640px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    
}

.casio-calculator-wrapper .history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.casio-calculator-wrapper .history-title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.casio-calculator-wrapper .history-status {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(34,197,94,0.15);
  color: #4ade80;
  border: 1px solid rgba(34,197,94,0.2);
}
.casio-calculator-wrapper .history-status.offline {
  background: rgba(234,179,8,0.15);
  color: #facc15;
  border-color: rgba(234,179,8,0.2);
}
.casio-calculator-wrapper .history-clear {
  background: rgba(231,76,60,0.15);
  color: #f87171;
  border: 1px solid rgba(231,76,60,0.25);
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s;
}
.casio-calculator-wrapper .history-clear:hover { background: rgba(231,76,60,0.25); }

.casio-calculator-wrapper .history-list {
  flex: 1;
  overflow-y: auto;
  margin-right: -6px;
  padding-right: 6px;
}
.casio-calculator-wrapper .history-list::-webkit-scrollbar { width: 5px; }
.casio-calculator-wrapper .history-list::-webkit-scrollbar-track { background: rgba(255,255,255,0.03); border-radius: 3px; }
.casio-calculator-wrapper .history-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 3px; }

.casio-calculator-wrapper .history-item {
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 10px 13px;
  margin-bottom: 8px;
  font-family: 'Share Tech Mono', monospace;
  cursor: pointer;
  transition: all 0.15s;
}
.casio-calculator-wrapper .history-item:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(244,196,48,0.25);
  transform: translateX(-2px);
}
.casio-calculator-wrapper .history-expr {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 4px;
  word-break: break-all;
  line-height: 1.3;
}
.casio-calculator-wrapper .history-result {
  color: var(--shift-yellow);
  font-size: 17px;
  font-weight: 600;
  word-break: break-all;
}
.casio-calculator-wrapper .history-time {
  color: #475569;
  font-size: 10px;
  margin-top: 5px;
  font-family: 'Inter', sans-serif;
}
.casio-calculator-wrapper .history-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 50px 20px;
  font-size: 13px;
  line-height: 1.6;
}
.casio-calculator-wrapper .history-empty svg {
  margin: 0 auto 12px;
  opacity: 0.4;
  display: block;
}

.casio-calculator-wrapper .toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: rgba(10,15,30,0.95);
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 13px;
  transition: transform 0.3s cubic-bezier(0.2,0.8,0.2,1);
  z-index: 1000;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
.casio-calculator-wrapper .toast.show { transform: translateX(-50%) translateY(0); }

.casio-calculator-wrapper .hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 14px;
  padding: 0 20px;
  line-height: 1.6;
}
.casio-calculator-wrapper .hint kbd {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  color: #cbd5e1;
}

@media (max-width: 820px) {
  .casio-calculator-wrapper .app { flex-direction: column; align-items: center; }
  .casio-calculator-wrapper .calculator { width: 100%; max-width: 402px; }
  .casio-calculator-wrapper .history-panel { width: 100%; max-width: 402px; max-height: 400px; }
}
@media (max-width: 440px) {
  .casio-calculator-wrapper { padding: 12px; }
  .casio-calculator-wrapper .calculator { padding: 16px; }
  .casio-calculator-wrapper .btn { height: 40px; }
  .casio-calculator-wrapper .brand-casio { font-size: 20px; }
}


/* ===== Fullscreen Button & Overlay ===== */
.casio-calculator-wrapper {
    position: relative;
}

.casio-fs-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
    background: rgba(197, 18, 43, 0.96);
    border: 1px solid rgba(255,255,255,0.2);
    color: #cbd5e1;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}
.casio-fs-btn:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}


/* Hide history by default (for mobile) */
.casio-calculator-wrapper .history-panel {
    display: none !important;
}

/* Show history only on larger screens (desktop) */
@media (min-width: 900px) {
    .casio-calculator-wrapper .history-panel {
        display: flex !important;
    }
}

/* When fullscreen is active/////////////////////////////////////////////////////// */
.casio-calculator-wrapper.casio-is-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #0a0f1e;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: auto;
}

/* Scale up the calculator slightly in fullscreen for better visibility */
.casio-calculator-wrapper.casio-is-fullscreen .app {
    transform: scale(1.1);
    transform-origin: center center;
}

/* Move the button to top-right of the screen in fullscreen */
.casio-calculator-wrapper.casio-is-fullscreen .casio-fs-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(197, 18, 43, 0.96);
}