/* PlayLoop: classic desktop look (gray bevels, navy title bars, teal desktop). */
:root {
  --desk: #008080;
  --face: #c0c0c0;
  --light: #dfdfdf;
  --hi: #ffffff;
  --shade: #808080;
  --dark: #0a0a0a;
  --navy: #000080;
  --navy2: #1084d0;
  --tip: #ffffe1;
  --red: #c00000;
  --font: Tahoma, "MS Sans Serif", "Microsoft Sans Serif", Verdana, Geneva, sans-serif;
  --raised: inset -1px -1px var(--dark), inset 1px 1px var(--light), inset -2px -2px var(--shade), inset 2px 2px var(--hi);
  --button: inset -1px -1px var(--dark), inset 1px 1px var(--hi), inset -2px -2px var(--shade), inset 2px 2px var(--light);
  --pressed: inset 1px 1px var(--dark), inset -1px -1px var(--hi), inset 2px 2px var(--shade), inset -2px -2px var(--light);
  --sunken: inset -1px -1px var(--hi), inset 1px 1px var(--shade), inset -2px -2px var(--light), inset 2px 2px var(--dark);
  --taskbar-h: 40px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--desk); color: #000;
  font: 400 14px/1.45 var(--font);
  -webkit-font-smoothing: none;
  padding-bottom: calc(var(--taskbar-h) + env(safe-area-inset-bottom));
  padding-top: env(safe-area-inset-top);
}
[hidden] { display: none !important; }
img, svg, iframe, video { max-width: 100%; }
h1, h2, h3 { font-weight: 700; line-height: 1.25; margin: 0 0 .5em; letter-spacing: 0; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 .8em; }
a { color: var(--navy); }
:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }
a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 1px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--tip); padding: 4px 8px; z-index: 99; }
.skip:focus { left: 8px; top: 8px; }
.sunken { box-shadow: var(--sunken); background: var(--face); }

