/* =============================================
   語音検査アプリ — 被検者タブレット用スタイル
   ============================================= */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Hiragino Sans', 'Meiryo', sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* =============================================
   画面共通
   ============================================= */
.pt-screen {
  display: none;
  width: 100vw;
  height: 100vh;
}
.pt-screen.active {
  display: flex;
}

/* =============================================
   接続画面
   ============================================= */
#pt-screen-connect {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.pt-connect-wrap {
  width: 100%;
  max-width: 480px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.pt-logo {
  font-size: 64px;
  line-height: 1;
}

.pt-title {
  font-size: 28px;
  font-weight: bold;
  color: #fff;
  letter-spacing: 0.05em;
}

.pt-subtitle {
  font-size: 16px;
  color: #90a0b0;
  margin-bottom: 8px;
}

.pt-card {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pt-label {
  font-size: 13px;
  color: #90a0b0;
  margin-bottom: 2px;
}

.pt-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 18px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
}
.pt-input:focus {
  border-color: #4a9eff;
}

.pt-code-input {
  font-size: 32px;
  text-align: center;
  letter-spacing: 0.3em;
  font-weight: bold;
}

.pt-btn {
  padding: 16px;
  font-size: 18px;
  font-weight: bold;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  touch-action: manipulation;
}
.pt-btn:active {
  opacity: 0.8;
  transform: scale(0.97);
}

.pt-btn-primary {
  background: linear-gradient(135deg, #4a9eff, #2563eb);
  color: #fff;
  margin-top: 4px;
}

.pt-connect-msg {
  font-size: 14px;
  text-align: center;
  min-height: 20px;
  color: #ff7070;
}
.pt-connect-msg.ok {
  color: #70d070;
}

/* =============================================
   待機画面
   ============================================= */
#pt-screen-waiting {
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.pt-waiting-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.pt-spinner {
  width: 64px;
  height: 64px;
  border: 5px solid rgba(255,255,255,0.15);
  border-top-color: #4a9eff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.pt-waiting-text {
  font-size: 22px;
  color: #c0d0e0;
}

.pt-waiting-sub {
  font-size: 16px;
  color: #80909a;
}

.pt-code-display {
  font-size: 28px;
  font-weight: bold;
  letter-spacing: 0.3em;
  color: #4a9eff;
}

/* =============================================
   入力画面
   ============================================= */
#pt-screen-input {
  flex-direction: column;
  background: #f0f4f8;
  color: #1a1a2e;
}

/* ---- モードバー ---- */
.pt-mode-bar {
  display: flex;
  gap: 0;
  background: #1a1a2e;
  padding: 8px 8px 0;
  flex-shrink: 0;
}

.pt-mode-btn {
  flex: 1;
  padding: 10px 4px;
  font-size: 15px;
  font-weight: bold;
  border: none;
  border-radius: 8px 8px 0 0;
  background: rgba(255,255,255,0.1);
  color: #aaa;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s;
}
.pt-mode-btn.active {
  background: #f0f4f8;
  color: #1a1a2e;
}
.pt-mode-btn:active {
  opacity: 0.75;
}

/* ---- プロンプト ---- */
.pt-prompt {
  background: #1a1a2e;
  color: #fff;
  text-align: center;
  padding: 14px 12px;
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- 入力エリア共通 ---- */
.pt-input-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
}
.pt-input-area.hidden {
  display: none;
}

/* =============================================
   手書きエリア
   ============================================= */
.pt-canvas {
  background: #fff;
  border: 3px solid #ccd;
  border-radius: 12px;
  touch-action: none;
  cursor: crosshair;
  display: block;
}

.pt-btn-clear {
  margin-top: 14px;
  padding: 14px 40px;
  font-size: 17px;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: bold;
  touch-action: manipulation;
}
.pt-btn-clear:active {
  opacity: 0.75;
}

/* =============================================
   テンキーエリア (SRT: 2〜7)
   ============================================= */
.pt-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 420px;
}

.pt-numpad-btn {
  aspect-ratio: 1;
  font-size: 48px;
  font-weight: bold;
  background: #fff;
  border: 3px solid #ccd;
  border-radius: 16px;
  cursor: pointer;
  color: #1a1a2e;
  touch-action: manipulation;
  transition: background 0.1s, transform 0.08s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pt-numpad-btn:active {
  background: #4a9eff;
  color: #fff;
  transform: scale(0.93);
}

/* =============================================
   五十音エリア
   ============================================= */
.pt-direction-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.pt-dir-btn {
  padding: 8px 24px;
  font-size: 15px;
  font-weight: bold;
  border: 2px solid #aab;
  border-radius: 8px;
  background: #fff;
  color: #556;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s;
}
.pt-dir-btn.active {
  background: #1a1a2e;
  color: #fff;
  border-color: #1a1a2e;
}

/* 選択済み文字表示 */
.pt-kana-selected {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff3cd;
  border: 2px solid #ffc107;
  border-radius: 10px;
  padding: 6px 18px;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.pt-kana-selected.hidden {
  display: none;
}

#pt-kana-selected-char {
  font-size: 36px;
  font-weight: bold;
  color: #1a1a2e;
  min-width: 1.2em;
  text-align: center;
}

.pt-btn-clear-kana {
  padding: 6px 16px;
  font-size: 15px;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  touch-action: manipulation;
}
.pt-btn-clear-kana:active { opacity: 0.75; }

/* 五十音グリッド */
.pt-gojuuon {
  display: grid;
  gap: 5px;
  overflow: auto;
  max-height: 100%;
  max-width: 100%;
}

/* 横書き: 10行×5列 (ア行〜ワ行) */
.pt-gojuuon.yoko {
  grid-template-columns: repeat(5, 1fr);
  width: 100%;
  max-width: 480px;
}

/* 縦書き: 5行×10列 */
.pt-gojuuon.tate {
  grid-template-columns: repeat(10, 1fr);
  width: 100%;
  max-width: 640px;
}

.pt-kana-btn {
  aspect-ratio: 1;
  font-size: 20px;
  font-weight: bold;
  background: #fff;
  border: 2px solid #ccd;
  border-radius: 8px;
  cursor: pointer;
  color: #1a1a2e;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, transform 0.08s;
  min-width: 0;
  padding: 0;
}
.pt-kana-btn:active {
  background: #4a9eff;
  color: #fff;
  transform: scale(0.90);
}
.pt-kana-btn.empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
  pointer-events: none;
}
.pt-kana-btn.selected {
  background: #ffc107;
  border-color: #e6a800;
  color: #1a1a2e;
}

/* 濁音・半濁音は少し小さく */
.pt-kana-btn.dakuten {
  font-size: 17px;
}
