html, body {
    height: 100%;
    overflow: hidden;
    margin: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #ffffff;
    color: #111111;
}

#app {
    width: 90%;
    max-width: 800px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

#btn-undo-last,
#btn-undo-last-results,
.btn-secondary {
  transition: opacity 0.2s ease-out;
}

.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; }
#participant-id {
    text-transform: lowercase;
}

button {
    padding: 10px 20px;
    font-size: 1em;
    cursor: pointer;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
}
button:disabled { background-color: #ccc; }

#press-button {
    width: 100%;
    max-width: 600px;
    height: 200px;
    background-color: #e9e9e9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.5em;
    cursor: pointer;
    border-radius: 8px;
    user-select: none;
    transition: opacity 0.4s ease-out;
}
#press-button.disabling {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}
#motor-area-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    background-color: #f0f0f0;
    border-radius: 8px;
    padding: 20px;
}
#btn-start-calibration, #btn-start-main {
    padding: 25px 50px;
    font-size: 1.5em;
    font-weight: bold;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.1s, background-color 0.2s;
}
#btn-start-calibration:hover, #btn-start-main:hover {
    background-color: #218838;
    transform: translateY(-2px);
}
#btn-start-calibration:active, #btn-start-main:active {
    transform: translateY(0);
}

#motor-area-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    background-color: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
}
.motor-guide-text {
    font-size: 1.2em;
    color: #495057;
    margin-bottom: 20px;
}
#motor-area {
    background-color: #e9e9e9;
    border-radius: 8px;
    height: 200px;
    width: 100%;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.5em;
    text-align: center;
    user-select: none;
}
/* 押した瞬間は即時緑（transitionなし）、戻る時はゆっくりフェード */
#motor-area.responded { background-color: #5cb85c; transition: none; }

/* --- Gojuon Grid Styles --- */
.choice-step.gojuon-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 5px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
}
.initial-btn {
    width: 100%;
    aspect-ratio: 1 / 1;
    font-size: 1.4em;
    background-color: #ffffff;
    color: #111111;
    border: 2px solid #444444;
    font-weight: 700;
}
.initial-btn:hover:not([disabled]) {
    background-color: #e6f2ff;
    border-color: #005fcc;
}
.initial-btn.disabled {
    background-color: #eeeeee;
    color: #aaaaaa;
    border-color: #dddddd;
    cursor: not-allowed;
}
.initial-btn.placeholder { visibility: hidden; }


/* --- Pie Menu --- */
.pie-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 1000;
}
.pie-svg{
  width: 100vw;
  height: 100vh;
  display: block;
}
.pie-sector{
  fill: #ffffff;
  stroke: #333;
  stroke-width: 2;
  cursor: pointer;
  transition: fill 0.1s;
}
.pie-sector:hover { fill: #f0f7ff; }
.pie-sector.selected { fill: #007bff; stroke: #0056b3; }
.pie-sector.confirmed { fill: #28a745; stroke: #1e7e34; transition: none; }
.pie-label.confirmed { fill: white; stroke: #1e7e34; stroke-width: 3px; transition: none; }
.pie-label {
  font-size: 16px;
  font-weight: bold;
  pointer-events: none;
  user-select: none;
  fill: #111;
  stroke: white;
  stroke-width: 5px;
  stroke-linejoin: round;
  paint-order: stroke fill;
}
.pie-label.selected {
  fill: white;
  stroke: #0056b3;
  stroke-width: 3px;
}

/* 中央の決定・戻るボタン */
.pie-center-group { cursor: pointer; }
.pie-center-circle { fill: #ffffff; stroke: #333; stroke-width: 3; }
.pie-center-circle.active { fill: #28a745; stroke: #1e7e34; }
.pie-center-circle.back { fill: #f8f9fa; }
.pie-center-text {
  font-size: 18px;
  font-weight: 800;
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: central;
}
.pie-center-text.active { fill: white; }

/* Volume Check */
#volume-playing-indicator {
    font-size: 1.6em;
    font-weight: bold;
    color: #28a745;
    margin: 30px auto;
    animation: volumePulse 2.5s ease-in-out infinite;
}
@keyframes volumePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Loader */
.loader {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #3498db;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 2s linear infinite;
    margin: 20px auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }


#results-stats {
    font-size: 16px;
    line-height: 1.6;
}
