/* TOMRULEZ.WIN — per-app styling */

/* ------------------------------------------------------------------ *
 * Explorer
 * ------------------------------------------------------------------ */

.explorer {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.exp-addr {
  display: flex;
  flex: none;
  gap: 6px;
  align-items: center;
  padding: 3px 4px;
  font-size: 15px;
}

.exp-addr label {
  flex: none;
}

.exp-addr input {
  flex: 1;
  min-width: 0;
  padding: 1px 4px;
  color: #000;
  background: var(--hi);
  border-top: 2px solid var(--shadow);
  border-left: 2px solid var(--shadow);
  border-right: 2px solid var(--hi);
  border-bottom: 2px solid var(--hi);
}

.exp-panes {
  display: flex;
  flex: 1;
  min-height: 0;
}

.exp-tree {
  flex: none;
  width: 168px;
  padding: 4px;
  overflow: auto;
  background: var(--hi);
  border-top: 2px solid var(--shadow);
  border-left: 2px solid var(--shadow);
  border-right: 2px solid var(--hi);
  border-bottom: 2px solid var(--hi);
}

.exp-list {
  flex: 1;
  min-width: 0;
  padding: 4px;
  overflow: auto;
  background: var(--hi);
  border-top: 2px solid var(--shadow);
  border-left: 2px solid var(--shadow);
  border-right: 2px solid var(--hi);
  border-bottom: 2px solid var(--hi);
}

.tree-node {
  display: block;
  width: 100%;
  padding: 1px 4px;
  font-size: 15px;
  color: #000;
  text-align: left;
  white-space: nowrap;
}

.tree-node.current {
  color: var(--hi);
  background: var(--title);
}

.exp-row {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 2px 4px;
  font-size: 16px;
  color: #000;
  text-align: left;
}

.exp-row:hover {
  background: #d8d8f0;
}

.exp-row.selected {
  color: var(--hi);
  background: var(--title);
}

.exp-row .glyph {
  flex: none;
  width: 20px;
  text-align: center;
}

.exp-row .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.exp-row .size,
.exp-row .date {
  flex: none;
  font-size: 14px;
  color: #444;
}

.exp-row.selected .size,
.exp-row.selected .date {
  color: #cfcfe8;
}

.exp-row .size {
  width: 74px;
  text-align: right;
}

.exp-row .date {
  width: 116px;
  text-align: right;
}

/* ------------------------------------------------------------------ *
 * Viewer
 * ------------------------------------------------------------------ */

.viewer-body {
  height: 100%;
  padding: 8px 10px;
  overflow: auto;
  font-size: 17px;
  line-height: 1.28;
  color: #000;
  background: var(--hi);
  border-top: 2px solid var(--shadow);
  border-left: 2px solid var(--shadow);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Block and box-drawing glyphs fall outside VT323, so the browser substitutes
   a fallback face for them and the columns stop lining up. Scene art needs
   correct metrics more than it needs the VT323 flavour — and a .ANS file was
   always viewed in a terminal font anyway. */
.viewer-body.ansi {
  font-family: Consolas, 'Lucida Console', 'DejaVu Sans Mono', monospace;
  font-size: 14px;
  line-height: 1.15;
  color: #c8c8c8;
  background: #000;
  white-space: pre;
  overflow-wrap: normal;
}

.viewer-body.ansi .c-cyan {
  color: var(--term-cyan);
}

.viewer-body.ansi .c-green {
  color: var(--term-green);
}

.viewer-body.ansi .c-amber {
  color: var(--term-amber);
}

.viewer-body.ansi .c-red {
  color: var(--term-red);
}

.viewer-body.ansi .c-white {
  color: var(--term-bright);
}

.viewer-body.ansi .c-mag {
  color: #ff5cff;
}

.viewer-body h1,
.viewer-body h2 {
  margin: 0 0 0.3em;
  font-size: 1em;
  font-weight: bold;
}

/* ------------------------------------------------------------------ *
 * Console
 * ------------------------------------------------------------------ */

/* The whole console scrolls as one column, so the prompt always follows the
   last line of output the way a real DOS session does. */
.console {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 6px 8px;
  overflow-y: auto;
  font-size: 18px;
  line-height: 1.2;
  color: var(--term-fg);
  background: #000;
}

.con-out {
  flex: 0 0 auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.con-out .echo {
  color: var(--term-bright);
}

.con-out .err {
  color: var(--term-red);
}

.con-out .ok {
  color: var(--term-green);
}

.con-out .hi {
  color: var(--term-amber);
}

.con-in {
  display: flex;
  flex: 0 0 auto;
  gap: 0;
  align-items: baseline;
}

.con-in .prompt {
  flex: none;
  color: var(--term-bright);
  white-space: pre;
}

.con-in input {
  flex: 1;
  min-width: 0;
  color: var(--term-bright);
  background: transparent;
  border: none;
  outline: none;
  caret-color: var(--term-bright);
}

/* ------------------------------------------------------------------ *
 * Guestbook
 * ------------------------------------------------------------------ */

.guestbook {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: #000;
}

.gb-form {
  flex: none;
  padding: 8px;
}

.gb-form .row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-bottom: 5px;
}

.gb-form label {
  flex: none;
  width: 66px;
  font-size: 15px;
  line-height: 1.5;
}

.gb-form input,
.gb-form textarea {
  flex: 1;
  min-width: 0;
  padding: 2px 4px;
  font-size: 16px;
  color: #000;
  background: var(--hi);
  border-top: 2px solid var(--shadow);
  border-left: 2px solid var(--shadow);
  border-right: 2px solid var(--hi);
  border-bottom: 2px solid var(--hi);
  resize: none;
}

.gb-form textarea {
  height: 54px;
}

.gb-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.gb-note {
  flex: none;
  padding: 4px 8px 6px;
  font-size: 14px;
  line-height: 1.25;
  color: #303030;
}

.gb-entries {
  flex: 1;
  min-height: 0;
  margin: 0 8px 8px;
  overflow: auto;
  background: var(--hi);
  border-top: 2px solid var(--shadow);
  border-left: 2px solid var(--shadow);
  border-right: 2px solid var(--hi);
  border-bottom: 2px solid var(--hi);
}

.gb-entry {
  padding: 6px 8px;
  border-bottom: 1px dotted var(--lo);
}

.gb-entry:last-child {
  border-bottom: none;
}

.gb-entry .head {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  font-size: 15px;
  font-weight: bold;
  color: var(--title);
}

.gb-entry .date {
  font-weight: normal;
  color: #555;
}

.gb-entry .msg {
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.gb-entry.mine {
  background: #f2f2ff;
}

/* ------------------------------------------------------------------ *
 * Trophies
 * ------------------------------------------------------------------ */

.trophies {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: #000;
}

.tr-head {
  flex: none;
  padding: 8px 10px 4px;
  font-size: 16px;
}

.tr-bar {
  height: 14px;
  margin-top: 4px;
  overflow: hidden;
  background: var(--hi);
  border-top: 2px solid var(--shadow);
  border-left: 2px solid var(--shadow);
  border-right: 2px solid var(--hi);
  border-bottom: 2px solid var(--hi);
}

.tr-bar .fill {
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--title) 0 8px, var(--face) 8px 10px);
  transition: width 300ms ease;
}

.tr-list {
  flex: 1;
  min-height: 0;
  margin: 6px 10px 10px;
  overflow: auto;
  background: var(--hi);
  border-top: 2px solid var(--shadow);
  border-left: 2px solid var(--shadow);
  border-right: 2px solid var(--hi);
  border-bottom: 2px solid var(--hi);
}

.tr-item {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 5px 8px;
  border-bottom: 1px dotted var(--lo);
}

.tr-item .glyph {
  flex: none;
  width: 24px;
  font-size: 19px;
  text-align: center;
}

.tr-item .name {
  font-size: 16px;
  font-weight: bold;
}

.tr-item .desc {
  font-size: 15px;
  line-height: 1.2;
  color: #333;
}

.tr-item.locked {
  color: #767676;
}

.tr-item.locked .glyph {
  filter: grayscale(1);
  opacity: 0.5;
}

.tr-item.locked .name {
  font-weight: normal;
}

/* ------------------------------------------------------------------ *
 * Sysinfo
 * ------------------------------------------------------------------ */

.sysinfo {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 8px;
  color: #000;
}

.si-tabs {
  display: flex;
  flex: none;
  gap: 2px;
}

.si-tab {
  padding: 3px 11px;
  font-size: 15px;
  color: #000;
  background: var(--face);
  border-top: 2px solid var(--hi);
  border-left: 2px solid var(--hi);
  border-right: 2px solid var(--shadow);
}

.si-tab[aria-selected='true'] {
  font-weight: bold;
  background: var(--face);
  transform: translateY(-2px);
}

.si-panel {
  flex: 1;
  min-height: 0;
  padding: 10px;
  overflow: auto;
  font-size: 16px;
  line-height: 1.35;
  background: var(--face);
  border-top: 2px solid var(--hi);
  border-left: 2px solid var(--hi);
  border-right: 2px solid var(--shadow);
  border-bottom: 2px solid var(--shadow);
}

.si-panel h4 {
  margin: 10px 0 3px;
  font-size: 16px;
}

.si-panel h4:first-child {
  margin-top: 0;
}

.si-panel li {
  padding-left: 14px;
  text-indent: -14px;
}

.si-panel .device {
  display: flex;
  gap: 7px;
  align-items: baseline;
}

.si-panel .device .warn {
  color: #b58900;
}

.si-panel .note {
  margin-top: 12px;
  padding: 8px;
  font-size: 15px;
  line-height: 1.3;
  background: #ffffe1;
  border: 1px solid var(--lo);
}

/* ------------------------------------------------------------------ *
 * Games
 * ------------------------------------------------------------------ */

.game-shell {
  position: relative;
  height: 100%;
  background: #000;
}

.game-shell canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  padding: 18px;
  font-family: var(--mono);
  font-size: 18px;
  line-height: 1.3;
  color: var(--term-fg);
  text-align: center;
  background: #000;
}

