:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #1f1f1f;
  --muted: rgba(31, 31, 31, 0.72);
}

* {
  box-sizing: border-box;
}

html, body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 24px;
}

.equation-strip {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  background: #ececec;
  padding: 20px 0;
  margin-top: 12vh;
}

.equation-strip-inner {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 22px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.topbar-right {
  justify-self: end;
  gap: 18px;
}

.topbar-right > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.topbar-label {
  color: var(--text);
  opacity: 0.72;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.topbar strong,
.topbar h1 {
  color: var(--text);
  font-weight: 400;
}

.topbar h1 {
  margin: 0;
  justify-self: center;
  font-size: 0.98rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.topbar strong {
  font-size: 0.95rem;
  line-height: 1;
}

.game-card {
  padding-top: 0;
}

.prompt-wrap {
  display: grid;
  gap: 10px;
}

.is-hidden {
  display: none !important;
}

.how-to-wrap {
  text-align: center;
  margin-top: 12px;
}

.how-to-button {
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: "Courier New", Courier, monospace;
  font-size: 1rem;
  padding: 8px 12px;
  cursor: pointer;
}

/* Modal styles */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-content {
  position: relative;
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 18px;
  max-width: 560px;
  width: calc(100% - 40px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  z-index: 1;
}

.modal-content h2 {
  margin: 0 0 8px 0;
  font-size: 1.05rem;
  text-align: center;
}

.modal-body p {
  margin: 8px 0;
  color: var(--muted);
}

.modal-actions {
  margin-top: 12px;
  text-align: center;
}

.modal-close {
  background: #f1f1f1;
  border: 0;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.base-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.base-list li {
  margin: 6px 0;
}

.game-button {
  display: block;
  margin: 0 auto;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 1;
  letter-spacing: 0.02em;
  padding: 0;
  cursor: pointer;
}

.equation-row {
  display: block;
}

.equation-row-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5rem minmax(0, 1fr);
  align-items: center;
  gap: 0;
  width: 100%;
}

.prompt,
.prompt-arrow,
.rhs-prefix,
input {
  color: var(--text);
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.prompt {
  justify-self: end;
  min-width: 0;
  display: flex;
  align-items: center;
}

.prompt-value {
  color: var(--text);
}

.prefix-decimal {
  color: #3f6fb5;
}

.prefix-hex {
  color: #ca0000;
}

.prefix-binary {
  color: #5a5a5a;
}

.prompt-arrow {
  justify-self: center;
  width: 5rem;
  text-align: center;
  color: #5a5a5a;
}

.answer-cluster {
  justify-self: start;
  display: flex;
  align-items: center;
  min-width: 0;
}

.rhs-prefix {
  flex: 0 0 auto;
}

input {
  flex: 1 1 auto;
  width: 5ch;
  min-width: 5ch;
  max-width: 5ch;
  border: 0;
  background: #fff;
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 1;
  letter-spacing: 0.02em;
  padding: 0.08em 0.1em;
  margin: 0;
  outline: none;
  box-shadow: none;
}

.helper-text {
  margin: 8px 0 0;
  color: var(--text);
  opacity: 0.72;
  font-size: 0.85rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 14px 0 18px;
  }

  .equation-strip-inner {
    width: min(100% - 20px, 1180px);
  }

  .topbar {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 8px;
  }

  .topbar-left,
  .topbar-right {
    justify-self: center;
  }

  .topbar-right {
    gap: 14px;
  }

  .equation-row {
    display: block;
  }

  .equation-row-inner {
    grid-template-columns: 1fr 3.5rem 1fr;
  }

  .prompt-arrow {
    width: 3.5rem;
  }
}
