:root {
  color-scheme: light;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  background-color: #a5a4ce;
  font-family: System, monospace;
  font-size: 13px;
  color: #000;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

a {
  color: #0000ff;
}

a:hover {
  color: #ff0000;
}

/* ==================== NAVIGATION BAR ==================== */
.nav-bar {
  background-color: silver;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0;
  font-weight: bold;
  text-align: center;
}

.nav-bar a {
  color: #000;
  text-decoration: none;
  padding: 0 1em;
  margin: 0 1em;
  font-size: 13px;
}

.nav-bar a:hover {
  background-color: #505050;
  color: silver;
}

.nav-bar a.active {
  background-color: #0000ff;
  color: #fff;
}

.nav-hamburger {
  padding: 0 1em;
  cursor: pointer;
  position: relative;
}

.nav-hamburger:hover {
  background-color: #0000ff;
  color: #fff;
}

/* Reset hamburger hover when menu is open (hovering on menu items) */
.nav-hamburger:has(.sidebar-menu.open):hover {
  background-color: transparent;
  color: inherit;
}

/* Sidebar Dropdown */
.sidebar-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background-color: silver;
  box-shadow: 0 0 0 3px silver, 1em 1em 3px 0 rgba(0, 0, 0, 0.5);
  min-width: 200px;
  z-index: 1000;
  padding: 0;
  font-weight: normal;
}

.sidebar-menu.open {
  display: block;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.5em;
  padding-left: 0.5em;
  text-align: left;
  color: #000 !important;
  text-decoration: none;
  margin: 0;
}

.sidebar-menu a .external-favicon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
}

.sidebar-menu a:hover {
  background-color: #0000ff !important;
  color: #fff !important;
}

.sidebar-menu .menu-header {
  padding: 0.5em;
  font-weight: bold;
  background-color: silver;
  color: #000;
  font-size: 11px;
  border-bottom: 1px solid #808080;
}

.nav-buttons {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.app-shell {
  width: 100%;
  margin: 0;
  padding: 8px;
  display: block;
  flex: 1 1 auto;
  min-height: 0;
}

.screen-wrap {
  width: 100%;
  height: 100%;
  border: 0;
  box-shadow: none;
  background: transparent;
  overflow: hidden;
}

#screen {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#prefsDialog {
  position: fixed;
  margin: 0;
  border: 1px solid #4c2718;
  background: #ffdfc6;
  color: #3f1a0b;
  min-width: min(92vw, 620px);
  max-width: 620px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

#prefsDialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

#prefsForm {
  margin: 0;
  padding: 16px;
}

#prefsForm h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

#prefsRows {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
}

.pref-row {
  display: grid;
  gap: 4px;
}

.pref-row label {
  font-size: 12px;
}

.pref-row select {
  width: 100%;
  border: 1px solid #9f6d52;
  border-radius: 4px;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 12px;
  background: #fff3e8;
  color: #3f1a0b;
}

menu {
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

menu button {
  border: 1px solid #8e5e44;
  background: #ffd3b5;
  color: #3f1a0b;
  font-family: inherit;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
}

@media (max-width: 860px) {
  #prefsRows {
    grid-template-columns: 1fr;
  }
}
