:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body, #title-screen-root { width: 100%; min-height: 100%; margin: 0; }
button { font: inherit; }

.title-screen {
  --ash: #c8c0aa;
  --blood: #8e2735;
  --night: #090a0d;
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  place-items: center;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ash);
  background:
    linear-gradient(#18252c, #090a0d);
  image-rendering: pixelated;
  font-family: monospace;
}

.title-world { position: absolute; z-index: 0; inset: 0; overflow: hidden; background: #18252c; }
.title-world__canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  filter: blur(1.25px) brightness(.68) saturate(.88);
  transform: scale(1.012);
}
.title-world__canvas.is-unavailable { display: none; }
.title-world__veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 48%, transparent 0 20%, #080b1029 62%, #05070bc7 100%),
    linear-gradient(to bottom, #07101924 0 48%, #07090ebd 100%);
}

.game-title { z-index: 2; align-self: end; text-align: center; text-shadow: 4px 4px #000; animation: title-reveal .7s ease-out both; }
.game-title p { margin: .65rem 0 0; color: #eee5cf; font-size: clamp(.72rem, 1.35vw, 1rem); font-weight: 700; letter-spacing: .38em; text-shadow: 2px 2px 0 #000, 0 0 8px #000; text-transform: uppercase; }
.game-title h1 { margin: 0; color: #ddd5bd; font-size: clamp(2.6rem, 9vw, 7rem); letter-spacing: .08em; }
.title-mark { display: block; margin-top: .8rem; color: var(--blood); font-size: 1rem; }

.main-menu { z-index: 2; display: grid; gap: .8rem; width: min(90vw, 23rem); animation: menu-reveal .65s .35s ease-out both; }
.menu-button, .back-button {
  border: 0;
  color: var(--ash);
  background: transparent;
  cursor: pointer;
  text-shadow: 2px 2px #000;
}
.menu-button { border: 1px solid #84766f; padding: 1rem; font-size: clamp(.85rem, 2vw, 1.1rem); letter-spacing: .12em; background: #090d13dc; box-shadow: 0 5px 0 #030507b8, inset 0 0 20px #ffffff08; backdrop-filter: blur(4px); }
.menu-button::before { content: '◆'; margin-right: 1rem; color: transparent; }
.menu-button:hover::before, .menu-button:focus-visible::before { color: var(--blood); }
.menu-button:hover, .menu-button:focus-visible { border-color: #c3ad82; color: #f1ead8; background: #151820ed; transform: translateY(-2px); }
.menu-button:focus-visible { outline: 2px solid #8e2735; outline-offset: 2px; }
.menu-button:disabled { color: #47464a; cursor: default; }

.save-panel, .name-panel, .guild-panel {
  z-index: 3;
  width: min(92vw, 48rem);
  padding: clamp(1rem, 3vw, 2rem);
  border: 4px double #514348;
  background: #0b0c10ed;
  box-shadow: 0 0 0 3px #050507, 12px 12px 0 #0008;
}
.save-panel[hidden], .name-panel[hidden], .guild-panel[hidden], .main-menu[hidden], .title-modal[hidden] { display: none; }
.panel-heading { display: flex; align-items: center; border-bottom: 2px solid #342e31; }
.panel-heading h2 { flex: 1; font-size: clamp(.8rem, 2vw, 1.1rem); text-align: center; letter-spacing: .16em; }
.panel-heading > div { flex: 1; text-align: center; }
.panel-heading > div h2 { margin: .35rem 0 .75rem; }
.panel-heading > div small { color: #665b5e; font-size: .5rem; letter-spacing: .12em; }
.back-button { padding: .4rem .8rem; font-size: 2rem; }
.save-slots { display: grid; gap: .75rem; margin-top: 1rem; }
.save-slot { position: relative; display: flex; border: 1px solid #3d363a; background: #111116; }
.save-slot:focus-within, .save-slot:hover { border-color: #887679; background: #181419; }
.slot-select { display: flex; flex: 1; align-items: center; min-height: 5.2rem; border: 0; color: inherit; background: transparent; text-align: left; cursor: pointer; }
.slot-select:disabled { cursor: not-allowed; opacity: .35; }
.slot-number { padding: 1rem; color: var(--blood); font-size: 1.35rem; }
.slot-details { display: grid; gap: .3rem; padding: .7rem; }
.slot-details strong { color: #d4cab2; font-size: .86rem; }
.slot-details span, .slot-details small { color: #777174; font-size: .62rem; }
.slot-empty { color: #555055; font-size: .72rem; letter-spacing: .14em; }
.delete-button { align-self: center; margin-right: .7rem; border: 0; color: #6b5559; background: none; font-size: 1.3rem; cursor: pointer; }
.delete-button:hover { color: #bc4655; }
.name-form { display: grid; gap: 1rem; width: min(100%, 28rem); margin: 1.5rem auto 0; }
.name-label { color: #665b5e; font-size: .58rem; letter-spacing: .18em; text-align: center; }
.name-input {
  width: 100%;
  border: 1px solid #40383c;
  padding: .9rem 1rem;
  color: #ddd5bd;
  background: #111116;
  font: inherit;
  font-size: 1rem;
  letter-spacing: .08em;
  text-align: center;
  text-transform: uppercase;
}
.name-input:focus { outline: 2px solid var(--blood); border-color: var(--blood); }
.name-submit {
  border: 1px solid #514348;
  padding: .8rem 1rem;
  color: var(--ash);
  background: #171419;
  cursor: pointer;
  font: inherit;
  font-size: .8rem;
  letter-spacing: .14em;
}
.name-submit:hover, .name-submit:focus-visible { outline: 2px solid var(--blood); color: #ddd5bd; }
.guild-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.25rem; }
.guild-intro { width: min(100%, 40rem); margin: 1rem auto 0; color: #8d8280; font-family: monospace; font-size: .82rem; line-height: 1.5; text-align: center; }
.guild-card {
  position: relative;
  min-height: 20rem;
  padding: 1.5rem 1rem;
  border: 1px solid #40383c;
  color: #aaa198;
  background: linear-gradient(#171419, #0c0d11);
  cursor: pointer;
  text-align: center;
}
.guild-card:hover, .guild-card:focus-visible { transform: translateY(-4px); outline: 2px solid var(--guild-color); box-shadow: 0 8px 0 #050507; }
.guild-card--poison { --guild-color: #71883e; }
.guild-card--fire { --guild-color: #b84a32; }
.guild-card--ice { --guild-color: #5790a4; }
.guild-sigil { display: block; width: 4rem; height: 4rem; margin: .5rem auto 1.5rem; border: 4px double var(--guild-color); transform: rotate(45deg); box-shadow: inset 0 0 0 8px #111217; }
.guild-copy { display: grid; gap: .8rem; justify-items: center; }
.guild-copy small { color: #6e6667; font-size: .48rem; }
.guild-copy strong { color: var(--guild-color); font-size: 1rem; text-transform: uppercase; }
.guild-copy span { min-height: 4rem; font-family: monospace; font-size: .78rem; line-height: 1.45; }
.guild-copy em { border-top: 1px solid #373135; padding-top: .7rem; color: #756d70; font-size: .55rem; font-style: normal; text-transform: uppercase; }
.guild-copy b { margin-top: .2rem; color: var(--guild-color); font-size: .52rem; font-weight: 400; letter-spacing: .1em; text-transform: uppercase; }
.title-modal { position: fixed; z-index: 20; display: grid; place-items: center; inset: 0; padding: 1rem; }
.title-modal__backdrop { position: absolute; inset: 0; background: #030306d9; backdrop-filter: blur(3px); }
.title-modal__dialog {
  --modal-accent: var(--blood);
  position: relative;
  width: min(92vw, 34rem);
  border: 4px double #635158;
  padding: 2rem clamp(1rem, 4vw, 2.5rem);
  color: var(--ash);
  background: linear-gradient(#171419, #090a0d);
  box-shadow: 0 0 0 3px #050507, 14px 14px 0 #0009;
  text-align: center;
}
.title-modal[data-guild="poison"] .title-modal__dialog { --modal-accent: #71883e; }
.title-modal[data-guild="fire"] .title-modal__dialog { --modal-accent: #b84a32; }
.title-modal[data-guild="ice"] .title-modal__dialog { --modal-accent: #5790a4; }
.title-modal__mark { display: block; margin-bottom: .8rem; color: var(--modal-accent); }
.title-modal__eyebrow { color: #76686b; font-size: .5rem; letter-spacing: .15em; }
.title-modal__dialog h2 { margin: .55rem 0 1rem; color: var(--modal-accent); font-size: clamp(.9rem, 3vw, 1.25rem); letter-spacing: .12em; }
.title-modal__dialog p { margin: 0 auto; color: #aaa198; font-family: monospace; font-size: .9rem; line-height: 1.55; }
.title-modal__actions { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: 1.6rem; }
.modal-button { border: 1px solid #514348; padding: .8rem .5rem; color: var(--ash); background: #111116; cursor: pointer; font: inherit; font-size: .62rem; letter-spacing: .08em; }
.modal-button:hover, .modal-button:focus-visible { outline: 2px solid var(--modal-accent); border-color: var(--modal-accent); }
.modal-button--confirm { color: var(--modal-accent); }
.modal-button--danger { color: #cf4354; }
.title-footer { z-index: 2; align-self: end; display: grid; justify-items: center; gap: .55rem; margin: 0 0 1rem; }
.privacy-link { border: 0; padding: .25rem .45rem; color: #8e969f; background: #080b10a6; cursor: pointer; font-family: monospace; font-size: .58rem; letter-spacing: .08em; text-decoration: underline; }
.privacy-link:hover, .privacy-link:focus-visible { outline: 1px solid #c3ad82; color: #eee5cf; }
.controls-hint { margin: 0; color: #4e4b50; font-size: .55rem; }

@keyframes title-reveal { from { opacity: 0; transform: translateY(-12px); } }
@keyframes menu-reveal { from { opacity: 0; transform: translateY(20px); } }
@media (prefers-reduced-motion: reduce) {
  .game-title, .main-menu { animation: none; }
}
@media (max-width: 650px) {
  .guild-panel { margin: 1rem 0; }
  .guild-list { grid-template-columns: 1fr; }
  .guild-card { min-height: auto; }
  .guild-copy span { min-height: auto; }
}
