@import url('https://fonts.googleapis.com/css2?family=Kosugi+Maru&display=swap');

:root {
  --primary-color: #2b9348;
  --bg-color: #f4fcf4;
  --frame-color: #d4a373;
  --beam-color: #8b5a2b;
  --rod-color: #e0c097;
  --bead-color: #0077b6; 
  --go-bead-color: #55a630; 
  --text-main: #333;
}

body {
  font-family: 'Kosugi Maru', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  margin: 0;
  padding: 10px; 
  display: flex;
  justify-content: center;
}

.app-container {
  max-width: 900px;
  width: 100%;
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  padding: 15px; 
  box-sizing: border-box;
}

header {
  border-bottom: 3px dashed #c7e9c0;
  padding-bottom: 5px;
  margin-bottom: 10px;
}

.title-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-area h1 {
  color: var(--primary-color);
  margin: 0;
  font-size: 24px; 
}

.header-desc {
  margin: 5px 0;
  font-size: 14px;
}

.controls {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

button {
  font-family: inherit;
  background: #f0f0f0;
  border: 2px solid #ccc;
  padding: 6px 14px; 
  border-radius: 20px;
  font-size: 14px; 
  cursor: pointer;
  transition: all 0.2s;
  font-weight: bold;
}

button.active, button:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.panel {
  background: #fff0f3;
  border: 2px solid #ffb3c6;
  border-radius: 12px;
  padding: 15px; 
  margin-bottom: 15px;
}

.panel.hidden { display: none; }

.question-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.question-header h2 {
  margin: 0;
  font-size: 18px; 
}

.highlight-number {
  font-size: 28px; 
  font-weight: bold;
  letter-spacing: 1px;
  margin-right: 10px;
}

.desc-text {
  color: #555;
  font-size: 14px;
}

.hint-section {
  margin-top: 10px;
  border-top: 1px solid #ffc8dd;
  padding-top: 10px;
}

#hint-btn {
  background: #ffb703;
  border-color: #fb8500;
  color: white;
}

#hint-text {
  color: #d62828;
  font-weight: bold;
  margin-top: 5px;
  background: #ffe5d9;
  padding: 8px;
  border-radius: 8px;
  font-size: 14px;
}

/* そろばんの描画 */
.soroban-wrapper {
  overflow-x: auto;
  padding: 10px 0; 
}

.soroban {
  position: relative;
  height: 200px; 
  background: var(--frame-color);
  border: 8px solid #8b5a2b; 
  border-radius: 6px;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
  min-width: max-content;
  padding: 0 6px;
}

.beam {
  position: absolute;
  top: 55px; 
  left: 0;
  right: 0;
  height: 8px; 
  background: var(--beam-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  z-index: 5;
}

/* 定位点（白い点）を梁の真上に配置 */
.teiiten {
  position: absolute;
  width: 6px; 
  height: 6px;
  background: #fff;
  border-radius: 50%;
  top: 56px; 
  left: 50%;
  transform: translateX(-50%);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
  z-index: 20; 
}

.rods-container {
  display: flex;
  height: 100%;
}

.rod-col {
  position: relative;
  width: 38px; 
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 串（軸） */
.rod-col::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px; 
  background: var(--rod-color);
  box-shadow: inset -1px 0 2px rgba(0,0,0,0.3);
  z-index: 1;
}

/* 珠のサイズと形状 */
.bead {
  position: absolute;
  width: 32px; 
  height: 18px; 
  background: var(--bead-color);
  clip-path: polygon(10% 0%, 90% 0%, 100% 50%, 90% 100%, 10% 100%, 0% 50%);
  z-index: 10;
  cursor: pointer;
  transition: transform 0.1s cubic-bezier(0.2, 0.8, 0.2, 1); 
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.4), inset 0 1px 1px rgba(255,255,255,0.4);
}

.bead.go-bead { background: var(--go-bead-color); }

.go-bead { top: 6px; }
.go-bead.active { transform: translateY(28px); } 

.ichi-bead-1 { top: 108px; }
.ichi-bead-2 { top: 128px; }
.ichi-bead-3 { top: 148px; }
.ichi-bead-4 { top: 168px; }

.ichi-bead-1.active { transform: translateY(-44px); } 
.ichi-bead-2.active { transform: translateY(-44px); }
.ichi-bead-3.active { transform: translateY(-44px); }
.ichi-bead-4.active { transform: translateY(-44px); }

.display-area {
  margin-top: 10px; 
  text-align: center;
}

.speech-bubble {
  background: #e9ecef;
  border-radius: 16px;
  padding: 10px 15px; 
  display: inline-block;
  min-width: 250px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.bubble-title {
  margin: 0 0 5px 0;
  color: #6c757d;
  font-weight: bold;
  font-size: 14px;
}

.current-number {
  font-size: 28px; 
  font-weight: bold;
  color: var(--primary-color);
  letter-spacing: 1px;
}

input[type="text"] {
  padding: 6px 10px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 180px;
  margin: 0 5px;
}

.success-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.success-box {
  background: white;
  padding: 30px;
  border-radius: 16px;
  text-align: center;
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-box h3 {
  font-size: 28px;
  color: #d62828;
  margin-top: 0;
}

.hidden { display: none !important; }

@keyframes popIn {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}