#ai-box-wrap {
    overflow-y: auto;
    padding-top: 1.5em;
}

.ai-content #ai-question,
.ai-content #ai-noticed-words,
.ai-content #ai-situation-connection {
    min-height: 4em;
    resize: vertical;
}

@media screen and (max-width: 767px) {
    #ai-box-wrap {
        font-size: 1rem;
    }

    .ai-content textarea {
        font-size: 16px;
        line-height: 1.4;
        padding: 0.5em 0.7em;
        margin-bottom: 1em;
    }

    .ai-content #ai-question,
    .ai-content #ai-noticed-words,
    .ai-content #ai-situation-connection {
        height: calc(4.2em + 1em + 2px - 12px);
        min-height: 0;
        max-height: calc(4.2em + 1em + 2px - 12px);
        resize: none;
        overflow-y: auto;
    }

}

.ai-content button#copy-ai-prompt {
    display: block;
    width: auto;
    max-width: 100%;
    margin-top: 0;
    margin-right: auto;
    margin-bottom: 0;
    margin-left: auto;
    padding-right: 1.3em;
    padding-left: 1.3em;
}

.ai-content .ai-prompt-help {
    margin: 0.8em 0 0;
    line-height: 1.3;
}

.ai-content #copy-ai-prompt:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#visual-trigger {
	z-index: 11;
	--trigger-position: 50%;
	--trigger-split-gap: 1.5px; /* 左右で合計3pxの隙間 */
	max-width: 387.5em; /*620px*/
	width: calc(100% - 12em);
	height: 0.875rem;
	background: transparent;
	border: none;
	border-radius: 50%;
	margin: 3.5em auto -1em;
	position: relative;
}
#visual-trigger::before,
#visual-trigger::after {
	content: "";
	position: absolute;
	top: 0;
	height: 100%;
	background: var(--text-color3);
	border-radius: 999px;
	pointer-events: none;
}
#visual-trigger::before {
	left: 0;
	width: calc(var(--trigger-position) - var(--trigger-split-gap));
}
#visual-trigger::after {
	right: 0;
	width: calc(100% - var(--trigger-position) - var(--trigger-split-gap));
}
#trigger-bar {
	background: #fff;
	/*background: var(--color-red);*/
	height: calc(100% + 0.25rem);
	width: 1px;
	position: absolute;
	top: 50%;
	left: var(--trigger-position);
	margin-left: 0em;
	transform: translate(-50%, -50%);
	border-radius: 999px;
	transition: none;
	will-change: transform;
	visibility: visible;
	z-index: 1;
}
#trigger-bar.hidden {
	visibility: hidden;
}
#visual-trigger.is-static::before,
#visual-trigger.is-unsplit::before {
	width: 100%;
}
#visual-trigger.is-static::after,
#visual-trigger.is-unsplit::after {
	display: none;
}
#visual-trigger.is-unsplit #trigger-bar {
	visibility: hidden;
}
#visual-trigger label {
	cursor: pointer;
	position: absolute;
	top: 0;
	left: auto;
	right: -8em;
	text-align: right;
	width: 7em;
	font-size: 0.75em;
	color: var(--text-color1);
	vertical-align: middle;
	transform: translateY(-0.25em);
}
#visual-trigger label input {
	margin-right: 0.3em;
	vertical-align: middle;
}
#visual-trigger label span {
	line-height: 1;
	vertical-align: middle;
}

@media screen and (max-width: 767px) {
	#visual-trigger {
		max-width: 96%;
		width: calc(100% - 1em);
		margin: 0 auto 0.7em;
		transform: translateY(2em);
	}
	#visual-trigger label {
		position: absolute;
		top: 0;
		left: auto;
		right: 0;
		width: 7em;
		font-size: 0.75em;
		color: var(--text-color1);
		vertical-align: middle;
		transform: translateY(1.5em);
	}
}

.control {
    /* transformで作られる重なりを、卦パネル・サブ卦矢印より前にする。 */
    position: relative;
    z-index: 10;
	display: flex;
	gap: 0.625em;
	padding: 0 auto 0;
	justify-content: space-between;
	align-items: center;
	box-sizing: border-box;
	height: 9em;
	transform: translateY(0.5em);
}
.control p {
	width: calc((100% - 7em) / 2);
	padding: 0 1em;
	box-sizing: border-box;
}
.control .control-help {
    position: absolute;
    bottom: 1.3em;
    left: calc(50% - 3em - 0.4em);
    transform: translateX(-100%);
    width: max-content;
    margin: 0;
    padding: 0;
    color: #999;
    text-align: left;
    pointer-events: none;
}
.control-help > span { display: inline-block; font-size: 0.7rem; line-height: 1.2; }

@media screen and (min-width: 768px) {
    /* 卦枠の上へ配置したリセットを、操作エリア（z-index: 10）より前にする。 */
    .container > .divination-operation-area + .hexagram-wrap > .reset-btn-wrap {
        z-index: 11;
    }
}

