/* Commit Muncher program — the Commit Monster loose in a maze of code. */

.window--muncher {
  --bg-cookie: #101319;
  --panel: #181c26;
  --cookie-blue: #2b7de9;
  --cookie-brown: #c98a3e;
  --text-dim: #8a8f9c;
  --font-heading: 'Press Start 2P', monospace;
  --font-body: 'VT323', monospace;
  max-width: 780px;
}

.window--muncher .window-body {
  padding: 20px;
  background: var(--bg-cookie);
  color: #e6e8ee;
  font-family: var(--font-body);
}

.mz-layout {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  justify-content: center;
}

.mz-stage {
  position: relative;
  flex: 0 1 560px;
  max-width: 560px;
  width: 100%;
}

#mz-screen {
  display: block;
  width: 100%;
  border: 2px solid rgba(43, 125, 233, 0.4);
  border-radius: 6px;
  background: #1a1d27;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.mz-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(16, 19, 25, 0.9);
  border-radius: 6px;
  text-align: center;
  padding: 16px;
}

.mz-overlay.is-hidden {
  display: none;
}

.mz-overlay-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  color: var(--cookie-blue);
  text-shadow: 0 0 12px #2b7de9, 0 0 28px #2b7de955;
  line-height: 1.6;
}

.mz-overlay-msg {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.35;
  color: var(--text-dim);
}

.mz-btn {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  padding: 12px 18px;
  background: var(--cookie-blue);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 4px 0 #17498d;
  transition: transform 80ms ease, box-shadow 80ms ease;
}

.mz-btn:hover {
  filter: brightness(1.1);
}

.mz-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #17498d;
}

.mz-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.mz-btn--small {
  font-size: 0.5rem;
  padding: 8px 12px;
  background: var(--panel);
  box-shadow: 0 3px 0 #0a0c10;
  border: 2px solid #2a3040;
}

.mz-submit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.mz-submit.is-hidden {
  display: none;
}

.mz-initials {
  font-family: var(--font-body);
  font-size: 1.3rem;
  color: var(--cookie-brown);
  background: #0b0d12;
  border: 2px solid #2a3040;
  border-radius: 4px;
  padding: 6px 10px;
  width: 160px;
  text-align: center;
  text-transform: uppercase;
}

.mz-initials:focus {
  outline: none;
  border-color: var(--cookie-blue);
  box-shadow: 0 0 10px rgba(43, 125, 233, 0.4);
}

.mz-side {
  flex: 0 0 150px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mz-panel {
  background: var(--panel);
  border: 2px solid #2a3040;
  border-radius: 4px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.mz-panel--scores {
  align-items: stretch;
}

.mz-panel-label {
  font-family: var(--font-heading);
  font-size: 0.5rem;
  color: var(--text-dim);
  text-align: center;
}

.mz-panel-value {
  font-size: 1.6rem;
  line-height: 1;
  color: var(--cookie-brown);
}

.mz-scores {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--text-dim);
  counter-reset: rank;
}

.mz-scores li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  counter-increment: rank;
}

.mz-scores li::before {
  content: counter(rank) '.';
  color: var(--cookie-blue);
  min-width: 1.4em;
}

.mz-scores li span:first-of-type {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mz-scores li:first-child span {
  color: var(--cookie-brown);
}

.mz-scores-empty {
  justify-content: center;
}

.mz-scores-empty::before {
  content: none;
}

.mz-help {
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text-dim);
  text-align: center;
}

/* Touch d-pad: hidden unless the screen is narrow or the pointer is coarse. */
.mz-pad {
  display: none;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 48px);
  gap: 6px;
  justify-content: center;
  margin-top: 18px;
}

.mz-pad-btn {
  font-family: var(--font-body);
  font-size: 1.5rem;
  color: var(--cookie-blue);
  background: var(--panel);
  border: 2px solid #2a3040;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.mz-pad-btn:active {
  background: rgba(43, 125, 233, 0.2);
}

.mz-pad-btn--up { grid-column: 2; grid-row: 1; }
.mz-pad-btn--left { grid-column: 1; grid-row: 2; }
.mz-pad-btn--down { grid-column: 2; grid-row: 3; }
.mz-pad-btn--right { grid-column: 3; grid-row: 2; }

@media (max-width: 720px) {
  .window--muncher .window-body {
    padding: 12px;
  }

  .mz-layout {
    flex-direction: column;
    align-items: center;
  }

  .mz-side {
    flex: none;
    width: 100%;
    max-width: 560px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: stretch;
  }

  .mz-panel--scores,
  .mz-help,
  #mz-mute {
    grid-column: 1 / -1;
  }

  .mz-pad {
    display: grid;
  }
}

@media (hover: none) and (pointer: coarse) {
  .mz-pad {
    display: grid;
  }
}