/* ---------- window ---------- */
.desktop { padding: 16px; }
.window { background: var(--face); box-shadow: var(--raised); padding: 3px; }
.main-window { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; min-height: calc(100vh - var(--taskbar-h) - 32px); }
.titlebar {
  display: flex; align-items: center; gap: 4px; padding: 3px 3px 3px 4px;
  background: linear-gradient(90deg, var(--navy), var(--navy2)); color: #fff; font-weight: 700;
}
.titlebar img { image-rendering: pixelated; }
#win-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-buttons { display: flex; gap: 0; }
.tb {
  width: 18px; height: 16px; display: inline-grid; place-items: center;
  background: var(--face); color: #000; box-shadow: var(--button);
  font: 700 11px/1 var(--font); text-decoration: none;
}
.tb.close { margin-left: 2px; }
.tb.close:active { box-shadow: var(--pressed); }
.menubar { display: flex; gap: 2px; padding: 2px 0; overflow-x: auto; border-bottom: 1px solid var(--shade); box-shadow: 0 1px var(--hi); margin-bottom: 4px; }
.menubar a { color: #000; text-decoration: none; padding: 3px 8px; white-space: nowrap; }
.menubar a:hover, .menubar a[aria-current="page"] { background: var(--navy); color: #fff; }
.window-body { flex: 1; background: var(--face); padding: 12px; outline: none; overflow: hidden; }
.statusbar { display: flex; gap: 3px; margin-top: 3px; }
.statusbar span { padding: 2px 6px; font-size: 12px; }
.statusbar span:first-child { flex: 1; }

/* ---------- controls ---------- */
.btn {
  font: inherit; color: #000; cursor: pointer; text-decoration: none; display: inline-block;
  background: var(--face); border: 0; box-shadow: var(--button);
  min-width: 80px; padding: 5px 14px; text-align: center;
}
.btn:active, .btn[aria-pressed="true"] { box-shadow: var(--pressed); padding: 6px 13px 4px 15px; }
.btn:focus-visible { outline: 1px dotted #000; outline-offset: -5px; }
.btn[disabled] { color: var(--shade); text-shadow: 1px 1px var(--hi); cursor: wait; }
.btn.default { box-shadow: 0 0 0 1px #000, var(--button); }
input, select, textarea {
  font: inherit; color: #000; background: #fff; border: 0; border-radius: 0;
  box-shadow: var(--sunken); padding: 5px 6px; width: 100%;
}
select { padding: 4px; }
textarea { min-height: 5.5em; resize: vertical; }
.form { display: grid; gap: 10px; max-width: 440px; }
.field { display: grid; gap: 3px; }
.field small { color: #333; }
.error { color: var(--red); margin: 0; min-height: 1em; }
.error:empty { display: none; }
fieldset { border: 0; box-shadow: inset -1px -1px var(--hi), inset 1px 1px var(--shade), inset -2px -2px var(--shade), inset 2px 2px var(--hi); padding: 12px; margin: 0 0 14px; min-width: 0; }
legend { padding: 0 4px; }
.switch { background: none; border: 0; color: var(--navy); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }
.lead { max-width: 640px; }

/* ---------- feed ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin: 6px 0 0; }
.tabs { display: flex; align-items: flex-end; }
.tab {
  font: inherit; cursor: pointer; background: var(--face); border: 0; color: #000;
  padding: 3px 12px 4px; margin-right: -2px; position: relative; top: 2px;
  box-shadow: inset 1px 1px var(--hi), inset -1px 0 var(--dark), inset -2px 0 var(--shade), inset 2px 2px var(--light);
}
.tab[aria-selected="true"] { padding: 5px 14px 6px; top: 2px; z-index: 1; }
.search-wrap { margin-left: auto; display: flex; gap: 6px; align-items: center; padding-bottom: 4px; }
.search { width: 200px; }
.panel { box-shadow: var(--raised); padding: 12px; background: var(--face); }
.listview { background: #fff; box-shadow: var(--sunken); padding: 10px; min-height: 160px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.item { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 8px 4px; color: #000; text-decoration: none; }
.item img { width: 48px; height: 30px; image-rendering: pixelated; }
.item .label { padding: 0 3px; overflow-wrap: anywhere; }
.item:hover .label, .item:focus-visible .label { background: var(--navy); color: #fff; outline: 1px dotted #ff0; }
.item:focus-visible { outline: none; }
.item .sub { font-size: 12px; color: #444; }
.empty { padding: 20px; text-align: center; }

/* featured game: the one loud element */
.featured { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); gap: 14px; align-items: start; }
.featured p { margin-bottom: 10px; }

/* ---------- player + post ---------- */
.player { aspect-ratio: 16 / 10; background: #000; box-shadow: var(--sunken); padding: 2px; }
.player.video { aspect-ratio: 16 / 9; }
.player iframe, .player video { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.linkbox { height: 100%; display: grid; place-items: center; text-align: center; padding: 12px; background: var(--desk); color: #fff; }
.post-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.meta { color: #333; margin: 0 0 8px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 14px; }
details { margin: 0 0 14px; }
summary { cursor: pointer; padding: 2px 0; }
pre { background: #fff; box-shadow: var(--sunken); padding: 8px; overflow: auto; max-height: 320px; font: 12px/1.4 "Courier New", monospace; margin: 6px 0 0; }
.comments { list-style: none; margin: 0 0 10px; padding: 6px; background: #fff; box-shadow: var(--sunken); max-height: 360px; overflow: auto; }
.comments li { padding: 5px 4px; border-bottom: 1px dotted var(--shade); }
.comments li:last-child { border-bottom: 0; }
.comments b { display: block; font-size: 12px; }
.comment-form { display: grid; gap: 6px; }
.comment-form .btn { justify-self: start; }
.profile-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 12px; }
.profile-head h1 { margin: 0; }
.prose { max-width: 680px; }
.prose ul { padding-left: 20px; margin-top: 0; }
.dialog-wrap { display: grid; place-items: center; padding: 20px 0; }
.dialog { width: 100%; max-width: 380px; }
.dialog .window-body { padding: 14px; }

/* ---------- taskbar + start menu ---------- */
.taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--taskbar-h) + env(safe-area-inset-bottom));
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  display: flex; align-items: stretch; gap: 4px;
  background: var(--face); box-shadow: inset 0 1px var(--light), inset 0 2px var(--hi);
}
.start { font: 700 14px var(--font); display: flex; align-items: center; gap: 5px; padding: 0 8px; border: 0; background: var(--face); box-shadow: var(--button); cursor: pointer; color: #000; }
.start img { image-rendering: pixelated; }
.start[aria-expanded="true"] { box-shadow: var(--pressed); }
.tasks { flex: 1; display: flex; min-width: 0; }
.task { display: flex; align-items: center; max-width: 220px; min-width: 0; padding: 0 8px; color: #000; text-decoration: none; background: var(--face); box-shadow: var(--pressed); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background-image: repeating-conic-gradient(var(--face) 0 25%, var(--hi) 0 50%); background-size: 2px 2px; }
.tray { display: flex; align-items: center; padding: 0 10px; font-size: 13px; }
.startmenu {
  position: fixed; left: 2px; bottom: calc(var(--taskbar-h) + env(safe-area-inset-bottom) - 2px); z-index: 50;
  display: flex; background: var(--face); box-shadow: var(--raised); padding: 3px; min-width: 210px;
}
.startside { width: 26px; background: linear-gradient(0deg, var(--navy), var(--navy2)); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; }
.startside span { writing-mode: vertical-rl; transform: rotate(180deg); color: var(--face); font-size: 18px; white-space: nowrap; }
.startside b { color: #fff; }
#startnav { flex: 1; display: flex; flex-direction: column; }
#startnav a { color: #000; text-decoration: none; padding: 9px 14px 9px 10px; display: flex; align-items: center; gap: 10px; }
#startnav a:hover, #startnav a:focus-visible { background: var(--navy); color: #fff; outline: none; }
#startnav img { width: 24px; height: 15px; image-rendering: pixelated; }
#startnav hr { border: 0; border-top: 1px solid var(--shade); border-bottom: 1px solid var(--hi); margin: 3px 2px; }

/* balloon tip */
#toast {
  position: fixed; right: 8px; bottom: calc(var(--taskbar-h) + env(safe-area-inset-bottom) + 8px); z-index: 60;
  background: var(--tip); color: #000; border: 1px solid #000; padding: 8px 12px; max-width: min(320px, 92vw);
  box-shadow: 2px 2px 0 rgba(0,0,0,.5); display: none;
}
#toast.show { display: block; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .desktop { padding: 0; }
  .main-window { min-height: calc(100vh - var(--taskbar-h)); }
  .featured, .post-grid { grid-template-columns: 1fr; }
  .player { aspect-ratio: 4 / 5; }
  .player.video { aspect-ratio: 16 / 9; }
  .search-wrap { margin-left: 0; width: 100%; order: -1; }
  .search { width: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .window-body { padding: 8px; }
  .task { max-width: 140px; }
}
@media (pointer: coarse) {
  .btn, .start { min-height: 38px; }
  .menubar a { padding: 8px 10px; }
  input, select { min-height: 38px; }
}
