/* Windows 98 complete adaptation */
:root {
  --win95-gray: #C0C0C0;
  --win95-dark-gray: #808080;
  --win95-light-gray: #FFFFFF;
  --win95-black: #000000;
  --win95-blue: #000080;
  --win95-active-title-bar-blue: #0000AA;
  --win95-red: #FF0000;
  --win95-green: #008000;
}

body {
  background: var(--win95-gray);
  font-family: 'MS Sans Serif', 'Arial', sans-serif;
  margin: 0;
  padding: 28px 24px 48px;
  color: var(--win95-black);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
}

.win95-window {
  background: var(--win95-gray);
  width: 360px;
  border-top: 3px solid var(--win95-light-gray);
  border-left: 3px solid var(--win95-light-gray);
  border-bottom: 3px solid var(--win95-dark-gray);
  border-right: 3px solid var(--win95-dark-gray);
  box-shadow: 2px 2px 0 var(--win95-black);
  display: flex;
  flex-direction: column;
}

.title-bar {
  background: linear-gradient(to right, var(--win95-active-title-bar-blue), #1084D0);
  padding: 2px 6px 2px 4px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  color: var(--win95-light-gray);
  font-weight: bold;
  font-size: 14px;
  user-select: none;
  border-bottom: 1px solid var(--win95-black);
}

.title-bar.mini {
  font-size: 12px;
  background: linear-gradient(to right, var(--win95-active-title-bar-blue), #1084D0);
}

.title-bar-text { padding-left: 4px; }

.window-body { padding: 14px 14px 18px; }

.counter-container { margin-top: 10px; }

.count-display {
  font-size: 52px;
  text-align: center;
  margin: 14px 0 24px;
  font-weight: bold;
  font-family: 'MS Sans Serif', 'Arial', sans-serif;
  color: var(--win95-black);
  text-shadow: 1px 1px 0 var(--win95-light-gray);
}

.win-input {
  width: 100%;
  box-sizing: border-box;
  padding: 4px 6px;
  font-size: 16px;
  background-color: var(--win95-gray);
  border: 2px inset var(--win95-dark-gray);
  font-family: 'MS Sans Serif', 'Arial', sans-serif;
  color: var(--win95-black);
  outline: none;
  margin-bottom: 12px;
  text-align: center;
}
.win-input:focus { background: var(--win95-light-gray); }

/* Layout clusters */
.button-container, .update-container {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 12px;
}
.button-container {
  margin-bottom: 36px; /* extra spacing since minus moved below plus */
  flex-direction: column; /* stack buttons vertically */
  align-items: center; /* center stacked buttons */
  gap: 12px; /* increased space between plus and minus */
}
.button-container .win-btn.btn-large { width: 170px; }

.reset-container {
  display: flex;
  justify-content: center;
  margin-top: 34px;
}
.update-container { gap: 2px; }

.win-btn {
  padding: 6px 18px 8px 18px;
  background-color: var(--win95-gray);
  color: var(--win95-black);
  border-top: 2px solid var(--win95-light-gray);
  border-left: 2px solid var(--win95-light-gray);
  border-bottom: 2px solid var(--win95-dark-gray);
  border-right: 2px solid var(--win95-dark-gray);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none; /* iOS Safari */
  -webkit-touch-callout: none; /* prevent callout on long press */
  text-shadow: 1px 1px 0 var(--win95-light-gray);
  min-width: 90px;
  box-sizing: border-box;
  line-height: 1;
}
.win-btn:focus {
  outline: 2px dotted var(--win95-black);
  outline-offset: 2px;
}
.win-btn:active {
  border-top: 2px solid var(--win95-dark-gray);
  border-left: 2px solid var(--win95-dark-gray);
  border-bottom: 2px solid var(--win95-light-gray);
  border-right: 2px solid var(--win95-light-gray);
  transform: translateY(1px);
}

.btn-large { font-size: 42px; padding: 4px 28px 6px; }
.btn-small { font-size: 18px; }
.btn-minus { font-size: 42px; padding: 4px 28px 6px; font-weight: bold; text-shadow: 1px 1px 0 var(--win95-light-gray); }
.btn-minus.disabled, .btn-minus:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  text-shadow: none;
}
.btn-update { flex: 1; }

.reset {
  background: var(--win95-red);
  color: var(--win95-light-gray);
  width: 120px; /* fixed width to prevent horizontal shift */
  min-width: 120px; /* retain for safety */
  text-shadow: none; /* remove shadow for readability on red */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  white-space: nowrap; /* single-line for normal state */
  height: 56px; /* reserve vertical space for potential two-line confirm */
}
.reset.confirm {
  background: #CC0000; /* slightly darker red on confirm state */
  color: var(--win95-light-gray);
  text-shadow: none;
  width: 120px; /* keep same width in confirm state */
  white-space: normal; /* allow wrapping to two lines */
}

/* Status bar (37) */
.status-bar {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  padding: 4px 6px;
  background: var(--win95-gray);
  color: var(--win95-black); /* ensure inherited text color on iOS */
  border-top: 2px solid var(--win95-light-gray);
  border-left: 2px solid var(--win95-light-gray);
  border-bottom: 2px solid var(--win95-dark-gray);
  border-right: 2px solid var(--win95-dark-gray);
  box-shadow: inset 1px 1px 0 var(--win95-light-gray), inset -1px -1px 0 var(--win95-dark-gray);
}
.status-actions { display: flex; gap: 4px; }
.status-btn {
  font-size: 12px;
  padding: 2px 8px 3px;
  min-width: 52px;
  background: var(--win95-gray);
  border-top: 2px solid var(--win95-light-gray);
  border-left: 2px solid var(--win95-light-gray);
  border-bottom: 2px solid var(--win95-dark-gray);
  border-right: 2px solid var(--win95-dark-gray);
  cursor: pointer;
  font-family: 'MS Sans Serif', 'Arial', sans-serif;
  color: var(--win95-black); /* prevent iOS default blue */
  -webkit-appearance: none; appearance: none; /* neutralize iOS native button tint */
}
.status-btn:active {
  border-top: 2px solid var(--win95-dark-gray);
  border-left: 2px solid var(--win95-dark-gray);
  border-bottom: 2px solid var(--win95-light-gray);
  border-right: 2px solid var(--win95-light-gray);
}
.status-btn:focus { outline: 1px dotted var(--win95-black); outline-offset: 1px; }

/* Dark theme button container at bottom right */
.dark-toggle-container {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
.dark-toggle-container .status-btn {
  min-width: 96px;
}

/* Easter egg theme toggle (38) */
body.dark-theme {
  --win95-gray: #222832;
  --win95-dark-gray: #121418;
  --win95-light-gray: #E0E6F0;
  --win95-black: #F5F8FF;
  background: linear-gradient(135deg,#1c2230,#2b3442 58%,#10141b);
  color: var(--win95-black);
}
body.dark-theme .win95-window, body.dark-theme .toast {
  background: #2b3442;
  border-top: 3px solid #4c566a;
  border-left: 3px solid #4c566a;
  border-bottom: 3px solid #0d1014;
  border-right: 3px solid #0d1014;
  box-shadow: 2px 2px 0 #000;
}
body.dark-theme .title-bar, body.dark-theme .title-bar.mini {
  background: linear-gradient(to right,#556b8e,#8fa1b3);
  color: #fff;
}
body.dark-theme .win-btn, body.dark-theme .status-btn {
  background: #2b3442;
  color: #E0E6F0;
  text-shadow: 1px 1px 0 #000;
}
body.dark-theme .count-display { text-shadow: 2px 2px 0 #000; }
body.dark-theme .reset { background: #9c2f2f; }
body.dark-theme .reset.confirm { background: #7a2323; }
body.dark-theme .status-bar { background: #2b3442; }

/* Visually hidden utility for accessible labels */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* High contrast mode toggle */
body.high-contrast {
  --win95-gray: #000000;
  --win95-light-gray: #FFFFFF;
  --win95-dark-gray: #666666;
  --win95-black: #FFFFFF;
  background: #000;
  color: #FFF;
}
body.high-contrast .win95-window,
body.high-contrast .toast {
  background: #000;
  border-top: 3px solid #FFF;
  border-left: 3px solid #FFF;
  border-bottom: 3px solid #666;
  border-right: 3px solid #666;
}
body.high-contrast .win-btn { background: #000; color: #FFF; text-shadow: none; }
body.high-contrast .btn-minus.disabled, body.high-contrast .btn-minus:disabled { opacity: 0.35; }
body.high-contrast .count-display { text-shadow: none; }

/* Draggable title bar cursor */
.title-bar { cursor: move; }

/* Long-press active visual feedback */
.long-pressing { filter: brightness(1.2); }

/* Numeric input spinner removal */
input#newCount::-webkit-outer-spin-button,
input#newCount::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input#newCount { -moz-appearance: textfield; appearance: textfield; }

html, body { touch-action: manipulation; }


@media (max-width: 480px) {
  .win95-window { width: 94%; }
  .count-display { font-size: 40px; margin: 10px 0 20px; }
  .btn-large, .btn-minus { 
    font-size: 34px; 
    padding: 12px 22px 14px; /* increase vertical padding for better touch target */
    min-height: 64px; /* ensure comfortable tap height */
  }
  .win-btn { font-size: 16px; padding: 6px 14px 8px; min-width: 70px; }
  .win-input { font-size: 14px; }
}