@media screen and (max-width: 767px) {
	.divination-operation-area {
		display: flex;
		flex-direction: column;
	}
	.divination-operation-area > #visual-trigger {
		flex-shrink: 0;
	}
	.divination-operation-area > .control {
		flex: 1 0 auto;
		height: auto;
		min-height: 8em;
	}
	.control {
		font-size: 0.7rem;
		height: 8em;
		margin-bottom: 1.2em;
		transform: translateY(1.5em);
	}
}

/*--------------------------*/
#btn-1 {
	color: white;
	width: 6em;
	height: 6em;
	line-height: 6em;
	border-radius: 50%;
	font-size: 0.93rem;
	background-color: #999;
	border: none;
	box-sizing: border-box;
	opacity: 1;
	cursor: grab;
    outline: none;
	user-select: none;
    transition: all 0.3s ease;
    position: relative;
	z-index: 1;
	--duration: 3s;
}
#btn-1:enabled:hover {
	opacity: 0.7;
	transform: scale(0.95);
	transition: all 0.3s ease;
}
#btn-1:enabled:active {
	opacity: 1;
	box-sizing: border-box;
	transform: scale(0.95);
	cursor: grabbing;
	transition: all 0.3s ease;
	z-index: 10000;
}
#btn-1:enabled:active .wave {
	background-color: var(--active-btn-color, #999);
}
/*--------------------------*/
#btn-1 .wave {
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    border-radius: 50%;
	box-sizing: border-box;
    background-color: var(--active-btn-color, #999);
    opacity: 0;
    pointer-events: none;
    z-index: -1!important;
}
#btn-1:enabled:active .w1,
#btn-1:enabled:active .w2,
#btn-1:enabled:active .w3,
#btn-1:enabled:active .w4,
#btn-1:enabled:active .w5 {
	animation: smoothPulse var(--duration) cubic-bezier(0.2, 0.55, 0.45, 1) infinite,
        rippleFade var(--duration) linear infinite;
}
/*#btn-1:enabled:active .w1 {  
}*/
#btn-1:enabled:active .w2 {
    animation-delay: calc(var(--duration) / 5);
}
#btn-1:enabled:active .w3 {
    animation-delay: calc(var(--duration) * 2 / 5);
}
#btn-1:enabled:active .w4 {
    animation-delay: calc(var(--duration) * 3 / 5);
}
#btn-1:enabled:active .w5 {
    animation-delay: calc(var(--duration) * 4 / 5);
}

@media screen and (max-width: 767px) {
	#btn-1:enabled:active {
		touch-action: none;
		z-index: 10000;
	}
	#btn-1:enabled:hover {
		transform: scale(1.0);
		transition: all 0.3s ease;
	}
	#btn-1:enabled:active {
		transform: scale(1.1);
	}
}

@keyframes smoothPulse {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(6);
    }
}

@keyframes rippleFade {
    0% {
        opacity: 0;
    }
    12% {
        opacity: 0.5;
    }
    60% {
        opacity: 0.18;
    }
    100% {
        opacity: 0;
    }
}

#btn-1:disabled,
#btn-1[style*="pointer-events: none"] {
    cursor: not-allowed;
    /* ホバー時の装飾を消す */
    background-color: #999 !important; 
    transform: none !important;
	pointer-events: none!important;
}
#btn-1 #stage-title {
	display: block;
	line-height: 1.2;
	font-size: 0.9rem;
	pointer-events: auto;
	-webkit-user-select: none;   /* iOS Safari, Android Chrome */
	-webkit-touch-callout: none; /* iOS Safari の長押しポップアップ（コピーなど）を禁止 */
	user-select: none;
}
/* 完了時は、子要素の pointer-events: auto でも操作対象に戻さない。 */
#btn-1:disabled *,
#btn-1[style*="pointer-events: none"] * {
    pointer-events: none !important;
}
#btn-1 #stage-title #yao-name {
	display: block;
}
#btn-1 #stage-title #phase-number {
	display: block;
	font-size: 2.0em;
	font-family: "Roboto Condensed", sans-serif;
	font-weight: 300;
}

@media screen and (max-width: 767px) {
	#btn-1 {
		font-size: 0.65rem;
		transform: translateY(0em);
	}
}