.game-overlay.hidden {
  display: none;
}

.game-overlay h3 {
  font-family: var(--pixel);
  font-size: clamp(13px, 2.4vw, 20px);
  line-height: 1.5;
  color: var(--term-amber);
}

.game-overlay .sub {
  color: var(--term-bright);
}

.game-overlay .dim {
  font-size: 16px;
  color: var(--lo);
}

.install-bar {
  width: min(340px, 80%);
  height: 18px;
  overflow: hidden;
  background: #000;
  border: 2px solid var(--term-fg);
}

.install-bar .fill {
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--term-cyan) 0 6px, #000 6px 8px);
}

.nag-box {
  max-width: 460px;
  padding: 14px 16px;
  text-align: left;
  border: 2px solid var(--term-amber);
}

.nag-box p {
  margin-bottom: 0.7em;
}

.nag-box p:last-child {
  margin-bottom: 0;
}

.scoretable {
  width: min(420px, 92%);
  font-size: 17px;
  border-collapse: collapse;
}

.scoretable th,
.scoretable td {
  padding: 2px 8px;
  text-align: left;
}

.scoretable th {
  color: var(--term-amber);
  border-bottom: 1px solid var(--lo);
}

.scoretable .you {
  color: var(--term-green);
}

.scoretable td.n {
  text-align: right;
}

.game-btn {
  padding: 6px 18px;
  font-family: var(--mono);
  font-size: 18px;
  color: #000;
  background: var(--term-amber);
  border: 2px solid var(--term-bright);
}

.game-btn:hover {
  background: var(--term-bright);
}

/* ------------------------------------------------------------------ *
 * LAN party mode
 * ------------------------------------------------------------------ */

.lan-party #desktop {
  animation: lan-hue 1.4s linear infinite;
}

@keyframes lan-hue {
  to {
    filter: hue-rotate(360deg);
  }
}

.sparkle {
  position: absolute;
  z-index: 8400;
  pointer-events: none;
  font-size: 18px;
  animation: sparkle-fade 700ms ease-out forwards;
}

@keyframes sparkle-fade {
  to {
    opacity: 0;
    transform: translateY(-26px) scale(0.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lan-party #desktop {
    animation: none;
  }

  .sparkle {
    display: none;
  }

  .toast {
    animation: none;
  }
}
