* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  background: #120c0a;
  color: #ddd;
  font-family: "DejaVu Sans Mono", "Menlo", "Consolas", monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  min-height: 100vh;
  justify-content: center;
}
.overlay { display: flex; align-items: center; justify-content: center; }
.panel { text-align: center; }
.logo { color: #c4452f; font-weight: bold; text-align: left;
        display: inline-block; font-size: 13px; line-height: 1.1; }
.subtitle { color: #c8a24a; font-weight: bold; letter-spacing: 0.1em;
            margin: 0.4em 0 0.2em; }
@media (max-width: 640px) { .logo { font-size: 7px; } }
.sub { color: #5c6370; margin-bottom: 2em; }
.sub code { color: #c8a24a; }
#authform input {
  display: block;
  margin: 0.5em auto;
  padding: 0.5em 0.8em;
  width: 16em;
  background: #1d1412;
  border: 1px solid #3a2c26;
  color: #ddd;
  font-family: inherit;
  font-size: 1em;
}
#authform input:focus { outline: 1px solid #c4452f; }
.buttons { margin-top: 1em; }
.buttons button {
  background: #241a16;
  color: #c8a24a;
  border: 1px solid #3a2c26;
  padding: 0.5em 1.5em;
  margin: 0 0.4em;
  font-family: inherit;
  font-size: 1em;
  cursor: pointer;
}
.buttons button:hover { border-color: #c4452f; }
#autherror { color: #e06c75; min-height: 1.2em; }
.scores-link { margin-top: 0.8em; }
.scores-link a { color: #5c6370; }
.scores-link a:hover { color: #c8a24a; }
#scorespanel h2 { color: #c8a24a; font-size: 1.1em; letter-spacing: 0.2em; }
#scorespanel ul {
  list-style: none;
  padding: 0;
  text-align: left;
  display: inline-block;
  white-space: pre;
  font-size: 0.85em;
  color: #d8dee9;
}
#term {
  font-size: 16px;
  line-height: 1.15;
  margin: 0.5em 0 0;
  white-space: pre;
}
.hint { color: #5c6370; font-size: 0.85em; }
.hint a { color: #5c6370; }
.c0 { color: #d8dee9; }
.c1 { color: #e06c75; }
.c2 { color: #98c379; }
.c3 { color: #e5c07b; }
.c4 { color: #61afef; }
.c5 { color: #c678dd; }
.c6 { color: #56b6c2; }
.c7 { color: #5c6370; }
.b { font-weight: bold; }
.b.c0 { color: #ffffff; }
@media (max-width: 1400px) { #term { font-size: 14px; } }
@media (max-width: 1100px) { #term { font-size: 12px; } }

/* ----------------------------------------------------- touch controls */
/* hidden unless JS adds body.mobile after a touch-mode connect */
#controls, #letters { display: none; }

body.mobile #game { width: 100%; }
body.mobile #term { margin: 2px auto 0; width: fit-content; }
body.mobile .hint { display: none; }

body.mobile #controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  max-width: 560px;
  padding: 8px;
  touch-action: manipulation;
}
#dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-auto-rows: 52px;
  gap: 5px;
}
#acts {
  display: grid;
  grid-template-columns: repeat(3, minmax(58px, 1fr));
  grid-auto-rows: 40px;
  gap: 5px;
  flex: 1;
  max-width: 240px;
}
body.mobile #letters {
  display: flex;
  gap: 4px;
  width: 100%;
  max-width: 560px;
  overflow-x: auto;
  padding: 0 8px 10px;
  -webkit-overflow-scrolling: touch;
}
.key {
  background: #21262d;
  color: #d8dee9;
  border: 1px solid #3a2c26;
  border-radius: 6px;
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  padding: 0;
}
.key:active { background: #30363d; border-color: #c4452f; }
.key.dir { color: #c8a24a; font-size: 18px; }
.key.act { color: #56b6c2; font-size: 13px; }
.key.act.more { color: #c8a24a; font-weight: bold; }
.key.letter {
  flex: 0 0 34px;
  height: 34px;
  color: #98c379;
}
.key.letter.shift { color: #c8a24a; font-weight: bold; }
.key.letter.shift.on { background: #3a2c26; border-color: #c4452f; }

#tiles {
  display: block;
  margin: 0.5em auto 0;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  background: #120c0a;
  border: 1px solid #3a2c26;
}

.site-links { margin-top: 0.4em; font-size: 0.95em; }
.site-links a { color: #c8a24a; }
.site-links a:hover { color: #c4452f; }
