html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #2c4a66;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  touch-action: none;
  border-radius: 6px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

/* スマホ縦向きのときの案内 */
#rotate {
  display: none;
  position: fixed;
  inset: 0;
  background: #a9dcf7;
  color: #5a3b2b;
  align-items: center;
  justify-content: center;
  font-family: 'Hiragino Maru Gothic ProN', 'M PLUS Rounded 1c', 'Yu Gothic UI', 'Meiryo', sans-serif;
  font-weight: bold;
  font-size: 22px;
  text-align: center;
  z-index: 10;
}

.phone {
  width: 60px;
  height: 100px;
  margin: 0 auto 20px;
  border: 5px solid #5a3b2b;
  border-radius: 14px;
  background: #fff8ec;
  animation: turn 2s ease-in-out infinite;
}

@keyframes turn {
  0%, 30% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(-90deg); }
}

@media (orientation: portrait) and (pointer: coarse) {
  #rotate {
    display: flex;
  }
}

[hidden] {
  display: none !important;
}

/* ---------- HTMLの画面（ホーム画面に追加・合言葉入力） ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20; /* 縦向きの案内より手前（縦向きでも読める・入力できる） */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(44, 74, 102, 0.72);
  overflow-y: auto;
  -webkit-user-select: text;
  user-select: text;
  touch-action: auto;
  font-family: 'Hiragino Maru Gothic ProN', 'M PLUS Rounded 1c', 'Yu Gothic UI', 'Meiryo', sans-serif;
  color: #5a3b2b;
}

.card {
  box-sizing: border-box;
  width: 100%;
  max-width: 560px;
  max-height: 100%;
  overflow-y: auto;
  margin: auto;
  padding: 22px 22px 18px;
  background: #fff8ec;
  border: 3px solid #5a3b2b;
  border-radius: 26px;
  box-shadow: 0 6px 0 rgba(90, 59, 43, 0.35);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card h1 {
  margin: 0;
  font-size: 22px;
  text-align: center;
  text-wrap: balance;
}

.card .lead {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
}

.app-icon {
  align-self: center;
  border-radius: 18px;
  border: 3px solid #5a3b2b;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.steps section {
  border: 2px dashed rgba(90, 59, 43, 0.4);
  border-radius: 16px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
}

.steps section.mine {
  border: 3px solid #5a3b2b;
  background: #fff1cf;
  order: -1;
}

.steps h2 {
  margin: 0 0 4px;
  font-size: 15px;
}

.steps ol {
  margin: 0;
  padding-left: 1.3em;
}

.card label {
  font-size: 14px;
  font-weight: bold;
}

.card input[type='text'],
.card input:not([type]) {
  font: inherit;
  font-size: 18px; /* 16px以上にして iPhone の自動ズームを防ぐ */
  padding: 10px 14px;
  border: 2.5px solid #5a3b2b;
  border-radius: 14px;
  background: #fff;
  color: #5a3b2b;
}

.card .check {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: normal;
  font-size: 14px;
}

.card .check input {
  width: 20px;
  height: 20px;
}

.card button {
  font: inherit;
  font-weight: bold;
  font-size: 18px;
  min-height: 48px;
  padding: 8px 20px;
  border: 3px solid #5a3b2b;
  border-radius: 999px;
  background: #fff6e8;
  color: #5a3b2b;
  box-shadow: 0 4px 0 rgba(90, 59, 43, 0.35);
  cursor: pointer;
}

.card button.primary {
  background: #ffcf73;
}

.card button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(90, 59, 43, 0.35);
}

.card button:disabled {
  opacity: 0.55;
}

.card button:focus-visible,
.card input:focus-visible {
  outline: 3px solid #5fb8f5;
  outline-offset: 2px;
}

.card .row {
  display: flex;
  gap: 10px;
}

.card .row button {
  flex: 1;
}

.status {
  min-height: 1.4em;
  margin: 0;
  font-size: 14px;
  text-align: center;
}

.status.error {
  color: #d9434f;
  font-weight: bold;
}

@media (prefers-reduced-motion: reduce) {
  .phone {
    animation: none;
  }
}
