html::before {
  content: 'CodePen ♥ The Web';
  position: fixed;
  inset: 0;
  z-index: -1;
  margin: auto;
  width: fit-content;
  height: fit-content;
  font-family: monospace;
  opacity: 0.6;
  background: rebeccapurple;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
}
/* iPhone等の自動文字サイズ調整による崩れを防止 */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  background-color: #121212;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Meiryo", sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

#game-container {
  width: 100%;
  max-width: 600px;
  height: 90vh;
  background: #1e1e1e;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  overflow: hidden;
  position: relative;
}

header {
  padding: 12px 16px;
  background: #2a2a2a;
  border-bottom: 2px solid #333;
}

h1 {
  margin: 0 0 8px 0;
  font-size: 1.1rem;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.version-tag {
  font-size: 0.8rem;
  color: #888;
  font-weight: normal;
}

.status-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.status-item {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
}

.label {
  width: 60px;
}

.bar-container {
  flex: 1;
  height: 10px;
  background: #444;
  border-radius: 5px;
  overflow: hidden;
  margin: 0 8px;
}

#sanity-bar {
  height: 100%;
  width: 0%;
  background: #2ecc71;
  transition: width 0.3s;
}

#stamina-bar {
  height: 100%;
  width: 100%;
  background: #e74c3c;
  transition: width 0.3s;
}

.value {
  width: 35px;
  text-align: right;
  font-weight: bold;
}

main#screen {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: #141414;
  line-height: 1.6;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

footer#controls {
  padding: 12px 16px;
  background: #2a2a2a;
  border-top: 2px solid #333;
}

#system-msg {
  font-size: 0.85rem;
  color: #f1c40f;
  margin-bottom: 8px;
  min-height: 1.2em;
}

#command-box {
  display: flex;
  justify-content: center;
}

#start-btn {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#action-btns {
  width: 100%;
  display: flex;
  gap: 8px;
}

#action-btns button {
  flex: 1;
  padding: 10px 4px;
  font-size: 0.85rem;
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  font-weight: bold;
}

#action-btns button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-through { background: #7f8c8d; }
.btn-notice { background: #e67e22; }
.btn-correct { background: #e74c3c; }

/* ルール説明モーダル */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 20px;
  box-sizing: border-box;
}

.modal-content {
  background: #222;
  border: 2px solid #3498db;
  border-radius: 8px;
  padding: 20px;
  color: #fff;
  text-align: left;
  line-height: 1.6;
}

.modal-content h2 {
  margin-top: 0;
  color: #3498db;
  font-size: 1.2rem;
  text-align: center;
}

.modal-content p {
  font-size: 0.9rem;
  margin: 12px 0;
}

.btn-modal-start {
  width: 100%;
  padding: 12px;
  margin-top: 16px;
  font-size: 1rem;
  background: #2ecc71;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

/* エンド・リザルトパネル */
#ending-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  background: #222;
  border: 2px solid #e74c3c;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  z-index: 10;
}

#ending-title { margin-top: 0; }
#ending-score { font-size: 1.1rem; font-weight: bold; margin: 10px 0; }
#ending-msg { font-size: 0.9rem; line-height: 1.5; white-space: pre-wrap; }

.btn-retry {
  padding: 10px 20px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 10px;
}
