/* ============ Fun Time 95 — Windows 95 look & feel ============ */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --gray: #c0c0c0;
  --gray-dark: #808080;
  --gray-darker: #404040;
  --white: #ffffff;
  --navy: #000080;
  --navy2: #1084d0;
  --teal: #008080;
  --font: "Tahoma", "MS Sans Serif", "Segoe UI", sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 12px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.hidden { display: none !important; }

/* ---------- bevels ---------- */
.bevel-out, #taskbar, #start-menu, .win, .btn, .titlebar-btn {
  background: var(--gray);
  border: 2px solid;
  border-color: var(--white) var(--gray-darker) var(--gray-darker) var(--white);
  box-shadow: inset 1px 1px 0 #dfdfdf, inset -1px -1px 0 var(--gray-dark);
}
.bevel-in, .field, .win-body-inset, .tray-inset {
  background: var(--white);
  border: 2px solid;
  border-color: var(--gray-dark) var(--white) var(--white) var(--gray-dark);
  box-shadow: inset 1px 1px 0 var(--gray-darker), inset -1px -1px 0 #dfdfdf;
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font);
  font-size: 12px;
  padding: 3px 12px;
  cursor: pointer;
  color: #000;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.btn:active, .btn.active {
  border-color: var(--gray-darker) var(--white) var(--white) var(--gray-darker);
  box-shadow: inset 1px 1px 0 var(--gray-dark), inset -1px -1px 0 #dfdfdf;
}
.btn:active > *, .btn.active > * { transform: translate(1px, 1px); }
.btn:focus { outline: 1px dotted #000; outline-offset: -5px; }

.field {
  font-family: var(--font);
  font-size: 12px;
  padding: 3px 5px;
  color: #000;
}
textarea.field { resize: none; }

/* ---------- boot screen ---------- */
#boot-screen {
  position: fixed; inset: 0; z-index: 10000;
  background: #000;
  color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 24px;
  transition: opacity .6s;
}
#boot-screen.fade { opacity: 0; pointer-events: none; }
.boot-logo { text-align: center; }
.boot-flag { display: inline-grid; grid-template-columns: 28px 28px; gap: 4px; margin-bottom: 18px; transform: skewY(-6deg); }
.boot-flag span { height: 28px; }
.fr { background:#f25022 } .fg { background:#7fba00 } .fb { background:#00a4ef } .fy { background:#ffb900 }
.boot-title { font-size: 38px; font-weight: bold; letter-spacing: 1px; }
.boot-title span { color: #ffb900; }
.boot-sub { color: #aaa; margin-top: 6px; font-size: 14px; }
.boot-bar { width: min(420px, 70vw); height: 14px; border: 1px solid #fff; padding: 2px; }
.boot-bar-fill { height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--navy2) 0 12px, var(--navy) 12px 24px); animation: bootfill 1.6s ease-in forwards; }
@keyframes bootfill { to { width: 100%; } }
.boot-hint { color: #888; font-family: "Courier New", monospace; }

/* ---------- screen / desktop ---------- */
#screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
#desktop {
  flex: 1;
  position: relative;
  background: var(--teal);
  overflow: hidden;
  padding: 8px;
  display: flex; flex-direction: column; flex-wrap: wrap; align-content: flex-start;
  gap: 4px;
}
#windows-layer { position: absolute; inset: 0 0 36px 0; pointer-events: none; }

/* desktop icons */
.desk-icon {
  width: 76px;
  padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer;
  text-align: center;
  touch-action: none;
}
.desk-icon .ico { font-size: 30px; line-height: 1; filter: drop-shadow(1px 1px 0 rgba(0,0,0,.4)); }
.desk-icon .lbl { color: #fff; text-shadow: 1px 1px 0 #000; font-size: 11px; line-height: 1.2; word-break: break-word; }
.desk-icon.selected .lbl { background: var(--navy); outline: 1px dotted #fff; }
.desk-icon.ghost { opacity: 0; transition: opacity .3s; }
.desk-icon.ghost:hover { opacity: 1; }

/* ---------- windows ---------- */
.win {
  position: absolute;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  min-height: 120px;
  padding: 2px;
  box-shadow: inset 1px 1px 0 #dfdfdf, inset -1px -1px 0 var(--gray-dark), 2px 2px 6px rgba(0,0,0,.35);
}
.win.maxed { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; }
.titlebar {
  height: 22px;
  background: linear-gradient(90deg, var(--gray-dark), #b5b5b5);
  color: #d8d8d8;
  display: flex; align-items: center;
  padding: 0 2px 0 4px;
  gap: 4px;
  cursor: default;
  flex: none;
  touch-action: none;
}
.win.focused .titlebar { background: linear-gradient(90deg, var(--navy), var(--navy2)); color: #fff; }
.titlebar .t-icon { font-size: 13px; }
.titlebar .t-text { flex: 1; font-weight: bold; font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.titlebar-btn {
  width: 18px; height: 16px;
  font-size: 10px; font-weight: bold; font-family: var(--font);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: #000; padding: 0 0 2px 0;
}
.win-body {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--gray);
  padding: 8px;
}
.win-body.no-pad { padding: 0; }
.win-body.white { background: #fff; }
.win .resizer {
  position: absolute; right: 0; bottom: 0; width: 18px; height: 18px;
  cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 50%, var(--gray-dark) 50%, var(--gray-dark) 60%, transparent 60%, transparent 70%, var(--gray-dark) 70%, var(--gray-dark) 80%, transparent 80%, transparent 90%, var(--gray-dark) 90%);
}

/* menu bar inside windows */
.menubar { display: flex; gap: 2px; padding: 1px 2px; background: var(--gray); flex: none; }
.menubar .mitem { padding: 2px 7px; cursor: pointer; }
.menubar .mitem:hover, .menubar .mitem.open { background: var(--navy); color: #fff; }
.dropdown {
  position: absolute; z-index: 500;
  background: var(--gray);
  border: 2px solid;
  border-color: var(--white) var(--gray-darker) var(--gray-darker) var(--white);
  box-shadow: 2px 2px 4px rgba(0,0,0,.3);
  min-width: 140px;
  padding: 2px;
}
.dropdown .ditem { padding: 4px 18px 4px 22px; cursor: pointer; white-space: nowrap; }
.dropdown .ditem:hover { background: var(--navy); color: #fff; }
.dropdown .dsep { height: 0; border-top: 1px solid var(--gray-dark); border-bottom: 1px solid var(--white); margin: 3px 2px; }

/* ---------- taskbar ---------- */
#taskbar {
  height: 36px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  border-left: none; border-right: none; border-bottom: none;
  z-index: 3000;
  position: relative;
}
#start-btn { font-size: 13px; padding: 2px 8px; height: 28px; }
.start-logo { font-size: 16px; }
#task-buttons { flex: 1; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
#task-buttons::-webkit-scrollbar { display: none; }
.task-btn {
  max-width: 160px; min-width: 90px; height: 28px;
  overflow: hidden; text-overflow: ellipsis;
  flex: 0 1 auto;
  font-size: 11px;
}
.task-btn.active { font-weight: bold; background: repeating-conic-gradient(#d4d4d4 0% 25%, var(--gray) 0% 50%) 0 0 / 4px 4px; }
#tray {
  display: flex; align-items: center; gap: 8px;
  height: 28px; padding: 0 8px;
  border: 2px solid;
  border-color: var(--gray-dark) var(--white) var(--white) var(--gray-dark);
  font-size: 14px;
}
#tray > span { cursor: pointer; }
#clock { font-size: 12px; cursor: default; min-width: 58px; text-align: center; }

/* ---------- start menu ---------- */
#start-menu {
  position: absolute;
  left: 4px; bottom: 38px;
  z-index: 4000;
  display: flex;
  padding: 3px;
  min-width: 230px;
}
.sm-band {
  width: 28px;
  background: linear-gradient(180deg, var(--navy2), var(--navy));
  color: #fff;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 16px; font-weight: bold; letter-spacing: 1px;
  padding: 8px 4px;
  display: flex; align-items: center;
}
.sm-items { flex: 1; display: flex; flex-direction: column; padding: 2px; max-height: min(70vh, 480px); overflow-y: auto; }
.sm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px 7px 8px;
  cursor: pointer;
  font-size: 13px;
}
.sm-item:hover { background: var(--navy); color: #fff; }
.sm-item .ico { font-size: 22px; width: 26px; text-align: center; }
.sm-sep { height: 0; border-top: 1px solid var(--gray-dark); border-bottom: 1px solid var(--white); margin: 3px 4px; }

/* ---------- dialogs ---------- */
.dlg-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.dlg-btns { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.dlg-btns .btn { min-width: 78px; justify-content: center; }
.dlg-icon { font-size: 34px; }

/* ---------- screensaver ---------- */
#screensaver-layer { position: fixed; inset: 0; z-index: 9000; background: #000; cursor: none; }
#screensaver-layer canvas { width: 100%; height: 100%; display: block; }

/* ---------- BSOD ---------- */
#bsod {
  position: fixed; inset: 0; z-index: 9999;
  background: #0000aa;
  color: #fff;
  font-family: "Courier New", monospace;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.bsod-inner { max-width: 640px; display: flex; flex-direction: column; gap: 18px; }
.bsod-title { background: #aaa; color: #0000aa; align-self: center; padding: 0 8px; font-weight: bold; }
.bsod-center { text-align: center; }
.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- misc ---------- */
.crt-flicker { animation: crt .12s linear; }
@keyframes crt { 0% { filter: brightness(2) } 100% { filter: none } }

::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track { background: repeating-conic-gradient(#d4d4d4 0% 25%, var(--white) 0% 50%) 0 0 / 4px 4px; }
::-webkit-scrollbar-thumb { background: var(--gray); border: 2px solid; border-color: var(--white) var(--gray-darker) var(--gray-darker) var(--white); }

/* ---------- mobile ---------- */
@media (max-width: 640px), (max-height: 520px) {
  .win { min-width: 0; min-height: 0; }
  .desk-icon { width: 68px; }
  .desk-icon .ico { font-size: 27px; }
  .titlebar { height: 28px; }
  .titlebar-btn { width: 24px; height: 22px; font-size: 12px; }
  #taskbar { height: 42px; }
  #start-btn, .task-btn, #tray { height: 34px; }
  .sm-item { padding: 10px 14px 10px 8px; }
  body { font-size: 13px; }
}