.history-item {
	width: 100%;
	box-sizing: border-box;
	margin-bottom: 0;
	padding: 0.8em 20px 0.8em;
	border-top: 1px dashed var(--border-color);
	background: #fff;
}
.history-item .tbl_ttl {
	margin: 0em 0 0.8em;
	line-height: 1;
	font-size: 0.7rem;
	font-weight: 500;
}
.history-item .tbl_ttl span:nth-child(1) {
	display: block;
	font-size: 1.5em;
	margin: 0.2em -20px 0.5em;
	padding: 0 20px 0.5em;
	border-bottom: 2px solid var(--border-color);
}
.history-item .tbl_ttl span:nth-child(2) {
	display: block;
	padding-top: 0.3em;
	font-size: 1.5em!important;
	/*font-size: 0.7em;*/
}
.history-item:nth-child(4n+2) .tbl_ttl span:nth-child(1),
.history-item:nth-child(4n+3) .tbl_ttl span:nth-child(1),
.history-item:nth-child(4n) .tbl_ttl span:nth-child(1) {
	display: none;
}
.history-item .tbl_ttl span:nth-child(2){
	font-size: 1.3em;
}
.history-item:first-child,
.log-kou + .history-item {
	border: none;
}
#history-log > .history-item:first-child,
#history-log > .log-kou + .history-item {
    border-top: 2px solid var(--border-color);
}
#history-log > .log-kou + .history-item {
    margin-top: 1em;
}
.log-box .tbl-log {
	border-collapse: collapse;
	line-height: 2.0;
	background: #fff;
}
.log-box .tbl-log th,
.log-box .tbl-log td,
.log-box .tbl-log td span {
	vertical-align: top;
}
.log-box .tbl-log th {
	padding-right: 1.5em;
	white-space: nowrap;
}
.log-box .tbl-log td span {
	display: inline-block;
}
.log-box .tbl-log td span:nth-child(1) {
	width: 8.0em;
}
.log-box .tbl-log td span:nth-child(2) {
	width: 7.5em;
	margin-right: -1em;
	box-sizing: border-box;
}
.log-kou {
	background: #fff;
	border-top: 1px dashed var(--border-color);
	padding: 0.8em 1.5em;
	display: flex;
	justify-content: flex-end;
	gap: 1em;
	align-items: center;
	/*margin-bottom: 2em;*/
	margin-bottom: 0;
	text-align: right;
}
.log-kou p {
	padding: 0;
	margin: 0;
	line-height: 18px;
	text-align: left;
}
.log-kou .yao {
	font-size: 1.4em;
	line-height: 18px;
	margin-left: 0.5em;
	color: var(--color-red);
}
.log-kou .sisho {
	padding-left: 1em;
	font-size: 1.2em;
	color: var(--color-red);
}
.log-stage-fix {
	margin-top: 2em;
}
#log-display p {
	padding: 0.8em 1em 0;
	text-align: center;
}
@media screen and (max-width: 767px) {
	.history-item {
		padding: 0.8em 10px 0.8em;
	}
	.history-item .tbl_ttl span:nth-child(1) {
		margin: 0.2em -10px 0.5em;
		padding: 0 10px 0.5em;
	}
	#log-display p {
		padding: 0.8em 1em 0;
		text-align: center;
	}
}
#log-display .log-intro {
    text-align: left;
    font-size: 1.1em;
    line-height: 1.6em;
}
@media screen and (max-width: 767px) {
    #log-display .log-intro {
        font-size: 1.2em;
    }
    #log-box-wrap:has(.log-intro) {
        padding-top: 2em;
    }
}
#log-display .log-intro h3 {
    margin: 1.6em 0 0.6em;
    padding: 0.45em 0.7em;
    border-left: 3px solid var(--text-color2);
    font-size: 1.05em;
    font-weight: 600;
    line-height: 1.5;
    text-align: left;
}
#log-display .log-intro h3:first-child {
    margin-top: 0;
}
#log-display .log-intro .change-count {
    white-space: nowrap;
}
#log-display .log-intro .multiply-sign {
    margin: 0 0.2em;
}
#log-display .log-intro .probability-table {
    width: 100%;
    margin: 0 0 1em;
    border-collapse: collapse;
    font-size: inherit;
}
#log-display .log-intro .probability-table th,
#log-display .log-intro .probability-table td {
    padding: 0.5em 0.3em;
    border-bottom: 1px solid var(--border-color);
    text-align: right;
    vertical-align: middle;
}
#log-display .log-intro .probability-table th {
    font-weight: 500;
}
#log-display .log-intro .probability-table th:first-child {
    text-align: left;
    white-space: nowrap;
}
#log-display .log-intro p {
    padding: 0;
    margin: 0 0 1em;
    text-align: left;
    line-height: inherit;
}
.log-intro ol {
    list-style: decimal;
    padding-left: 1.5em;
    margin: 0 0 1em;
}
.log-intro li + li {
    margin-top: 0.7em;
}
/* 易占前の紹介文。本卦は爻の描画開始時、サブ卦は完了時に置き換わる。 */
.sub-panel .sub-gua-intro,
#hexagram > .honka-intro {
    width: 100%;
    max-height: 100%;
    margin: auto 0;
    padding: 1em 1.7em;
    box-sizing: border-box;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.6em;
    text-align: left;
    color: var(--text-color2);
}

@media screen and (min-width: 768px) {
    .sub-panel .sub-gua-intro,
    #hexagram > .honka-intro {
        position: relative;
        top: 1em;
        font-size: 1rem;
        padding-left: 1.7em;
        padding-right: 1.7em;
    }
}

@media screen and (max-width: 767px) {
    .sub-panel .sub-gua-intro,
    #hexagram > .honka-intro {
        font-size: 1.55em;
		margin: 0;
        padding-left: 1.9em;
        padding-right: 1.9em;
    }

    #hexagram > .honka-intro {
        /* サブ卦の上余白 2.5em × 0.62rem と、紹介文の上余白を揃える。 */
        padding-top: calc(2.5em + 1.55rem);
    }

    .sub-panel .sub-gua-intro {
        padding-top: 2.5em;
    }
}


.control:has(#btn-1:enabled:active) {
    z-index: 1002;
}
