:root {
  --bg: #f4f1ee;
  --fg: #000;
  --sidebar-bg: #ddd;
  --letter-bg-1: #e4dad2;
  --letter-bg-2: #d9e6ed;
  --letter-bg-3: #f7c5b1;
  --letter-bg-4: #ede4cb;
  --letter-bg-5: #d2c1b0;
  --button-bg: #e6e6e6;
  --button-hover: #ccc;
  --input-bg: #fff;
  --box-bg: #fffaf5;
  --box-border: #aaa;
}
[data-theme='dark'] {
  --bg: #121212;
  --fg: #eee;
  --sidebar-bg: #333;
  --button-bg: #444;
  --button-hover: #666;
  --input-bg: #222;
  --box-bg: #1a1a1a;
  --box-border: #666;
}

body {
  margin: 0;
  font-family: monospace;
  display: flex;
  height: 100vh;
  background-color: var(--bg);
  color: var(--fg);
}

#sidebar {
  width: 25%;
  background: var(--sidebar-bg);
  overflow-y: auto;
  padding: 1em;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.toggle-container {
  display: flex;
  align-items: center;
  margin-bottom: 1em;
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 20px;
  background: #999;
  border-radius: 10px;
  cursor: pointer;
  margin-right: 0.5em;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

[data-theme='dark'] .toggle-switch::after {
  transform: translateX(20px);
}

#main {
  width: 75%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 2em;
}

#header {
  font-family: 'Courier New', monospace;
  font-size: 2.5em;
  margin-bottom: 1em;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.letter {
  display: inline-block;
  transform: rotate(calc(-10deg + 20deg * var(--rand)));
  font-weight: bold;
  margin: 0 0.1em;
  padding: 0.1em 0.2em;
  color: #000;
  font-family: Impact, sans-serif;
}

.letter:not(.space):nth-child(5n+1) { background: var(--letter-bg-1); }
.letter:not(.space):nth-child(5n+2) { background: var(--letter-bg-2); }
.letter:not(.space):nth-child(5n+3) { background: var(--letter-bg-3); }
.letter:not(.space):nth-child(5n+4) { background: var(--letter-bg-4); }
.letter:not(.space):nth-child(5n+5) { background: var(--letter-bg-5); }

.letter.space {
  background: transparent;
  padding: 0 0.2em;
}

#game {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5em;
  width: 100%;
}

#lastSentence {
  font-size: 1.25em;
  font-weight: bold;
  text-align: center;
  margin-bottom: 0.5em;
  max-width: 600px;
}

#sentenceInput {
  font-size: 1.5em;
  padding: 0.5em;
  width: 80%;
  max-width: 600px;
  border: none;
  border-bottom: 2px solid var(--fg);
  background: var(--input-bg);
  outline: none;
  text-align: center;
  color: var(--fg);
  margin-top: 0.5em;
}

#submitBtn,
#startBtn,
#endGameBtn {
  margin-top: 1em;
  font-size: 1em;
  padding: 0.6em 1.2em;
  cursor: pointer;
  background: var(--button-bg);
  border: 1px solid var(--fg);
  color: var(--fg);
  border-radius: 4px;
  transition: background 0.2s;
}

#submitBtn:hover,
#startBtn:hover,
#endGameBtn:hover {
  background: var(--button-hover);
}

#finalOutput {
  margin-top: 2em;
  text-align: center;
}

.contribution {
  margin: 0.5em 0;
}

.workTitle {
  font-weight: bold;
  margin-top: 1em;
}

.savedWork {
  margin-bottom: 1em;
  cursor: pointer;
}

#config label,
#config input,
#config select {
  font-size: 1em;
  margin: 0.5em 0;
}

#config input[type="number"],
#config select {
  padding: 0.4em;
  font-size: 1em;
  background: var(--input-bg);
  color: var(--fg);
  border: 1px solid var(--fg);
  border-radius: 3px;
}

#instructions {
  font-size: 1em;
  max-width: 600px;
  text-align: center;
  margin-bottom: 1.5em;
  color: var(--fg);
}

#printLink {
  margin-top: 2em;
  font-size: 0.9em;
  text-decoration: underline;
  cursor: pointer;
  color: var(--fg);
  text-align: center;
  display: block;
}

#config {
  background-color: var(--box-bg);
  border: 1px solid var(--box-border);
  border-radius: 6px;
  padding: 1.5em;
  max-width: 400px;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.05);
  text-align: left;
  margin-bottom: 1em;
}

