:root {
  --cream: #fffae9;
  --paper: #ffffff;
  --text: #1c1c1c;
  --muted: #6d685f;
  --border: #1c1c1c;
  --red-bg: #ffecec;
  --red-head: #ffc2c2;
  --red-border: #ff4d4d;
  --red-text: #8c1919;
  --green-bg: #e3f9e5;
  --green-head: #aef0b5;
  --green-border: #28a745;
  --green-text: #145a23;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

button, textarea, input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 2px solid #1c1c1c;
  outline-offset: 2px;
}

/* Minimal neal.fun top navigation */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 24px 0;
}

.logo {
  text-decoration: none;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -0.4px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s, transform 0.15s;
}

.logo:hover {
  background: rgba(0, 0, 0, 0.04);
  transform: translateY(-1px);
}

.neal-mark {
  color: #f59e0b;
  font-size: 18px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-help {
  border: 1px solid #d6ceb8;
  border-radius: 6px;
  background: #fffdf5;
  color: #3d3932;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  transition: border-color 0.12s, background 0.12s;
}

.nav-help:hover {
  border-color: #1c1c1c;
  background: #ffffff;
}

/* Main Page Container */
.page {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 16px 72px;
}

.star, .hero .eyebrow {
  display: none;
}

.hero {
  text-align: center;
  margin-bottom: 34px;
}

.hero h1 {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-weight: 700;
  font-size: clamp(30px, 6vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.5px;
  margin: 0;
  color: #111111;
}

.pw-asterisk {
  color: #e11d48;
  font-family: monospace;
  font-weight: 800;
  margin-right: 2px;
}

.hero-sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.game {
  width: 100%;
  margin: 0 auto;
}

.card {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.input-top {
  margin-bottom: 9px;
}

.input-top label {
  font-size: 16px;
  font-weight: 500;
  color: #1c1c1c;
}

/* Password Input Box — exact neal.fun/password-game styling */
.input-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}

.input-wrap .editable {
  width: 100%;
  min-height: 62px;
  padding: 15px 56px 15px 16px;
  border: 1.5px solid #1c1c1c;
  background: #ffffff;
  color: #111111;
  border-radius: 9px;
  font: 500 19px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  outline: none;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.input-wrap .editable:focus {
  border-color: #000000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.09);
}

.char-badge {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  font-weight: 500;
  color: #7c776e;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* Formatting & Quick Insert Toolbars */
.format-toolbar {
  margin-top: 10px;
  padding: 8px 10px;
  background: #fffdf5;
  border: 1px solid #dfd7c2;
  border-radius: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.format-toolbar.needed {
  border-color: #1c1c1c;
  background: #ffffff;
}

.format-toolbar button {
  border: 1px solid #cfc6b0;
  background: #ffffff;
  min-height: 31px;
  padding: 0 9px;
  border-radius: 5px;
  color: #1c1c1c;
  font-size: 13px;
}

.format-toolbar button:hover {
  border-color: #1c1c1c;
  background: #f8f4e8;
}

.format-toolbar #smart-format {
  margin-left: auto;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  background: #fef08a;
  border-color: #ca8a04;
  color: #422006;
}

.font-size-chooser {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  font-size: 12px;
  color: #4a453d;
  border: 1px solid #cfc6b0;
  border-radius: 5px;
  background: #ffffff;
}

.font-size-chooser input {
  width: 44px;
  min-width: 0;
  padding: 3px 4px;
  border: 1px solid #d4cbb8;
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
}

.font-size-chooser button {
  min-height: 25px;
  padding: 2px 7px;
  font-size: 11.5px;
  background: #f3ede0;
}

.quick-insert {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.quick-insert > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-right: 2px;
}

.quick-insert button {
  width: 34px;
  height: 34px;
  border: 1px solid #dcd4c0;
  background: #ffffff;
  border-radius: 7px;
  font-size: 17px;
  display: grid;
  place-items: center;
  transition: transform 0.1s, border-color 0.1s;
}

.quick-insert button:hover {
  border-color: #1c1c1c;
  transform: scale(1.06);
}

/* Rule Cards — exact neal.fun/password-game red/green cards */
.rule-section {
  margin-top: 22px;
}

.rules {
  display: grid;
  gap: 14px;
}

.rule {
  border-radius: 9px;
  border: 1.5px solid var(--red-border);
  overflow: hidden;
  background: var(--red-bg);
  box-shadow: 0 3px 8px rgba(255, 77, 77, 0.08);
  animation: ruleSlideIn 0.24s cubic-bezier(0.2, 1.2, 0.4, 1);
  transition: background 0.2s, border-color 0.2s;
}

.rule.ok {
  border-color: var(--green-border);
  background: var(--green-bg);
  box-shadow: 0 2px 6px rgba(40, 167, 69, 0.07);
}

@keyframes ruleSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.rule-head {
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--red-head);
  color: var(--red-text);
  border-bottom: 1px solid rgba(255, 77, 77, 0.25);
}

.rule.ok .rule-head {
  background: var(--green-head);
  color: var(--green-text);
  border-bottom: 1px solid rgba(40, 167, 69, 0.25);
}

.rule-title {
  font-size: 16px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.rule-icon {
  font-weight: 800;
  font-size: 17px;
}

.rule-body {
  padding: 15px 16px 12px;
  font-size: 16.5px;
  line-height: 1.5;
  color: #1c1c1c;
}

.rule-body b {
  font-weight: 700;
}

.rule-live-tally {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: #4b463e;
}

.rule-hint {
  padding: 0 16px 13px;
}

.rule-hint button {
  font-size: 12px;
  color: #6b6356;
  background: none;
  border: none;
  border-bottom: 1px dashed #9d9383;
  padding: 0;
}

.rule-hint button:hover {
  color: #1c1c1c;
}

.hint-text {
  font-size: 13px;
  color: #4a443b;
  margin-top: 7px;
  background: rgba(255, 255, 255, 0.6);
  padding: 7px 10px;
  border-radius: 6px;
}

/* Interactive Embedded Rule Widgets */
.captcha {
  display: inline-flex;
  gap: 2px;
  padding: 7px 14px;
  margin: 8px 8px 4px 0;
  border: 1px solid #8c9ba8;
  border-radius: 6px;
  background: repeating-linear-gradient(145deg, #cfdae1, #cfdae1 5px, #fff 6px, #fafafa 10px);
  color: #253b43;
  font: bold 24px/1.3 monospace;
  letter-spacing: 2px;
  text-decoration: line-through;
  text-decoration-color: #b94f58;
  vertical-align: middle;
}

.captcha i {
  display: inline-block;
  font-style: normal;
}

.mini-btn {
  border: 1px solid #1c1c1c;
  background: #ffffff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}

.mini-btn:hover {
  background: #f5f5f5;
}

.country-shape {
  display: block;
  width: 170px;
  height: 155px;
  max-width: 100%;
  color: #2d6a4f;
  margin: 10px auto 4px;
  border: 1.5px solid #1c1c1c;
  background: #d8f3dc;
  border-radius: 8px;
  padding: 14px;
}

.chess-board {
  width: min(272px, 100%);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  margin: 12px auto 4px;
  border: 3px solid #1c1c1c;
  border-radius: 4px;
  overflow: hidden;
}

.chess-board .sq {
  display: grid;
  place-items: center;
  font-size: clamp(16px, 4vw, 25px);
  font-family: "Segoe UI Symbol", serif;
  aspect-ratio: 1;
  color: #121319;
}

.chess-board .sq.white {
  background: #f0d9b5;
}

.chess-board .sq.black {
  background: #b58863;
}

.sacrifice {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 10px 0 6px;
}

.sacrifice button {
  width: 32px;
  height: 34px;
  border: 1px solid #1c1c1c;
  border-radius: 5px;
  background: #ffffff;
  font-size: 12px;
  font-weight: 700;
}

.sacrifice button.chosen {
  background: #dc2626;
  border-color: #991b1b;
  color: white;
}

.swatch {
  width: 78px;
  height: 44px;
  display: inline-block;
  border: 2px solid #1c1c1c;
  vertical-align: middle;
  border-radius: 6px;
  margin: 6px 8px;
}

.editable .symbolic {
  font-family: Wingdings, Webdings, serif;
  background: #eef2ff;
  color: #3730a3;
}

/* Wordle Mini-Game inside Rule 11 */
.word-game {
  margin: 12px auto 4px;
  max-width: 260px;
}

.word-grid {
  display: grid;
  gap: 4px;
  justify-content: center;
}

.word-row {
  display: grid;
  grid-template-columns: repeat(5, 38px);
  gap: 4px;
}

.tile {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 2px solid #cbd5e1;
  font-size: 17px;
  font-weight: 800;
  text-transform: uppercase;
  background: #ffffff;
  border-radius: 3px;
}

.tile.correct {
  background: #6aaa64;
  color: white;
  border-color: #6aaa64;
}

.tile.present {
  background: #c9b458;
  color: white;
  border-color: #c9b458;
}

.tile.absent {
  background: #787c7e;
  color: white;
  border-color: #787c7e;
}

.word-controls {
  display: flex;
  gap: 6px;
  margin: 10px auto 0;
  max-width: 215px;
}

.word-controls input {
  width: 130px;
  min-width: 0;
  text-transform: uppercase;
  border: 1.5px solid #1c1c1c;
  border-radius: 5px;
  padding: 7px 9px;
  background: #fff;
  font-weight: 700;
}

.word-controls button {
  background: #1c1c1c;
  color: white;
  border: 0;
  border-radius: 5px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 600;
}

.word-solved {
  display: block;
  color: var(--green-text);
  text-align: center;
  margin-top: 8px;
  font-size: 13px;
}

.bottom-note {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 36px 0 0;
  padding-top: 16px;
  border-top: 1px solid #e6dec8;
  font-size: 12.5px;
  color: var(--muted);
}

.bottom-note a {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.bottom-note a:hover {
  text-decoration: underline;
}

/* Dialogs */
dialog {
  border: 2px solid #1c1c1c;
  border-radius: 12px;
  max-width: 420px;
  width: calc(100% - 32px);
  padding: 28px;
  background: #ffffff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

dialog h2 {
  font-family: Georgia, serif;
  font-size: 26px;
  margin: 0 28px 14px 0;
}

dialog p, dialog li {
  font-size: 15px;
  line-height: 1.65;
  color: #44403a;
}

.close {
  position: absolute;
  top: 10px;
  right: 14px;
  border: 0;
  background: none;
  font-size: 28px;
}

.modal-action, #confirm-submit {
  width: 100%;
  background: #1c1c1c;
  color: #ffffff;
  border: 0;
  border-radius: 7px;
  padding: 12px 16px;
  font-weight: 600;
  margin-top: 10px;
}

#final-dialog textarea {
  width: 100%;
  min-height: 96px;
  display: block;
  font-size: 17px;
  padding: 10px;
  border: 1.5px solid #1c1c1c;
  border-radius: 7px;
  margin: 12px 0;
}

#final-clock {
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}

.editable.blurred {
  filter: blur(5px);
}

@media (max-width: 600px) {
  .site-nav {
    padding: 12px 14px 0;
  }
  .nav-help span {
    display: none;
  }
  .page {
    padding: 18px 12px 52px;
  }
  .format-toolbar #smart-format {
    margin-left: 0;
  }
  .word-row {
    grid-template-columns: repeat(5, 33px);
  }
  .tile {
    width: 33px;
    height: 33px;
    font-size: 15px;
  }
}
